File indexing completed on 2024-04-28 15:34:48
0001 /* -*- C++ -*- 0002 This file contains a testsuite for global queue instantiation in ThreadWeaver. 0003 0004 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include <QString> 0010 #include <QTest> 0011 0012 #include <ThreadWeaver/ThreadWeaver> 0013 0014 // The tests checks if the global ThreadWeaver instance is properly 0015 // destroyed along with QCoreApplication. After that all the puppies 0016 // are sad and the kittens cry, and the test exits. 0017 class ShutdownOnQApplicationQuitTests : public QObject 0018 { 0019 Q_OBJECT 0020 0021 public: 0022 ShutdownOnQApplicationQuitTests(); 0023 0024 private Q_SLOTS: 0025 void testShutdownOnQApplicationQuit(); 0026 }; 0027 0028 ShutdownOnQApplicationQuitTests::ShutdownOnQApplicationQuitTests() 0029 { 0030 } 0031 0032 void ShutdownOnQApplicationQuitTests::testShutdownOnQApplicationQuit() 0033 { 0034 { 0035 int argc = 0; 0036 QCoreApplication app(argc, (char **)nullptr); 0037 QVERIFY(ThreadWeaver::Queue::instance() != nullptr); 0038 ThreadWeaver::Queue::instance()->suspend(); 0039 ThreadWeaver::Queue::instance()->resume(); 0040 QTest::qWait(10); 0041 } 0042 QVERIFY(ThreadWeaver::Queue::instance() == nullptr); 0043 } 0044 0045 QTEST_APPLESS_MAIN(ShutdownOnQApplicationQuitTests) 0046 0047 #include "ShutdownOnQApplicationQuitTests.moc"