diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-06 03:48:23 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-07-06 04:05:17 (GMT) |
commit | 98bfc8b8db811eb902290dbe87660ce799a44c27 (patch) | |
tree | 3715bdfae53a49cf5b1fca9c9fe16ddc0094c9ee /tests | |
parent | b43f46fdc4fede579b512624c03df5c19893288a (diff) | |
download | Qt-98bfc8b8db811eb902290dbe87660ce799a44c27.zip Qt-98bfc8b8db811eb902290dbe87660ce799a44c27.tar.gz Qt-98bfc8b8db811eb902290dbe87660ce799a44c27.tar.bz2 |
Fix input methods for TextInput elements with key handlers
Task-number: QTBUG-10297
Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml (renamed from tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml) | 1 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 29 |
2 files changed, 22 insertions, 8 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml b/tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml index da6b81f..405ee22 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/inputmethodhints.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml @@ -3,4 +3,5 @@ import Qt 4.7 TextInput { text: "Hello world!" inputMethodHints: Qt.ImhNoPredictiveText + Keys.onLeftPressed: {} } diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index b6ca7e5..5354f42 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -79,7 +79,7 @@ private slots: void maxLength(); void masks(); void validators(); - void inputMethodHints(); + void inputMethods(); void cursorDelegate(); void navigation(); @@ -609,18 +609,31 @@ void tst_qdeclarativetextinput::validators() delete canvas; } -void tst_qdeclarativetextinput::inputMethodHints() +void tst_qdeclarativetextinput::inputMethods() { - QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethods.qml"); canvas->show(); canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + // test input method hints QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); - QVERIFY(textinputObject != 0); - QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); - textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); - QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); + QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); + QVERIFY(input != 0); + QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); + input->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); + + QVERIFY(canvas->rootObject() != 0); + + input->setFocus(true); + QVERIFY(input->hasFocus() == true); + // test that input method event is committed + QInputMethodEvent event; + event.setCommitString( "My ", -12, 0); + QApplication::sendEvent(canvas, &event); + QCOMPARE(input->text(), QString("My Hello world!")); delete canvas; } |