diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp | 27 | ||||
-rw-r--r-- | tests/auto/opengl/qgl/tst_qgl.cpp | 7 | ||||
-rw-r--r-- | tests/auto/testlib/initmain/initmain.pro | 5 | ||||
-rw-r--r-- | tests/auto/testlib/initmain/tst_initmain.cpp | 56 | ||||
-rw-r--r-- | tests/auto/testlib/testlib.pro | 1 |
5 files changed, 87 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" diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 053c4b026b..3cc9592fb1 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -60,6 +60,8 @@ public: tst_QGL(); virtual ~tst_QGL(); + static void initMain(); + private slots: void initTestCase(); void getSetCheck(); @@ -101,6 +103,11 @@ tst_QGL::~tst_QGL() { } +void tst_QGL::initMain() +{ + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); +} + void tst_QGL::initTestCase() { QGLWidget glWidget; diff --git a/tests/auto/testlib/initmain/initmain.pro b/tests/auto/testlib/initmain/initmain.pro new file mode 100644 index 0000000000..4c12aba08d --- /dev/null +++ b/tests/auto/testlib/initmain/initmain.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +SOURCES += tst_initmain.cpp +QT = core testlib + +TARGET = tst_initmain diff --git a/tests/auto/testlib/initmain/tst_initmain.cpp b/tests/auto/testlib/initmain/tst_initmain.cpp new file mode 100644 index 0000000000..f08f82c5ec --- /dev/null +++ b/tests/auto/testlib/initmain/tst_initmain.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtCore/QCoreApplication> +#include <QtTest/QtTest> + +class tst_InitMain : public QObject +{ + Q_OBJECT + +public: + static void initMain() { m_initMainCalled = true; } + +private slots: + void testcase(); + +private: + static bool m_initMainCalled; +}; + +bool tst_InitMain::m_initMainCalled = false; + +void tst_InitMain::testcase() +{ + QVERIFY(m_initMainCalled); +} + +QTEST_MAIN(tst_InitMain) + +#include "tst_initmain.moc" diff --git a/tests/auto/testlib/testlib.pro b/tests/auto/testlib/testlib.pro index 587c76a189..55f1f9b87b 100644 --- a/tests/auto/testlib/testlib.pro +++ b/tests/auto/testlib/testlib.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS = \ + initmain \ outformat \ qsignalspy \ selftests \ |