summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp')
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 262dbea913..8e0bdac520 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -47,7 +47,11 @@
class tst_QTimer : public QObject
{
Q_OBJECT
+public:
+ static void initMain();
+
private slots:
+ void cleanupTestCase();
void zeroTimer();
void singleShotTimeout();
void timeout();
@@ -1138,22 +1142,27 @@ struct StaticSingleShotUser
}
};
+// NOTE: to prevent any static initialization order fiasco, we implement
+// initMain() to instantiate staticSingleShotUser before qApp
+
static StaticSingleShotUser *s_staticSingleShotUser = nullptr;
-void tst_QTimer::singleShot_static()
+void tst_QTimer::initMain()
{
- QCoreApplication::processEvents();
- QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls());
+ s_staticSingleShotUser = new StaticSingleShotUser;
}
-// NOTE: to prevent any static initialization order fiasco, we handle QTEST_MAIN
-// ourselves, but instantiate the staticSingleShotUser before qApp
+void tst_QTimer::cleanupTestCase()
+{
+ delete s_staticSingleShotUser;
+}
-int main(int argc, char *argv[])
+void tst_QTimer::singleShot_static()
{
- StaticSingleShotUser staticSingleShotUser;
- s_staticSingleShotUser = &staticSingleShotUser;
- QTEST_MAIN_IMPL(tst_QTimer)
+ QCoreApplication::processEvents();
+ QCOMPARE(s_staticSingleShotUser->helper.calls, s_staticSingleShotUser->calls());
}
+QTEST_MAIN(tst_QTimer)
+
#include "tst_qtimer.moc"