tst_ma::pressedCanceledOnWindowDeactivate: don't pop up second window

I guess I must have thought it would be more realistic that way;
but sending an explicit WindowDeactivate as we had it in early Qt 5
seems to keep the test passing now, and is probably more reliable.
The original purpose of the test seems to be to verify the recursive
delivery to all items via virtual QQuickItem::windowDeactivateEvent(),
which MouseArea (and no other item!) overrides to ungrab the mouse.

This mostly reverts commit 1c451b40ae.

Change-Id: I0c6f953514095a491120a0aac9944dc8b04ca17d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Shawn Rutledge 2020-11-18 23:11:37 +01:00
parent c16132c066
commit 423a9124e7
2 changed files with 2 additions and 13 deletions

View File

@ -1,5 +1,4 @@
import QtQuick 2.0
import QtQuick.Window 2.0
Rectangle {
id: root
@ -10,12 +9,6 @@ Rectangle {
property int clicked: 0
property int doubleClicked: 0
property int released: 0
property alias secondWindow: secondWindow
Window {
id: secondWindow
x: root.x + root.width
}
MouseArea {
id: mouse

View File

@ -937,7 +937,6 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
QCOMPARE(window.rootObject()->property("released").toInt(), expectedRelease);
QCOMPARE(window.rootObject()->property("clicked").toInt(), expectedClicks);
QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, {});
QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, {});
@ -966,11 +965,8 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
QCOMPARE(window.rootObject()->property("doubleClicked").toInt(), 1);
}
QWindow *secondWindow = qvariant_cast<QWindow*>(window.rootObject()->property("secondWindow"));
secondWindow->setProperty("visible", true);
QVERIFY(QTest::qWaitForWindowExposed(secondWindow));
QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
QGuiApplication::sendEvent(&window, &windowDeactivateEvent);
QTRY_VERIFY(!window.rootObject()->property("pressed").toBool());
QVERIFY(window.rootObject()->property("canceled").toBool());
QCOMPARE(window.rootObject()->property("released").toInt(), expectedRelease);