summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-10-30 10:21:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-30 12:53:46 +0100
commita48508cd766b056d3cb5b6502cf269a8293bb5a5 (patch)
tree1e9d0fcd89c7a0f07cfe00379f10d3ede4852596 /tests/auto
parent50ec06da2c8a1c680d48b84f8c1267fe78a86b6a (diff)
Send leave to most recently entered window when modal dialog is shown.
If a modal dialog was shown as a response to button click, the button retained its hover highlight, because it didn't get leave event. Fixed by tracking the most recently entered window and sending a leave to it when modal dialog is shown that blocks it. Also modified tst_QGuiApplication::modalWindow() autotest to check for enters and leaves. Task-number: QTBUG-27644 Change-Id: I387647e18a762a39d523e3df31221b9583a39f9d Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp69
1 files changed, 65 insertions, 4 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index cc291f72fa..a7c38d6664 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -336,12 +336,11 @@ class BlockableWindow : public QWindow
Q_OBJECT
public:
int blocked;
+ int leaves;
+ int enters;
inline BlockableWindow()
- : QWindow()
- {
- blocked = false;
- }
+ : QWindow(), blocked(false), enters(0), leaves(0) {}
bool event(QEvent *e)
{
@@ -352,11 +351,23 @@ public:
case QEvent::WindowUnblocked:
--blocked;
break;
+ case QEvent::Leave:
+ leaves++;
+ break;
+ case QEvent::Enter:
+ enters++;
+ break;
default:
break;
}
return QWindow::event(e);
}
+
+ void resetCounts()
+ {
+ leaves = 0;
+ enters = 0;
+ }
};
void tst_QGuiApplication::modalWindow()
@@ -391,6 +402,12 @@ void tst_QGuiApplication::modalWindow()
QCOMPARE(windowModalWindow2->blocked, 0);
QCOMPARE(applicationModalWindow1->blocked, 0);
+ // enter mouse in window1
+ QWindowSystemInterface::handleEnterEvent(window1);
+ QGuiApplication::processEvents();
+ QCOMPARE(window1->enters, 1);
+ QCOMPARE(window1->leaves, 0);
+
// show applicationModalWindow1, everything is blocked
applicationModalWindow1->show();
QCOMPARE(app.modalWindow(), applicationModalWindow1);
@@ -400,6 +417,24 @@ void tst_QGuiApplication::modalWindow()
QCOMPARE(windowModalWindow2->blocked, 1);
QCOMPARE(applicationModalWindow1->blocked, 0);
+ // opening modal causes leave for previously entered window, but not others
+ QGuiApplication::processEvents();
+ QCOMPARE(window1->enters, 1);
+ QCOMPARE(window1->leaves, 1);
+ QCOMPARE(window2->enters, 0);
+ QCOMPARE(window2->leaves, 0);
+ QCOMPARE(applicationModalWindow1->enters, 0);
+ QCOMPARE(applicationModalWindow1->leaves, 0);
+ window1->resetCounts();
+
+ // Try entering/leaving blocked window2 - no events should reach it
+ QWindowSystemInterface::handleEnterEvent(window2);
+ QGuiApplication::processEvents();
+ QWindowSystemInterface::handleLeaveEvent(window2);
+ QGuiApplication::processEvents();
+ QCOMPARE(window2->enters, 0);
+ QCOMPARE(window2->leaves, 0);
+
// everything is unblocked when applicationModalWindow1 is hidden
applicationModalWindow1->hide();
QCOMPARE(app.modalWindow(), static_cast<QWindow *>(0));
@@ -409,6 +444,12 @@ void tst_QGuiApplication::modalWindow()
QCOMPARE(windowModalWindow2->blocked, 0);
QCOMPARE(applicationModalWindow1->blocked, 0);
+ // Enter window2 - should not be blocked
+ QWindowSystemInterface::handleEnterEvent(window2);
+ QGuiApplication::processEvents();
+ QCOMPARE(window2->enters, 1);
+ QCOMPARE(window2->leaves, 0);
+
// show the windowModalWindow1, only window1 is blocked
windowModalWindow1->show();
QCOMPARE(app.modalWindow(), windowModalWindow1);
@@ -418,6 +459,15 @@ void tst_QGuiApplication::modalWindow()
QCOMPARE(windowModalWindow2->blocked, 0);
QCOMPARE(applicationModalWindow1->blocked, 0);
+ // opening window modal window doesn't cause leave for unblocked window
+ QGuiApplication::processEvents();
+ QCOMPARE(window1->enters, 0);
+ QCOMPARE(window1->leaves, 0);
+ QCOMPARE(window2->enters, 1);
+ QCOMPARE(window2->leaves, 0);
+ QCOMPARE(windowModalWindow1->enters, 0);
+ QCOMPARE(windowModalWindow1->leaves, 0);
+
// show the windowModalWindow2, windowModalWindow1 is blocked as well
windowModalWindow2->show();
QCOMPARE(app.modalWindow(), windowModalWindow2);
@@ -472,6 +522,17 @@ void tst_QGuiApplication::modalWindow()
QCOMPARE(windowModalWindow2->blocked, 1);
QCOMPARE(applicationModalWindow1->blocked, 0);
+ // window2 gets finally the leave
+ QGuiApplication::processEvents();
+ QCOMPARE(window1->enters, 0);
+ QCOMPARE(window1->leaves, 0);
+ QCOMPARE(window2->enters, 1);
+ QCOMPARE(window2->leaves, 1);
+ QCOMPARE(windowModalWindow1->enters, 0);
+ QCOMPARE(windowModalWindow1->leaves, 0);
+ QCOMPARE(applicationModalWindow1->enters, 0);
+ QCOMPARE(applicationModalWindow1->leaves, 0);
+
// hide applicationModalWindow1, windowModalWindow1 and window1 are blocked
applicationModalWindow1->hide();
QCOMPARE(app.modalWindow(), windowModalWindow2);