Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorExMix <rahuba.youri@mapswithme.com>2014-12-16 12:41:22 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:34:57 +0300
commitc37acaa46c976cbf20c59b8f7cea2c9e9baf5098 (patch)
tree0fd178af0fdddc024431192fb3d59725deadb999 /qt_tstfrm
parentfd6415e4f0b9ec5cbbfacc3f8b56b5260aa7c35a (diff)
drape_test linkage fix
Diffstat (limited to 'qt_tstfrm')
-rw-r--r--qt_tstfrm/test_main_loop.cpp45
-rw-r--r--qt_tstfrm/test_main_loop.hpp22
2 files changed, 28 insertions, 39 deletions
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<QWidget *>(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 <QtCore/QObject>
-
#include "../std/function.hpp"
class QPaintDevice;
-class TestMainLoop : public QObject
-{
- Q_OBJECT
-
-public:
-
- typedef function<void (QPaintDevice *)> 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<void (QPaintDevice *)> TRednerFn;
+void RunTestLoop(char const * testName, TRednerFn const & fn, bool autoExit = false);