diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-15 16:40:38 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-15 16:44:16 +0100 |
commit | b7a8b5a284bdf306a45b11e1c5ce308be007d1de (patch) | |
tree | 35ebcf4b3440abb24df67b579e00847417d42c19 /tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | |
parent | 441e6bbdb01733c0f9860ce881b61f5907d2d2f8 (diff) | |
parent | 365a3ac6ae50eb53253eca92bfdf4c527b3a5c05 (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
src/qml/jsruntime/qv4string.cpp
The conflict resolution for qv4tsring.cpp is to essentially omit the
change of commit 64714ea431f2fd355ed27edc69dba4e992511e75 as the code in
5.8 already uses the add/mul_overflow functions.
This merge also reverts commit f4ac007f4a19bc095ff15d415a6629986de78e49
as we can deal with dead store elimination now.
Change-Id: Iee08c87cbe1a2ff23a73ce621d56262b4e007c56
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r-- | tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 5ed0e9eea7..5d30cc8c94 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -140,6 +140,7 @@ private slots: void cursorVisible(); void delegateLoading_data(); void delegateLoading(); + void cursorDelegateHeight(); void navigation(); void readOnly(); #ifndef QT_NO_CLIPBOARD @@ -2848,6 +2849,43 @@ void tst_qquicktextedit::delegateLoading() //QVERIFY(!delegate); } +void tst_qquicktextedit::cursorDelegateHeight() +{ + QQuickView view(testFileUrl("cursorHeight.qml")); + view.show(); + view.requestActivate(); + QTest::qWaitForWindowActive(&view); + QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject"); + QVERIFY(textEditObject); + // Delegate creation is deferred until focus in or cursor visibility is forced. + QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance")); + QVERIFY(!textEditObject->isCursorVisible()); + + // Test that the delegate gets created. + textEditObject->setFocus(true); + QVERIFY(textEditObject->isCursorVisible()); + QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance"); + QVERIFY(delegateObject); + + const int largerHeight = textEditObject->cursorRectangle().height(); + + textEditObject->setCursorPosition(0); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Move the cursor to the next line, which has a smaller font. + textEditObject->setCursorPosition(5); + QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x()); + QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y()); + QVERIFY(textEditObject->cursorRectangle().height() < largerHeight); + QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height()); + + // Test that the delegate gets deleted + textEditObject->setCursorDelegate(0); + QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance")); +} + /* TextEdit element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. |