pressedCanceledOnWindowDeactivate pops up a second window
authorShawn Rutledge <shawn.rutledge@digia.com>
Mon, 4 Mar 2013 11:52:11 +0000 (12:52 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 4 Mar 2013 18:47:38 +0000 (19:47 +0100)
in order to cause the first one to be deactivated.

Task-number: QTBUG-29953
Change-Id: I7fec66b07976b2afc78941d39c593f99ea484522
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>

tests/auto/quick/qquickmousearea/data/pressedCanceled.qml
tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp

index 231436d..14630b8 100644 (file)
@@ -1,4 +1,5 @@
 import QtQuick 2.0
+import QtQuick.Window 2.0
 
 Rectangle {
     id: root
@@ -7,6 +8,12 @@ Rectangle {
     property bool pressed:mouse.pressed
     property bool canceled: false
     property bool released: false
+    property alias secondWindow: secondWindow
+
+    Window {
+        id: secondWindow
+        x: root.x + root.width
+    }
 
     MouseArea {
         id: mouse
@@ -15,4 +22,4 @@ Rectangle {
         onCanceled: {root.canceled = true}
         onReleased: {root.released = true; root.canceled = false}
     }
-}
\ No newline at end of file
+}
index 327abbe..6ee79b0 100644 (file)
@@ -583,16 +583,14 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
     QVERIFY(!window->rootObject()->property("canceled").toBool());
     QVERIFY(!window->rootObject()->property("released").toBool());
 
-    QTest::qWait(200);
+    QWindow *secondWindow = qvariant_cast<QWindow*>(window->rootObject()->property("secondWindow"));
+    secondWindow->setProperty("visible", true);
+    QTest::qWaitForWindowActive(secondWindow);
 
-    QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
-    QGuiApplication::sendEvent(window, &windowDeactivateEvent);
     QVERIFY(!window->rootObject()->property("pressed").toBool());
     QVERIFY(window->rootObject()->property("canceled").toBool());
     QVERIFY(!window->rootObject()->property("released").toBool());
 
-    QTest::qWait(200);
-
     //press again
     QGuiApplication::sendEvent(window, &pressEvent);
     QVERIFY(window->rootObject()->property("pressed").toBool());