File: ShutdownOnQApplicationQuitTests.cpp

package info (click to toggle)
kf6-threadweaver 6.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,324 kB
  • sloc: cpp: 7,554; python: 33; sh: 13; makefile: 5
file content (47 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* -*- C++ -*-
    This file contains a testsuite for global queue instantiation in ThreadWeaver.

    SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include <QString>
#include <QTest>

#include <ThreadWeaver/ThreadWeaver>

// The tests checks if the global ThreadWeaver instance is properly
// destroyed along with QCoreApplication. After that all the puppies
// are sad and the kittens cry, and the test exits.
class ShutdownOnQApplicationQuitTests : public QObject
{
    Q_OBJECT

public:
    ShutdownOnQApplicationQuitTests();

private Q_SLOTS:
    void testShutdownOnQApplicationQuit();
};

ShutdownOnQApplicationQuitTests::ShutdownOnQApplicationQuitTests()
{
}

void ShutdownOnQApplicationQuitTests::testShutdownOnQApplicationQuit()
{
    {
        int argc = 0;
        QCoreApplication app(argc, (char **)nullptr);
        QVERIFY(ThreadWeaver::Queue::instance() != nullptr);
        ThreadWeaver::Queue::instance()->suspend();
        ThreadWeaver::Queue::instance()->resume();
        QTest::qWait(10);
    }
    QCOMPARE(ThreadWeaver::Queue::instance(), nullptr);
}

QTEST_APPLESS_MAIN(ShutdownOnQApplicationQuitTests)

#include "ShutdownOnQApplicationQuitTests.moc"