diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-05-22 07:48:30 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-05-22 07:48:54 +0200 |
commit | 800025fb70ace453275011c1ae5ce906e0fa3344 (patch) | |
tree | 7f1ff56262b75beb3b0a1e94563c43fc59de742b /tests/auto/quick/qquicktextedit | |
parent | 666f20523cd7be16d88d3c03252ed2fd6e4be0c4 (diff) | |
parent | eb0f98499485487f9f75b6388f00c58b50aeff50 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I0dd91626837276f5811e4830f4a4e9f89bf1e1bd
Diffstat (limited to 'tests/auto/quick/qquicktextedit')
-rw-r--r-- | tests/auto/quick/qquicktextedit/data/qtbug-38947.qml | 16 | ||||
-rw-r--r-- | tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 28 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml b/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml new file mode 100644 index 0000000000..ebf8080e69 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/qtbug-38947.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + height: 200 + width: 200 + TextEdit { + objectName: "textedit" + text: "Hello\nWorld!" + selectByMouse: true + cursorDelegate: Rectangle { + width: 10 + color: "transparent" + border.color: "red" + } + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 88b9c2d792..f8fc4c10da 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -207,6 +207,7 @@ private slots: void embeddedImages_data(); void emptytags_QTBUG_22058(); + void cursorRectangle_QTBUG_38947(); private: void simulateKeys(QWindow *window, const QList<Key> &keys); @@ -5262,6 +5263,33 @@ void tst_qquicktextedit::emptytags_QTBUG_22058() QCOMPARE(input->text(), QString("<b>Bold<>")); } +void tst_qquicktextedit::cursorRectangle_QTBUG_38947() +{ + QQuickView window(testFileUrl("qtbug-38947.qml")); + + window.show(); + window.requestActivate(); + QTest::qWaitForWindowExposed(&window); + QQuickTextEdit *edit = window.rootObject()->findChild<QQuickTextEdit *>("textedit"); + QVERIFY(edit); + + QPoint from = edit->positionToRectangle(0).center().toPoint(); + QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, from); + + QSignalSpy spy(edit, SIGNAL(cursorRectangleChanged())); + QVERIFY(spy.isValid()); + + for (int i = 1; i < edit->length() - 1; ++i) { + QRectF rect = edit->positionToRectangle(i); + QTest::mouseMove(&window, rect.center().toPoint()); + QCOMPARE(edit->cursorRectangle(), rect); + QCOMPARE(spy.count(), i); + } + + QPoint to = edit->positionToRectangle(edit->length() - 1).center().toPoint(); + QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, to); +} + QTEST_MAIN(tst_qquicktextedit) #include "tst_qquicktextedit.moc" |