From a292bcb1438034a24e95ec08be04a76ba832d793 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 1 May 2014 09:21:05 +0200 Subject: Update tst_qquickapplication to support OS X ApplicationState handling This patch modifies tst_qquickapplication so that it tests correctly against OS X's new ApplicationState handling Task-number: QTBUG-10899 Change-Id: Iea20b0137daabe03fdddf98435dc2626e122741f Reviewed-by: J-P Nurmi --- .../quick/qquickapplication/tst_qquickapplication.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/auto/quick/qquickapplication') diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index dfcef43a7e..0993d03ee4 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -60,6 +60,7 @@ private slots: void state(); void layoutDirection(); void inputMethod(); + void cleanup(); private: QQmlEngine engine; @@ -69,6 +70,14 @@ tst_qquickapplication::tst_qquickapplication() { } +void tst_qquickapplication::cleanup() +{ + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); + QTest::waitForEvents(); + } +} + void tst_qquickapplication::active() { QQmlComponent component(&engine); @@ -98,12 +107,19 @@ void tst_qquickapplication::active() QVERIFY(item->property("active").toBool()); QVERIFY(item->property("active2").toBool()); - // not active again QWindowSystemInterface::handleWindowActivated(0); +#ifdef Q_OS_OSX + // OS X has the concept of "reactivation" + QTRY_VERIFY(QGuiApplication::focusWindow() != &window); + QVERIFY(item->property("active").toBool()); + QVERIFY(item->property("active2").toBool()); +#else + // not active again QTRY_VERIFY(QGuiApplication::focusWindow() != &window); QVERIFY(!item->property("active").toBool()); QVERIFY(!item->property("active2").toBool()); +#endif } void tst_qquickapplication::state() @@ -117,6 +133,7 @@ void tst_qquickapplication::state() " target: Qt.application; " " onStateChanged: state2 = Qt.application.state; " " } " + " Component.onCompleted: state2 = Qt.application.state; " "}", QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast(component.create()); QVERIFY(item); -- cgit v1.2.3