diff options
author | Marcel Schuette <marcel.schuette@nokia.com> | 2012-05-25 14:46:29 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-30 19:47:09 (GMT) |
commit | 6c20d552b9917ea736c52a7d436dafbf542bff30 (patch) | |
tree | 9e8803159831ef9b52c16c24742df9c04eae84b2 /tests | |
parent | fc1802a17bc5c074673cbd2778334cc7ddae9cd8 (diff) | |
download | Qt-6c20d552b9917ea736c52a7d436dafbf542bff30.zip Qt-6c20d552b9917ea736c52a7d436dafbf542bff30.tar.gz Qt-6c20d552b9917ea736c52a7d436dafbf542bff30.tar.bz2 |
Propagate left key presses to the parent item when TextInput is empty.
Don't overwrite the ignore value once it's been set to true. Backport
from Qt 5.0 to Qt 4.8
(commit a7017465152d544a4217d5ce4f6f84b80cb9b8b9)
Task-number: QTBUG-25447
Change-Id: I2232806b1235b0c901aab21116b5bc70c65d0500
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 12 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 12 |
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 31da832..6a1bb43 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1895,7 +1895,7 @@ void tst_qdeclarativetextedit::navigation() QVERIFY(canvas->rootObject() != 0); - QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); + QDeclarativeTextEdit *input = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasActiveFocus() == true); @@ -1910,6 +1910,16 @@ void tst_qdeclarativetextedit::navigation() simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasActiveFocus() == true); + // Test left and right navigation works if the TextEdit is empty (QTBUG-25447). + input->setText(QString()); + QCOMPARE(input->cursorPosition(), 0); + simulateKey(canvas, Qt::Key_Right); + QCOMPARE(input->hasActiveFocus(), false); + simulateKey(canvas, Qt::Key_Left); + QCOMPARE(input->hasActiveFocus(), true); + simulateKey(canvas, Qt::Key_Left); + QCOMPARE(input->hasActiveFocus(), false); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index df598be..55b4b89 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -1613,6 +1613,18 @@ void tst_qdeclarativetextinput::navigation() simulateKey(canvas, Qt::Key_Down); QCOMPARE(input->cursorPosition(),2); + // Test left and right navigation works if the TextInput is empty (QTBUG-25447). + input->setText(QString()); + QCOMPARE(input->cursorPosition(), 0); + simulateKey(canvas, Qt::Key_Left); + QCOMPARE(input->hasActiveFocus(), false); + simulateKey(canvas, Qt::Key_Right); + QCOMPARE(input->hasActiveFocus(), true); + simulateKey(canvas, Qt::Key_Right); + QCOMPARE(input->hasActiveFocus(), false); + simulateKey(canvas, Qt::Key_Left); + QCOMPARE(input->hasActiveFocus(), true); + delete canvas; } |