Fix TextInput and TextEdit cursorRectangleSize autotests
authorJoona Petrell <joona.t.petrell@nokia.com>
Fri, 30 Sep 2011 10:37:51 +0000 (13:37 +0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 5 Oct 2011 14:25:17 +0000 (16:25 +0200)
Task-number: QTBUG-21691

Change-Id: I7fdcbcb0fd8b3442f5af91aa87f4337c7597f95b
Reviewed-on: http://codereview.qt-project.org/5865
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Pekka Vuorela <pekka.ta.vuorela@nokia.com>
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp
tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp

index 16fc63b..b3577f1 100644 (file)
@@ -2426,10 +2426,6 @@ void tst_qsgtextedit::inputMethodComposing()
 
 void tst_qsgtextedit::cursorRectangleSize()
 {
-#ifdef QTBUG_21691
-    QEXPECT_FAIL("", QTBUG_21691_MESSAGE, Abort);
-    QVERIFY(false);
-#else
     QSGView *canvas = new QSGView(QUrl::fromLocalFile(SRCDIR "/data/CursorRect.qml"));
     QVERIFY(canvas->rootObject() != 0);
     canvas->show();
@@ -2441,13 +2437,15 @@ void tst_qsgtextedit::cursorRectangleSize()
     textEdit->setFocus(Qt::OtherFocusReason);
     QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition());
     QRectF microFocusFromScene = canvas->inputMethodQuery(Qt::ImCursorRectangle).toRectF();
-    QRectF microFocusFromApp= QGuiApplication::focusWidget()->inputMethodQuery(Qt::ImCursorRectangle).toRectF();
+    QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+    qApp->sendEvent(qApp->inputPanel()->inputItem(), &event);
+
+    QRectF microFocusFromApp = event.value(Qt::ImCursorRectangle).toRectF();
 
     QCOMPARE(microFocusFromScene.size(), cursorRect.size());
     QCOMPARE(microFocusFromApp.size(), cursorRect.size());
 
     delete canvas;
-#endif
 }
 
 QTEST_MAIN(tst_qsgtextedit)
index 0fecb54..89e5b02 100644 (file)
@@ -2593,15 +2593,10 @@ void tst_qsgtextinput::inputMethodComposing()
 
 void tst_qsgtextinput::cursorRectangleSize()
 {
-#ifdef QTBUG_21691
-    QEXPECT_FAIL("", QTBUG_21691_MESSAGE, Abort);
-    QVERIFY(false);
-#else
     QSGView *canvas = new QSGView(QUrl::fromLocalFile(SRCDIR "/data/positionAt.qml"));
     QVERIFY(canvas->rootObject() != 0);
     canvas->show();
-    canvas->setFocus();
-    QGuiApplication::setActiveWindow(canvas);
+    canvas->requestActivateWindow();
     QTest::qWaitForWindowShown(canvas);
 
     QSGTextInput *textInput = qobject_cast<QSGTextInput *>(canvas->rootObject());
@@ -2609,13 +2604,15 @@ void tst_qsgtextinput::cursorRectangleSize()
     textInput->setFocus(Qt::OtherFocusReason);
     QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition());
     QRectF microFocusFromScene = canvas->inputMethodQuery(Qt::ImCursorRectangle).toRectF();
-    QRectF microFocusFromApp= QGuiApplication::focusWidget()->inputMethodQuery(Qt::ImCursorRectangle).toRectF();
+    QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+    qApp->sendEvent(qApp->inputPanel()->inputItem(), &event);
+
+    QRectF microFocusFromApp = event.value(Qt::ImCursorRectangle).toRectF();
 
     QCOMPARE(microFocusFromScene.size(), cursorRect.size());
     QCOMPARE(microFocusFromApp.size(), cursorRect.size());
 
     delete canvas;
-#endif
 }
 
 void tst_qsgtextinput::tripleClickSelectsAll()