From c37acaa46c976cbf20c59b8f7cea2c9e9baf5098 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 16 Dec 2014 12:41:22 +0300 Subject: [PATCH] drape_test linkage fix --- drape/drape_tests/font_texture_tests.cpp | 3 +- drape/drape_tests/glyph_mng_tests.cpp | 3 +- omim.pro | 2 +- qt_tstfrm/test_main_loop.cpp | 45 ++++++++++++++---------- qt_tstfrm/test_main_loop.hpp | 22 ++---------- 5 files changed, 31 insertions(+), 44 deletions(-) diff --git a/drape/drape_tests/font_texture_tests.cpp b/drape/drape_tests/font_texture_tests.cpp index 61012a045d..4454b06447 100644 --- a/drape/drape_tests/font_texture_tests.cpp +++ b/drape/drape_tests/font_texture_tests.cpp @@ -102,6 +102,5 @@ UNIT_TEST(UploadingGlyphs) .WillOnce(Invoke(&r, &UploadedRender::glMemoryToQImage)); index.UploadResources(MakeStackRefPointer(&tex)); - TestMainLoop loop(bind(&UploadedRender::Render, &r, _1)); - loop.exec("UploadingGlyphs"); + RunTestLoop("UploadingGlyphs", bind(&UploadedRender::Render, &r, _1)); } diff --git a/drape/drape_tests/glyph_mng_tests.cpp b/drape/drape_tests/glyph_mng_tests.cpp index 9c06159d37..10b8278760 100644 --- a/drape/drape_tests/glyph_mng_tests.cpp +++ b/drape/drape_tests/glyph_mng_tests.cpp @@ -71,6 +71,5 @@ namespace UNIT_TEST(GlyphLoadingTest) { GlyphRenderer renderer; - TestMainLoop loop(bind(&GlyphRenderer::RenderGlyphs, &renderer, _1)); - loop.exec("GlyphLoadingTest"); + RunTestLoop("GlyphLoadingTest", bind(&GlyphRenderer::RenderGlyphs, &renderer, _1)); } diff --git a/omim.pro b/omim.pro index dc6256fff2..ac6b77a6ce 100644 --- a/omim.pro +++ b/omim.pro @@ -27,6 +27,7 @@ SUBDIRS = 3party \ geometry/geometry_tests \ platform/platform_tests \ anim \ + qt_tstfrm \ drape \ drape/drape_tests \ graphics \ @@ -37,7 +38,6 @@ SUBDIRS = 3party \ map map/map_tests map/benchmark_tool map/mwm_tests\ generator generator/generator_tests \ generator/generator_tool \ - qt_tstfrm \ indexer/indexer_tests \ graphics/graphics_tests \ gui/gui_tests \ diff --git a/qt_tstfrm/test_main_loop.cpp b/qt_tstfrm/test_main_loop.cpp index 1e71a14041..d5db995773 100644 --- a/qt_tstfrm/test_main_loop.cpp +++ b/qt_tstfrm/test_main_loop.cpp @@ -8,12 +8,30 @@ #include "../std/cstring.hpp" -TestMainLoop::TestMainLoop(TestMainLoop::TRednerFn const & fn) - : m_renderFn(fn) +namespace { -} -void TestMainLoop::exec(char const * testName, bool autoExit) +class MyWidget : public QWidget +{ +public: + MyWidget(TRednerFn const & fn) + : m_fn(fn) + { + } + +protected: + void paintEvent(QPaintEvent * e) + { + m_fn(this); + } + +private: + TRednerFn m_fn; +}; + +} // namespace + +void RunTestLoop(char const * testName, TRednerFn const & fn, bool autoExit) { char * buf = (char *)malloc(strlen(testName) + 1); MY_SCOPE_GUARD(argvFreeFun, [&buf](){ free(buf); }); @@ -24,21 +42,10 @@ void TestMainLoop::exec(char const * testName, bool autoExit) if (autoExit) QTimer::singleShot(3000, &app, SLOT(quit())); - QWidget w; - w.setWindowTitle(testName); - w.show(); - w.installEventFilter(this); + MyWidget * widget = new MyWidget(fn); + widget->setWindowTitle(testName); + widget->show(); app.exec(); -} - -bool TestMainLoop::eventFilter(QObject * obj, QEvent * event) -{ - if (event->type() == QEvent::Paint) - { - m_renderFn(qobject_cast(obj)); - return true; - } - - return false; + delete widget; } diff --git a/qt_tstfrm/test_main_loop.hpp b/qt_tstfrm/test_main_loop.hpp index ea879afee6..4faa8ec708 100644 --- a/qt_tstfrm/test_main_loop.hpp +++ b/qt_tstfrm/test_main_loop.hpp @@ -1,25 +1,7 @@ #pragma once -#include - #include "../std/function.hpp" class QPaintDevice; -class TestMainLoop : public QObject -{ - Q_OBJECT - -public: - - typedef function TRednerFn; - TestMainLoop(TRednerFn const & fn); - virtual ~TestMainLoop() {} - - void exec(char const * testName, bool autoExit = true); - -protected: - bool eventFilter(QObject * obj, QEvent * event); - -private: - TRednerFn m_renderFn; -}; +typedef function TRednerFn; +void RunTestLoop(char const * testName, TRednerFn const & fn, bool autoExit = false);