Fix TextInput echoMode test failure.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Wed, 12 Oct 2011 03:02:39 +0000 (13:02 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 17 Oct 2011 23:47:58 +0000 (01:47 +0200)
The default input method hints for a QSGItem is Qt::ImhMultiline and
TextInput is a single line input so clear that default flag in init.

Task-number: QTBUG-21686
Change-Id: I3b57227ee4182bf89f6789f775b56efb156df85b
Reviewed-by: Martin Jones <martin.jones@nokia.com>

src/declarative/items/qsgtextinput.cpp
tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp

index 1eddbde..1c6bccb 100644 (file)
@@ -1856,6 +1856,7 @@ void QSGTextInputPrivate::init()
     q->connect(control, SIGNAL(displayTextChanged(QString)),
                q, SLOT(updateRect()));
     q->updateSize();
+    imHints &= ~Qt::ImhMultiLine;
     oldValidity = control->hasAcceptableInput();
     lastSelectionStart = 0;
     lastSelectionEnd = 0;
index 6189151..9ab6e69 100644 (file)
@@ -1925,7 +1925,6 @@ void tst_qsgtextinput::echoMode()
     //Normal
     ref &= ~Qt::ImhHiddenText;
     ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
-    QEXPECT_FAIL("", "QTBUG-21686", Abort);
     QCOMPARE(input->inputMethodHints(), ref);
     input->setEchoMode(QSGTextInput::NoEcho);
     QCOMPARE(input->text(), initial);
@@ -1964,9 +1963,10 @@ void tst_qsgtextinput::echoMode()
     QCOMPARE(input->displayText(), QLatin1String("Q"));
     QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
     input->setFocus(true);
+    QVERIFY(input->hasActiveFocus());
     QInputMethodEvent inputEvent;
     inputEvent.setCommitString(initial);
-    QGuiApplication::sendEvent(&canvas, &inputEvent);
+    QGuiApplication::sendEvent(input, &inputEvent);
     QCOMPARE(input->text(), initial);
     QCOMPARE(input->displayText(), initial);
     QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);