diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-08-04 00:58:26 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-08-04 01:09:02 (GMT) |
commit | f9eac4edbd06adef7569ca99043da57129c96812 (patch) | |
tree | 441f4b011caef22b643a70fa5c85bad48e8d0409 /tests | |
parent | f9e7aee2019d321edd655bfde7de43f20a106971 (diff) | |
download | Qt-f9eac4edbd06adef7569ca99043da57129c96812.zip Qt-f9eac4edbd06adef7569ca99043da57129c96812.tar.gz Qt-f9eac4edbd06adef7569ca99043da57129c96812.tar.bz2 |
Move cursorDelegate with the mouse selection of read only text input.
Change-Id: Iae4b2f9f6c9a7da7ec0e194b2568fb3a6da8ea71
Task-number: QTBUG-19109
Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 8530c7f..5d6f2a2 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1679,15 +1679,26 @@ void tst_qdeclarativetextedit::cursorDelegate() QInputMethodEvent event; QApplication::sendEvent(view, &event); + // Test delegate gets moved on mouse press. textEditObject->setSelectByMouse(true); textEditObject->setCursorPosition(0); - qDebug() << textEditObject->boundingRect() << textEditObject->positionToRectangle(5).center() << view->mapFromScene(textEditObject->positionToRectangle(5).center()); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); + const QPoint point1 = view->mapFromScene(textEditObject->positionToRectangle(5).center()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, point1); QVERIFY(textEditObject->cursorPosition() != 0); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + // Test delegate gets moved on mouse drag + textEditObject->setCursorPosition(0); + const QPoint point2 = view->mapFromScene(textEditObject->positionToRectangle(10).center()); + QTest::mousePress(view->viewport(), Qt::LeftButton, 0, point1); + QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(view->viewport(), &mv); + QTest::mouseRelease(view->viewport(), Qt::LeftButton, 0, point2); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + textEditObject->setReadOnly(true); textEditObject->setCursorPosition(0); QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); @@ -1696,6 +1707,12 @@ void tst_qdeclarativetextedit::cursorDelegate() QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); textEditObject->setCursorPosition(0); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); + QVERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + textEditObject->setCursorPosition(0); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); QVERIFY(textEditObject->cursorRectangle().y() >= 0); |