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>
This commit is contained in:
Laszlo Agocs 2012-03-12 08:40:52 +02:00 committed by Qt by Nokia
parent 6cf36b2497
commit dda130fb2f
1 changed files with 9 additions and 4 deletions

View File

@ -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);