diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-05-03 13:03:29 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-03 07:04:03 +0200 |
commit | bf817782e6dfeb8455febe3e481bcdb4c383ed05 (patch) | |
tree | 7a11212363658422216dfa6d2b1f6a95ce5d7dee /tests/auto/quick/qquicktextinput | |
parent | ccd69247eaa6289bc31115f863ba4737b14fe34e (diff) |
Ensure the cursor rectangle is updated when preedit text changes.
Updating only when the cursor position changes isn't enough because
changing pre-edit text changes the width of the pre-edit area and
the x offset of all cursor positions within it.
Change-Id: I3c0a5e4ad4714a903ca84c1a25374491f34d95a0
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r-- | tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 23 |
2 files changed, 19 insertions, 5 deletions
diff --git a/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml index 907ea68b10..9e04620d8f 100644 --- a/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml +++ b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 TextInput { + width: 300 focus: true autoScroll: false diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 2ea24867af..e80808badf 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -3437,18 +3437,31 @@ void tst_qquicktextinput::preeditCursorRectangle() previousRect = currentRect; } + // Verify that if the cursor rectangle is updated if the pre-edit text changes + // but the (non-zero) cursor position is the same. + inputSpy.clear(); + panelSpy.clear(); + sendPreeditText("wwwww", 5); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRectF(); + QCOMPARE(input->cursorRectangle(), currentRect); + QCOMPARE(cursor->pos(), currentRect.topLeft()); + QCOMPARE(inputSpy.count(), 1); + QCOMPARE(panelSpy.count(), 1); + // Verify that if there is no preedit cursor then the micro focus rect is the // same as it would be if it were positioned at the end of the preedit text. - sendPreeditText(preeditText, 0); - QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + inputSpy.clear(); + panelSpy.clear(); + { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); } QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); currentRect = query.value(Qt::ImCursorRectangle).toRectF(); QCOMPARE(currentRect, previousRect); QCOMPARE(input->cursorRectangle(), currentRect); QCOMPARE(cursor->pos(), currentRect.topLeft()); - QVERIFY(inputSpy.count() > 0); - QVERIFY(panelSpy.count() > 0); + QCOMPARE(inputSpy.count(), 1); + QCOMPARE(panelSpy.count(), 1); } void tst_qquicktextinput::inputContextMouseHandler() |