diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-04-19 05:11:36 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-04-21 05:22:57 (GMT) |
commit | 60198a071dd76e57ab799215f0fbddc8d550ba30 (patch) | |
tree | f5801fea0958e2fb572e3a7de62ff6fe6e735c46 /tests/auto | |
parent | 2f173e4945dd8414636c1061acfaf9c2d8b718d8 (diff) | |
download | Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.zip Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.tar.gz Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.tar.bz2 |
Fix TextInput cursor position unchanged when selection length is 0.
Move the cursor position to the start position when both the new and
old selections are empty as would happen if either was non-empty.
Change-Id: I493e52c551b47e009fd13b3e95856ff012ee5d95
Task-number: QTBUG-18768
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 10 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 574d2d5..26a6fd8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -788,6 +788,14 @@ void tst_qdeclarativetextedit::selection() QCOMPARE(textEditObject->selectionEnd(), i); QVERIFY(textEditObject->selectedText().isNull()); } + //Test cursor follows selection + for(int i=0; i<= testStr.size(); i++) { + textEditObject->select(i,i); + QCOMPARE(textEditObject->cursorPosition(), i); + QCOMPARE(textEditObject->selectionStart(), i); + QCOMPARE(textEditObject->selectionEnd(), i); + } + textEditObject->setCursorPosition(0); QVERIFY(textEditObject->cursorPosition() == 0); @@ -812,10 +820,12 @@ void tst_qdeclarativetextedit::selection() for(int i=0; i<= testStr.size(); i++) { textEditObject->select(0,i); QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); + QCOMPARE(textEditObject->cursorPosition(), i); } for(int i=0; i<= testStr.size(); i++) { textEditObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); + QCOMPARE(textEditObject->cursorPosition(), testStr.size()); } textEditObject->setCursorPosition(0); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 79d95d3..baaf862 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -375,6 +375,13 @@ void tst_qdeclarativetextinput::selection() QCOMPARE(textinputObject->selectionEnd(), i); QVERIFY(textinputObject->selectedText().isNull()); } + //Test cursor follows selection + for(int i=0; i<= testStr.size(); i++) { + textinputObject->select(i,i); + QCOMPARE(textinputObject->cursorPosition(), i); + QCOMPARE(textinputObject->selectionStart(), i); + QCOMPARE(textinputObject->selectionEnd(), i); + } textinputObject->setCursorPosition(0); QVERIFY(textinputObject->cursorPosition() == 0); @@ -399,10 +406,12 @@ void tst_qdeclarativetextinput::selection() for(int i=0; i<= testStr.size(); i++) { textinputObject->select(0,i); QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); + QCOMPARE(textinputObject->cursorPosition(), i); } for(int i=0; i<= testStr.size(); i++) { textinputObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); + QCOMPARE(textinputObject->cursorPosition(), testStr.size()); } textinputObject->setCursorPosition(0); |