Fix expected failure in TextInput horizontalAlignment_RightToLeft test.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Wed, 9 Nov 2011 04:57:23 +0000 (14:57 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 10 Nov 2011 06:37:50 +0000 (07:37 +0100)
Send events to the input panels input item instead of the canvas. And
clear the pre-edit text before testing implicit alignment of empty text.

Change-Id: I5e6b04c53c9c6b344563b80b3aa76ab614b0ca0a
Reviewed-by: Martin Jones <martin.jones@nokia.com>

tests/auto/declarative/qquicktextinput/tst_qquicktextinput.cpp

index 62f5e03..95b5219 100644 (file)
@@ -1162,12 +1162,15 @@ void tst_qquicktextinput::horizontalAlignment_RightToLeft()
 
     // If there is no commited text, the preedit text should determine the alignment.
     textInput->setText(QString());
-    { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(&canvas, &ev); }
-    QEXPECT_FAIL("", "QTBUG-21691", Continue);
+    { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); }
     QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
-    { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(&canvas, &ev); }
+    { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); }
     QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
 
+    // Clear pre-edit text.  TextInput should maybe do this itself on setText, but that may be
+    // redundant as an actual input method may take care of it.
+    { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &ev); }
+
 #ifdef Q_OS_MAC
     // empty text with implicit alignment follows the system locale-based
     // keyboard input direction from QGuiApplication::keyboardInputDirection