From: Laszlo Agocs Date: Mon, 12 Mar 2012 06:40:52 +0000 (+0200) Subject: Fix MouseArea autotest. X-Git-Tag: qt-v5.0.0-alpha1~182 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dda130fb2f01b3ed6f8833c3d6522b1a494d9641;p=profile%2Fivi%2Fqtdeclarative.git Fix MouseArea autotest. The hover test seems to be simply wrong. The double click tests worked before due to the obscure handling of double click but were somewhat incorrect in any case. Change-Id: Ie5690e26eb5921fe149e128d24d331f52a5a9075 Reviewed-by: Kent Hansen --- diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 0b4a6fa..82563b0 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -468,6 +468,8 @@ void tst_QQuickMouseArea::doubleClick() canvas->requestActivateWindow(); QVERIFY(canvas->rootObject() != 0); + // The sequence for a double click is: + // press, release, (click), press, double click, release QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(canvas, &pressEvent); @@ -476,9 +478,9 @@ void tst_QQuickMouseArea::doubleClick() QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); + QGuiApplication::sendEvent(canvas, &pressEvent); pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(canvas, &pressEvent); - QGuiApplication::sendEvent(canvas, &releaseEvent); QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); @@ -507,9 +509,8 @@ void tst_QQuickMouseArea::clickTwice() QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(canvas, &pressEvent); - + pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(canvas, &pressEvent); QGuiApplication::sendEvent(canvas, &releaseEvent); @@ -787,13 +788,17 @@ void tst_QQuickMouseArea::hoverVisible() QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered())); - QTest::mouseMove(canvas,QPoint(10,32)); + // Note: We need to use a position that is different from the position in the last event + // generated in the previous test case. Otherwise it is not interpreted as a move. + QTest::mouseMove(canvas,QPoint(11,33)); QCOMPARE(mouseTracker->hovered(), false); QCOMPARE(enteredSpy.count(), 0); mouseTracker->setVisible(true); + QTest::mouseMove(canvas,QPoint(10,31)); + QCOMPARE(mouseTracker->hovered(), true); QCOMPARE(enteredSpy.count(), 1);