aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@theqtcompany.com>2015-04-08 14:10:28 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-04-08 13:26:59 +0000
commit47f6d256edf76a8a201057236226b507bcc1aa89 (patch)
treef93ea8e0155a13c11a791809fa61b23dd170148a /tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
parent7f0e3887c79353e4612efc5f8bab861683678e24 (diff)
tst_qquickapplication: change test case 'state' to be more stable
Qt-5.4 integration can sometimes fail on this test. We have not succeeded reproducing it, but from reading the test code, it seems likely that the problem might come from already pending state events queued before the test starts. Since the test cannot know if the platform will queue state events while spinning the event loop (waitForEvents), this patch will instead only flush already queued events, which should be less prone to side effects. Change-Id: I134f98ba35faa4d9213ee658ebcbe76b390b5516 Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick/qquickapplication/tst_qquickapplication.cpp')
-rw-r--r--tests/auto/quick/qquickapplication/tst_qquickapplication.cpp15
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 f803a63fd7..cc6fac5b39 100644
--- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
+++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
@@ -132,31 +132,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);