aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-10-14 10:44:47 +0200
committerRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-10-30 10:32:53 +0100
commit02de9d7b6c851d7021dbb901d97c3f91209b1ea9 (patch)
treed143dc6a40d98a7482d965e40a49c73813dd18ea /tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
parentcf959b4b4ea3d2dfd5243022fea393fadfd95b0d (diff)
text input: always let cursor rect have a width == 1
Instead of using a cursor width of null when a cursor delegate is set, we should to use a value of 1. Otherwise the rect we e.g return from cursorRect() will be invalid. An alternative would be to use the width of the delegate, but that was found to be controversial. On iOS we saw a bug with this when telling iOS to position text spelling popups underneath the cursor. Since the cursor rect we got was invalid (zero-width), no popup would show. Change-Id: Ice51b9a1bd33f331183e3acec61b7d9c0f5163cd Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 4829b478e9..4f10b4ce82 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -171,6 +171,7 @@ private slots:
void preeditCursorRectangle();
void inputMethodComposing();
+ void cursorRectangleSize_data();
void cursorRectangleSize();
void getText_data();
@@ -3654,12 +3655,28 @@ void tst_qquicktextedit::inputMethodComposing()
QCOMPARE(spy.count(), 8);
}
+void tst_qquicktextedit::cursorRectangleSize_data()
+{
+ QTest::addColumn<bool>("useCursorDelegate");
+
+ QTest::newRow("default cursor") << false;
+ QTest::newRow("custom cursor delegate") << true;
+}
+
void tst_qquicktextedit::cursorRectangleSize()
{
+ QFETCH(bool, useCursorDelegate);
+
QQuickView *window = new QQuickView(testFileUrl("positionAt.qml"));
QVERIFY(window->rootObject() != 0);
QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(window->rootObject());
+ QQmlComponent cursorDelegate(window->engine());
+ if (useCursorDelegate) {
+ cursorDelegate.setData("import QtQuick 2.0\nRectangle { width:10; height:10; }", QUrl());
+ textEdit->setCursorDelegate(&cursorDelegate);
+ }
+
// make sure cursor rectangle is not at (0,0)
textEdit->setX(10);
textEdit->setY(10);
@@ -3677,6 +3694,10 @@ void tst_qquicktextedit::cursorRectangleSize()
QRectF cursorRectFromItem = textEdit->cursorRectangle();
QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
+ QVERIFY(cursorRectFromItem.isValid());
+ QVERIFY(cursorRectFromQuery.isValid());
+ QVERIFY(cursorRectFromPositionToRectangle.isValid());
+
// item and input query cursor rectangles match
QCOMPARE(cursorRectFromItem, cursorRectFromQuery);