From 8a1b17f80c131a2bf6681070db43604029b3a8c0 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Fri, 30 Sep 2011 13:37:51 +0300 Subject: [PATCH] Fix TextInput and TextEdit cursorRectangleSize autotests Task-number: QTBUG-21691 Change-Id: I7fdcbcb0fd8b3442f5af91aa87f4337c7597f95b Reviewed-on: http://codereview.qt-project.org/5865 Reviewed-by: Qt Sanity Bot Reviewed-by: Pekka Vuorela Reviewed-by: Andrew den Exter --- tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp | 10 ++++------ tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp | 13 +++++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp index 16fc63b..b3577f1 100644 --- a/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp +++ b/tests/auto/declarative/qsgtextedit/tst_qsgtextedit.cpp @@ -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) diff --git a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp index 0fecb54..89e5b02 100644 --- a/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp +++ b/tests/auto/declarative/qsgtextinput/tst_qsgtextinput.cpp @@ -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(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() -- 2.7.4