aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-05-09 13:57:34 +1000
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-06-09 18:26:10 +1000
commit475c8aed8a7dbcec5b1d3647846f82f6cc940b2c (patch)
tree3b877cb7eee799c70861c3c23be56e281cea617e /tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
parentd356a263f627b55424a9750163a00dffc6faebcf (diff)
Ensure the TextEdit cursor delegate is repositioned on mouse events.
Update the micro focus when a mouse press changes the cursor position of a read only TextEdit. Change-Id: I11855037f7938b2cd23ac6ad165722b5289b4f46 Task-number: QTBUG-19109 Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 3f30a52204..f687d38de8 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -1639,6 +1639,26 @@ void tst_qdeclarativetextedit::cursorDelegate()
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
}
+ // Clear preedit text;
+ 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()));
+ QVERIFY(textEditObject->cursorPosition() != 0);
+ 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()));
+ 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()));