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 | |
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')
8 files changed, 43 insertions, 3 deletions
diff --git a/tests/auto/quick/qquicktextedit/data/cursorTest.qml b/tests/auto/quick/qquicktextedit/data/cursorTest.qml index 7bfc869403..afccc68aed 100644 --- a/tests/auto/quick/qquicktextedit/data/cursorTest.qml +++ b/tests/auto/quick/qquicktextedit/data/cursorTest.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 Rectangle { width: 300; height: 300; color: "white" property string contextualProperty: "Hello" TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject" + 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/qquicktextedit/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml index 8eed022c2f..0c9679bade 100644 --- a/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml +++ b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml @@ -6,6 +6,7 @@ Rectangle { width: 300; height: 300; color: "white" text: "Hello world!" id: textEditObject; objectName: "textEditObject" + width: 300; height: 300 wrapMode: TextEdit.WordWrap cursorDelegate: Cursor { id:cursorInstance; diff --git a/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml index bda171018a..6e2ed8c7a8 100644 --- a/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml +++ b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml @@ -7,6 +7,7 @@ Rectangle { width: 300; height: 300; color: "white" id: textEditObject wrapMode: TextEdit.Wrap objectName: "textEditObject" + width: 300; height: 300 cursorDelegate: Item { id:cursorInstance objectName: "cursorInstance" diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 298a93cf58..80d81ccc0b 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2101,6 +2101,8 @@ void tst_qquicktextedit::cursorDelegate() QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); + textEditObject->setReadOnly(false); + // Delegate moved when text is entered textEditObject->setText(QString()); for (int i = 0; i < 20; ++i) { @@ -2114,7 +2116,22 @@ void tst_qquicktextedit::cursorDelegate() for (int i = 0; i < 20; ++i) { QInputMethodEvent event; event.setCommitString("a"); - QGuiApplication::sendEvent(&view, &event); + QGuiApplication::sendEvent(textEditObject, &event); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->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(textEditObject, &event); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); + } + { // Delegate moved the text is changed in place by im. + QInputMethodEvent event; + event.setCommitString("i", -1, 1); + QGuiApplication::sendEvent(textEditObject, &event); QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); } 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()); } |