diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-11 14:17:35 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-12 01:10:13 +0000 |
commit | a890596770f928303b75cac8c8503afd61f85e26 (patch) | |
tree | c593a07f6dc3ab47868dc4023c527cb5023e17ec /tests | |
parent | f17d8982d7ca774a45b37f78a3d4cc3ce1042217 (diff) |
Deliver WindowActivate/Deactivate events to QWindow
We need those events to trigger palette color group changes in QQuickItem
without having to connect every item to yet another QWindow signal.
Task-number: QTBUG-93752
Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit b65159a5ea8db05165b2eaab8e180a12f30063e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index d4644c05ac..10e0d450b9 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -109,6 +109,7 @@ private slots: void testBlockingWindowShownAfterModalDialog(); void generatedMouseMove(); void keepPendingUpdateRequests(); + void activateDeactivateEvent(); private: QPoint m_availableTopLeft; @@ -2604,6 +2605,48 @@ void tst_QWindow::keepPendingUpdateRequests() QTRY_VERIFY(!platformWindow->hasPendingUpdateRequest()); } +void tst_QWindow::activateDeactivateEvent() +{ + class Window : public QWindow + { + public: + using QWindow::QWindow; + + int activateCount = 0; + int deactivateCount = 0; + protected: + bool event(QEvent *e) + { + switch (e->type()) { + case QEvent::WindowActivate: + ++activateCount; + break; + case QEvent::WindowDeactivate: + ++deactivateCount; + break; + default: + break; + } + return QWindow::event(e); + } + }; + + Window w1; + Window w2; + + w1.show(); + w1.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&w1)); + QCOMPARE(w1.activateCount, 1); + QCOMPARE(w1.deactivateCount, 0); + + w2.show(); + w2.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&w2)); + QCOMPARE(w1.deactivateCount, 1); + QCOMPARE(w2.activateCount, 1); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) |