Skip to content

Commit

Permalink
Fix MouseArea autotest.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laszlo Agocs authored and Qt by Nokia committed Mar 12, 2012
1 parent 6cf36b2 commit dda130f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit dda130f

Please sign in to comment.