summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-04-19 05:11:36 (GMT)
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-04-21 05:22:57 (GMT)
commit60198a071dd76e57ab799215f0fbddc8d550ba30 (patch)
treef5801fea0958e2fb572e3a7de62ff6fe6e735c46 /tests/auto
parent2f173e4945dd8414636c1061acfaf9c2d8b718d8 (diff)
downloadQt-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.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp9
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);