diff options
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquickapplication/tst_qquickapplication.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index e78427df3b..7df020405f 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -134,31 +134,30 @@ void tst_qquickapplication::state() QQuickWindow window; item->setParentItem(window.contentItem()); - // initial state should be ApplicationInactive - QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationInactive); - QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationInactive); - // If the platform plugin has the ApplicationState capability, state changes originate from it // as a result of a system event. We therefore have to simulate these events here. if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { + // Flush pending events, in case the platform have already queued real application state events + QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); - QTest::waitForEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationActive); QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationActive); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); - QTest::waitForEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationInactive); QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationInactive); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended); - QTest::waitForEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationSuspended); QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationSuspended); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationHidden); - QTest::waitForEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); QCOMPARE(Qt::ApplicationState(item->property("state").toInt()), Qt::ApplicationHidden); QCOMPARE(Qt::ApplicationState(item->property("state2").toInt()), Qt::ApplicationHidden); |