summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlgraphicstextinput
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-02-15 19:52:52 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-02-15 19:52:52 (GMT)
commit6d095d54cb42f4456f09cc3c1473db9a87347f65 (patch)
treeb70b2ce900c362accf3c83ca5ae37e7d15860ede /tests/auto/declarative/qmlgraphicstextinput
parent564d73b9a8ec5a5dd6f692b73625cd4c6a2f6b99 (diff)
downloadQt-6d095d54cb42f4456f09cc3c1473db9a87347f65.zip
Qt-6d095d54cb42f4456f09cc3c1473db9a87347f65.tar.gz
Qt-6d095d54cb42f4456f09cc3c1473db9a87347f65.tar.bz2
Fix TextInput keypad navigation
Was accidentally ignoring key movements even when an existing selection meant that pressing right/left would do something. Task-number: QT-2944
Diffstat (limited to 'tests/auto/declarative/qmlgraphicstextinput')
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml1
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/data/validators.qml2
-rw-r--r--tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp13
3 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
index 7a2e914..493db5b 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml
@@ -11,6 +11,7 @@ Rectangle {
}
TextInput { id: input; focus: true
+ text: "Needs some text"
KeyNavigation.left: firstItem
KeyNavigation.right: lastItem
KeyNavigation.up: firstItem
diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
index 673790d..0c81548 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
+++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml
@@ -1,4 +1,4 @@
-import Qt 4.6
+import Qt 4.7
Item {
property var intInput: intInput
diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
index 906dbc2..b7ae4a2 100644
--- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
+++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp
@@ -508,6 +508,7 @@ void tst_qmlgraphicstextinput::inputMethodHints()
/*
TextInput element should only handle left/right keys until the cursor reaches
the extent of the text, then they should ignore the keys.
+
*/
void tst_qmlgraphicstextinput::navigation()
{
@@ -518,14 +519,24 @@ void tst_qmlgraphicstextinput::navigation()
QVERIFY(canvas->root() != 0);
- QmlGraphicsItem *input = qobject_cast<QmlGraphicsItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+ QmlGraphicsTextInput *input = qobject_cast<QmlGraphicsTextInput *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
QVERIFY(input != 0);
+ input->setCursorPosition(0);
QTRY_VERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == true);
+ //QT-2944: If text is selected, then we should deselect first.
+ input->setCursorPosition(input->text().length());
+ input->setSelectionStart(0);
+ input->setSelectionEnd(input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Left);