diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-11 14:17:35 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-11 23:30:09 +0200 |
commit | b65159a5ea8db05165b2eaab8e180a12f30063e4 (patch) | |
tree | a27f4349d3fcfdfd1e85d9b895acca26626f36f2 /tests/auto/gui | |
parent | 421c69fde579baf21cb0fd607a7cfd97e6e63220 (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
Pick-to: 6.2
Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui')
-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) |