aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-05-25 16:41:14 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-05 03:22:18 +0200
commit5b83c3c27f95f14fba11d905a293797ebc543bf2 (patch)
tree0447a2b3741a81d968f87b0754292318c33351d2 /tests/auto/quick/qquicktextedit
parent1346c668cb65a8906cf31fc7e5a3a5f817f15af6 (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/qquicktextedit')
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTest.qml1
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml1
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestInline.qml1
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp19
4 files changed, 21 insertions, 1 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());
}