Skip to content

Commit

Permalink
Fix tst_qquicktextedit.
Browse files Browse the repository at this point in the history
Recent changes to mouse double-click handling mean that two
calls to QTest::mouseClick with the same position will result in a
double click, which was causing this test to fail.

Change-Id: I21e6aa7ab2221b6ea82b1afd13e36b7ba0aef8dc
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
  • Loading branch information
Michael Brasser authored and Qt by Nokia committed Mar 12, 2012
1 parent cb1ff7a commit 6cf36b2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
Expand Up @@ -1855,6 +1855,7 @@ void tst_qquicktextedit::cursorDelegate()
textEditObject->setSelectByMouse(true);
textEditObject->setCursorPosition(0);
const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
QTest::qWait(400); //ensure this isn't treated as a double-click
QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
Expand All @@ -1864,6 +1865,7 @@ void tst_qquicktextedit::cursorDelegate()
// Test delegate gets moved on mouse drag
textEditObject->setCursorPosition(0);
const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint();
QTest::qWait(400); //ensure this isn't treated as a double-click
QTest::mousePress(&view, Qt::LeftButton, 0, point1);
QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
QGuiApplication::sendEvent(&view, &mv);
Expand All @@ -1874,13 +1876,15 @@ void tst_qquicktextedit::cursorDelegate()

textEditObject->setReadOnly(true);
textEditObject->setCursorPosition(0);
QTest::qWait(400); //ensure this isn't treated as a double-click
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x());
QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y());

textEditObject->setCursorPosition(0);
QTest::qWait(400); //ensure this isn't treated as a double-click
QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
QTest::qWait(50);
QTRY_VERIFY(textEditObject->cursorPosition() != 0);
Expand Down

0 comments on commit 6cf36b2

Please sign in to comment.