diff --git a/data/testing/images/arrow-big.png b/data/testing/images/arrow-big.png new file mode 100644 index 0000000000..dfd720ee39 Binary files /dev/null and b/data/testing/images/arrow-big.png differ diff --git a/data/testing/images/arrow.png b/data/testing/images/arrow.png new file mode 100644 index 0000000000..9acd3c1e40 Binary files /dev/null and b/data/testing/images/arrow.png differ diff --git a/data/test.png b/data/testing/images/test.png similarity index 100% rename from data/test.png rename to data/testing/images/test.png diff --git a/graphics/graphics_tests/screengl_test.cpp b/graphics/graphics_tests/screengl_test.cpp index 8c0debaf87..fd6cc2800b 100644 --- a/graphics/graphics_tests/screengl_test.cpp +++ b/graphics/graphics_tests/screengl_test.cpp @@ -1451,7 +1451,7 @@ namespace { void DoDraw(shared_ptr const & p) { - graphics::Image::Info ii("test.png"); + graphics::Image::Info ii("testing/images/test.png"); math::Matrix m = math::Shift( diff --git a/gui/gui_tests/gui_tests.cpp b/gui/gui_tests/gui_tests.cpp new file mode 100644 index 0000000000..6ddcfe3723 --- /dev/null +++ b/gui/gui_tests/gui_tests.cpp @@ -0,0 +1,128 @@ +#include "../../qt_tstfrm/gui_test_widget.hpp" + +#include "../balloon.hpp" +#include "../button.hpp" +#include "../text_view.hpp" +#include "../image_view.hpp" + +struct BalloonTest +{ + shared_ptr m_balloon; + + void Init(gui::Controller * c) + { + gui::Balloon::Params bp; + + bp.m_depth = graphics::maxDepth - 20; + bp.m_pivot = m2::PointD(200, 200); + bp.m_position = graphics::EPosAbove; + + bp.m_textMarginLeft = 10; + bp.m_textMarginRight = 10; + bp.m_textMarginTop = 5; + bp.m_textMarginBottom = 5; + + bp.m_imageMarginLeft = 0; + bp.m_imageMarginRight = 10; + bp.m_imageMarginTop = 5; + bp.m_imageMarginBottom = 5; + + bp.m_text = "Кирова, 24"; + bp.m_image = graphics::Image::Info("testing/images/arrow.png"); + + m_balloon.reset(new gui::Balloon(bp)); + m_balloon->setIsVisible(true); + + c->AddElement(m_balloon); + } + + void DoDraw(shared_ptr const & p) + {} +}; + +struct ButtonTest +{ + shared_ptr m_button; + + void Init(gui::Controller * c) + { + gui::Button::Params bp; + + bp.m_depth = graphics::maxDepth - 10; + bp.m_pivot = m2::PointD(200, 200); + bp.m_position = graphics::EPosAbove; + bp.m_text = "TestButton"; + + m_button.reset(new gui::Button(bp)); + + c->AddElement(m_button); + } + + void DoDraw(shared_ptr const & p) + { + } +}; + +struct TextViewTest +{ + shared_ptr m_textView; + + void Init(gui::Controller * c) + { + gui::TextView::Params tp; + + tp.m_pivot = m2::PointD(100, 100); + tp.m_depth = graphics::maxDepth; + tp.m_position = graphics::EPosRight; + tp.m_text = "Simplicity is the ultimate"; + + m_textView.reset(new gui::TextView(tp)); + m_textView->setIsVisible(true); + + c->AddElement(m_textView); + } + + void DoDraw(shared_ptr const & p) + { + } +}; + +struct ImageViewTest +{ + shared_ptr m_imageView; + m2::PointD m_pivot; + + void Init(gui::Controller * c) + { + gui::ImageView::Params ip; + + m_pivot = m2::PointD(100, 100); + + ip.m_depth = graphics::maxDepth; + ip.m_pivot = m_pivot; + ip.m_position = graphics::EPosUnder; + + ip.m_image = graphics::Image::Info("testing/images/arrow.png"); + + m_imageView.reset(new gui::ImageView(ip)); + + c->AddElement(m_imageView); + + m_imageView->setIsVisible(true); + } + + void DoDraw(shared_ptr const & p) + { + m2::RectD r(m_pivot, m_pivot); + + r.Inflate(2, 2); + + p->drawRectangle(r, graphics::Color(255, 0, 0, 255), graphics::maxDepth); + } +}; + +UNIT_TEST_GUI(BalloonTest); +UNIT_TEST_GUI(ButtonTest); +UNIT_TEST_GUI(TextViewTest); +UNIT_TEST_GUI(ImageViewTest); + diff --git a/gui/gui_tests/gui_tests.pro b/gui/gui_tests/gui_tests.pro new file mode 100644 index 0000000000..99c40c16eb --- /dev/null +++ b/gui/gui_tests/gui_tests.pro @@ -0,0 +1,22 @@ +TARGET = gui_tests +CONFIG += console +CONFIG -= app_bundle +TEMPLATE = app + +ROOT_DIR = ../.. +DEPENDENCIES = qt_tstfrm gui map indexer graphics platform geometry coding base expat freetype fribidi protobuf + +include($$ROOT_DIR/common.pri) + +QT *= opengl gui core + +win32 { + LIBS *= -lopengl32 -lshell32 + win32-g++: LIBS *= -lpthread +} +macx*: LIBS *= "-framework Foundation" + +SOURCES += \ + ../../testing/testingmain.cpp \ + gui_tests.cpp + diff --git a/omim.pro b/omim.pro index dd6d845728..abee2ec558 100644 --- a/omim.pro +++ b/omim.pro @@ -27,6 +27,7 @@ SUBDIRS = 3party \ qt_tstfrm \ indexer/indexer_tests \ graphics/graphics_tests \ + gui/gui_tests \ qt } else { # libraries which are used on mobile devices