diff options
author | Michal Policht <michpolicht@gmail.com> | 2019-02-06 14:58:59 +0100 |
---|---|---|
committer | Michal Policht <michpolicht@gmail.com> | 2019-02-13 16:46:19 +0000 |
commit | 1e3ed172f35abaa0e0af43ee22259bc3cd188ad8 (patch) | |
tree | ac538d38b83874cb0647a263bae1f0e99b88fefc /tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp | |
parent | 01f9c623ed2dc1645ac022d69062f720e3b50132 (diff) |
Connect quit() and exit() signals with queued connections
Class QQmlApplicationEngine connects QQmlApplicationEngine::quit()
signal to QCoreApplication::quit() and QQmlApplicationEngine::exit()
signal to QCoreApplication::exit(), but it does so with AutoConnection.
This causes in some circumstances problems, which are described in Qt
documentation (see QCoreApplication::exit()). This change modifies type
of connections to queued connections.
[ChangeLog][QtQml][QQmlApplicationEngine] QQmlApplicationEngine
connects quit() and exit() signals with queued connections to avoid
problems with AutoConnection, when connecting to QCoreApplication
slots.
Task-number: QTBUG-73649
Change-Id: Ib27738b5af2f879efee8862b1ca01613a2e8dc4e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp')
-rw-r--r-- | tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index daeb9b5455..ce654dc45e 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -46,6 +46,7 @@ private slots: void initTestCase(); void basicLoading(); void testNonResolvedPath(); + void application_data(); void application(); void applicationProperties(); void removeObjectsWhenDestroyed(); @@ -111,35 +112,56 @@ void tst_qqmlapplicationengine::testNonResolvedPath() } } +void tst_qqmlapplicationengine::application_data() +{ + QTest::addColumn<QByteArray>("qmlFile"); + QTest::addColumn<QByteArray>("expectedStdErr"); + + QTest::newRow("delayed quit") << QByteArray("delayedQuit.qml") + << QByteArray("qml: Start: delayedQuit.qml\nqml: End\n"); + QTest::newRow("delayed exit") << QByteArray("delayedExit.qml") + << QByteArray("qml: Start: delayedExit.qml\nqml: End\n"); + QTest::newRow("immediate quit") << QByteArray("immediateQuit.qml") + << QByteArray("qml: End: immediateQuit.qml\n"); + QTest::newRow("immediate exit") << QByteArray("immediateExit.qml") + << QByteArray("qml: End: immediateExit.qml\n"); +} + void tst_qqmlapplicationengine::application() { /* This test batches together some tests about running an external application written with QQmlApplicationEngine. The application tests the following functionality which is easier to do by watching a separate process: - -Loads relative paths from the working directory - -quits when quit is called - -emits aboutToQuit after quit is called - -has access to application command line arguments + - Loads relative paths from the working directory + - Quits when quit is called + - Exits when exit is called + - Emits aboutToQuit after quit is called + - Has access to application command line arguments Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ + + QFETCH(QByteArray, qmlFile); + QFETCH(QByteArray, expectedStdErr); + #if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; - args << QLatin1String("testData"); + args << qmlFile; // QML file passed as an argument is going to be run by testapp. testProcess->start(QLatin1String("testapp/testapp"), args); QVERIFY(testProcess->waitForFinished(5000)); QCOMPARE(testProcess->exitCode(), 0); - QByteArray test_stdout = testProcess->readAllStandardOutput(); - QByteArray test_stderr = testProcess->readAllStandardError(); - QByteArray test_stderr_target("qml: Start: testData\nqml: End\n"); + QByteArray testStdOut = testProcess->readAllStandardOutput(); + QByteArray testStdErr = testProcess->readAllStandardError(); #ifdef Q_OS_WIN - test_stderr_target.replace('\n', QByteArray("\r\n")); + expectedStdErr.replace('\n', QByteArray("\r\n")); #endif - QCOMPARE(test_stdout, QByteArray("")); - QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); + QCOMPARE(testStdOut, QByteArray("")); + QVERIFY2(QString(testStdErr).endsWith(QString(expectedStdErr)), + QByteArray("\nExpected ending:\n") + expectedStdErr + + QByteArray("\nActual output:\n") + testStdErr); delete testProcess; QDir::setCurrent(srcDir); #else // process |