From 29e2497a2c3d09470ad779dd1aadcefac2d4daaf Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 25 Jul 2014 15:49:36 +0200 Subject: TextInput::displayText: include partial input from an input method [ChangeLog][QtQuick][Important Behavior Changes] TextInput::displayText now includes also partial input from an input method and thus matches with the actual displayed text. Task-number: QTBUG-40329 Change-Id: I407f464938c550d73eba1351283ec751aa293380 Reviewed-by: Alan Alpert Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index e5ef83ba32..c50923b32f 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2234,25 +2234,34 @@ void tst_qquicktextinput::inputMethods() QTRY_COMPARE(qGuiApp->focusObject(), input); QGuiApplication::sendEvent(input, &event); QCOMPARE(input->text(), QString("My Hello world!")); + QCOMPARE(input->displayText(), QString("My Hello world!")); input->setCursorPosition(2); event.setCommitString("Your", -2, 2); QGuiApplication::sendEvent(input, &event); QCOMPARE(input->text(), QString("Your Hello world!")); + QCOMPARE(input->displayText(), QString("Your Hello world!")); QCOMPARE(input->cursorPosition(), 4); input->setCursorPosition(7); event.setCommitString("Goodbye", -2, 5); QGuiApplication::sendEvent(input, &event); QCOMPARE(input->text(), QString("Your Goodbye world!")); + QCOMPARE(input->displayText(), QString("Your Goodbye world!")); QCOMPARE(input->cursorPosition(), 12); input->setCursorPosition(8); event.setCommitString("Our", -8, 4); QGuiApplication::sendEvent(input, &event); QCOMPARE(input->text(), QString("Our Goodbye world!")); + QCOMPARE(input->displayText(), QString("Our Goodbye world!")); QCOMPARE(input->cursorPosition(), 7); + QInputMethodEvent preeditEvent("PREEDIT", QList()); + QGuiApplication::sendEvent(input, &preeditEvent); + QCOMPARE(input->text(), QString("Our Goodbye world!")); + QCOMPARE(input->displayText(), QString("Our GooPREEDITdbye world!")); + // input should reset selection even if replacement parameters are out of bounds input->setText("text"); input->setCursorPosition(0); @@ -2260,6 +2269,8 @@ void tst_qquicktextinput::inputMethods() event.setCommitString("replacement", -input->text().length(), input->text().length()); QGuiApplication::sendEvent(input, &event); QCOMPARE(input->selectionStart(), input->selectionEnd()); + QCOMPARE(input->text(), QString("replacement")); + QCOMPARE(input->displayText(), QString("replacement")); QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled); QGuiApplication::sendEvent(input, &enabledQueryEvent); -- cgit v1.2.3