diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-05-25 16:41:14 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-05 03:22:18 +0200 |
commit | 5b83c3c27f95f14fba11d905a293797ebc543bf2 (patch) | |
tree | 0447a2b3741a81d968f87b0754292318c33351d2 /tests/auto/quick/qquicktextinput | |
parent | 1346c668cb65a8906cf31fc7e5a3a5f817f15af6 (diff) |
Ensure the cursor delegate position is updated on text changes.
Change-Id: I7518aa5969ea45538feccb87f4c296db6b7d6944
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
4 files changed, 22 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicktextinput/data/cursorTest.qml b/tests/auto/quick/qquicktextinput/data/cursorTest.qml index 71a420ee7c..363d37174b 100644 --- a/tests/auto/quick/qquicktextinput/data/cursorTest.qml +++ b/tests/auto/quick/qquicktextinput/data/cursorTest.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 Rectangle { id:rect; width: 300; height: 300; color: "white" property string contextualProperty: "Hello" TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject" + width: 300; height: 300 resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ] cursorDelegate: cursor } diff --git a/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml index 2f43449052..31ee01db99 100644 --- a/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml +++ b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml @@ -6,6 +6,7 @@ Rectangle { width: 300; height: 300; color: "white" text: "Hello world!" id: textInputObject; objectName: "textInputObject" + width: 300; height: 300 wrapMode: TextInput.Wrap cursorDelegate: Cursor { id:cursorInstance; diff --git a/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml index e51a2f3401..b699ed2752 100644 --- a/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml +++ b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml @@ -6,6 +6,7 @@ Rectangle { width: 300; height: 300; color: "white" text: "Hello world!" id: textInputObject objectName: "textInputObject" + width: 300; height: 300 wrapMode: TextInput.WordWrap cursorDelegate: Item { id:cursorInstance diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index d857d9ce6b..174233505a 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -2547,6 +2547,8 @@ void tst_qquicktextinput::cursorDelegate() QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); + textInputObject->setReadOnly(false); + // Delegate moved when text is entered textInputObject->setText(QString()); for (int i = 0; i < 20; ++i) { @@ -2559,8 +2561,23 @@ void tst_qquicktextinput::cursorDelegate() textInputObject->setText(QString()); for (int i = 0; i < 20; ++i) { QInputMethodEvent event; - event.setCommitString("a"); - QGuiApplication::sendEvent(&view, &event); + event.setCommitString("w"); + QGuiApplication::sendEvent(textInputObject, &event); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); + } + // Delegate moved when text is removed by im. + for (int i = 19; i > 1; --i) { + QInputMethodEvent event; + event.setCommitString(QString(), -1, 1); + QGuiApplication::sendEvent(textInputObject, &event); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); + } + { // Delegate moved the text is changed in place by im. + QInputMethodEvent event; + event.setCommitString("i", -1, 1); + QGuiApplication::sendEvent(textInputObject, &event); QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); } |