diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-03-12 08:40:52 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-12 17:04:32 +0100 |
commit | dda130fb2f01b3ed6f8833c3d6522b1a494d9641 (patch) | |
tree | b945cc16c0b1b9203592168a131298151f53a336 | |
parent | 6cf36b2497f0fdcfced155cd85e403b64bfa269e (diff) |
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 <kent.hansen@nokia.com>
-rw-r--r-- | tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 0b4a6fa438..82563b07f9 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); |