summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index cd00f4cc9c..92ab429d4a 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
@@ -369,6 +369,42 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( childFocusWidgetOne->focusInEventRecieved );
QCOMPARE( childFocusWidgetOne->focusInEventReason, (int)Qt::ActiveWindowFocusReason);
+
+ const bool windowActivationReasonFail =
+ QGuiApplication::platformName().toLower() == "minimal";
+
+ struct Window : public QWindow
+ {
+ Qt::FocusReason lastReason = Qt::NoFocusReason;
+ protected:
+ void focusInEvent(QFocusEvent *event) override
+ {
+ lastReason = event->reason();
+ }
+ void focusOutEvent(QFocusEvent *event) override
+ {
+ lastReason = event->reason();
+ }
+ };
+
+ Window window;
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ if (windowActivationReasonFail)
+ QEXPECT_FAIL("", "Platform doesn't set window activation reason for QWindow", Continue);
+ QCOMPARE(window.lastReason, Qt::ActiveWindowFocusReason);
+ window.lastReason = Qt::NoFocusReason;
+
+ Window window2;
+ window2.show();
+ window2.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window2));
+
+ if (windowActivationReasonFail)
+ QEXPECT_FAIL("", "Platform doesn't set window activation reason for QWindow", Continue);
+ QCOMPARE(window.lastReason, Qt::ActiveWindowFocusReason);
}