tst_qquickapplication: Don't assume app activation is tied to window activation
Follows same approach as 47f6d256ed
in tst_qquickapplication::state().
Change-Id: Ibecdab3f874fc9e75b38ba2ccaf3776bd46c77e8
Fixes: QTBUG-72953
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
cfdb483613
commit
4aa7fe666b
|
@ -88,11 +88,24 @@ void tst_qquickapplication::active()
|
||||||
QQuickWindow window;
|
QQuickWindow window;
|
||||||
item->setParentItem(window.contentItem());
|
item->setParentItem(window.contentItem());
|
||||||
|
|
||||||
// not active
|
// If the platform plugin has the ApplicationState capability, app activation 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);
|
||||||
|
QWindowSystemInterface::flushWindowSystemEvents();
|
||||||
|
QVERIFY(item->property("active").toBool());
|
||||||
|
QVERIFY(item->property("active2").toBool());
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
|
||||||
|
QWindowSystemInterface::flushWindowSystemEvents();
|
||||||
QVERIFY(!item->property("active").toBool());
|
QVERIFY(!item->property("active").toBool());
|
||||||
QVERIFY(!item->property("active2").toBool());
|
QVERIFY(!item->property("active2").toBool());
|
||||||
|
} else {
|
||||||
// active
|
// Otherwise, app activation is triggered by window activation.
|
||||||
window.show();
|
window.show();
|
||||||
window.requestActivate();
|
window.requestActivate();
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&window));
|
QVERIFY(QTest::qWaitForWindowActive(&window));
|
||||||
|
@ -100,19 +113,12 @@ void tst_qquickapplication::active()
|
||||||
QVERIFY(item->property("active").toBool());
|
QVERIFY(item->property("active").toBool());
|
||||||
QVERIFY(item->property("active2").toBool());
|
QVERIFY(item->property("active2").toBool());
|
||||||
|
|
||||||
QWindowSystemInterface::handleWindowActivated(nullptr);
|
|
||||||
|
|
||||||
#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
|
// not active again
|
||||||
|
QWindowSystemInterface::handleWindowActivated(nullptr);
|
||||||
QTRY_VERIFY(QGuiApplication::focusWindow() != &window);
|
QTRY_VERIFY(QGuiApplication::focusWindow() != &window);
|
||||||
QVERIFY(!item->property("active").toBool());
|
QVERIFY(!item->property("active").toBool());
|
||||||
QVERIFY(!item->property("active2").toBool());
|
QVERIFY(!item->property("active2").toBool());
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qquickapplication::state()
|
void tst_qquickapplication::state()
|
||||||
|
|
Loading…
Reference in New Issue