diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-11-06 17:00:44 -0700 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-11-07 19:28:00 -0700 |
commit | ac3f1eace1102543008a0ceded541e40ff495368 (patch) | |
tree | d0cb33e4f778d14733663380b81017db92583cb7 /tests/auto/quick/qquicktextinput | |
parent | d51847e327d6d19c0e984ad65f66d8123d2e56ea (diff) |
Allow tapping to deselect in TextInput/TextField with pre-6.4 API
Amends 650342de792e0ab37ce8bac8ccde21ab9b96b2c9
Fixes: QTBUG-116606
Pick-to: 6.5 6.6
Change-Id: I5c53559e0727c65a7d921a13f063ea2612cdcbca
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r-- | tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1df346dc93..f3b0366cd6 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -7183,6 +7183,20 @@ void tst_qquicktextinput::touchscreenDoesNotSelect() QTest::touchEvent(&window, touchscreen.data()).release(0, QPoint(x2,y), &window); QQuickTouchUtils::flush(&window); QVERIFY(textInputObject->selectedText().isEmpty()); + + // select all text (which moves the cursor to the end), then tap: + // with old API, it deselects, and moves the cursor (QTBUG-116606) + // with new API, it remains selected, and the cursor remains at the end + textInputObject->selectAll(); + const int cursorPos = textInputObject->cursorPosition(); + QTest::touchEvent(&window, touchscreen.data()).press(0, QPoint(x2,y), &window); + QTest::touchEvent(&window, touchscreen.data()).release(0, QPoint(x2,y), &window); + QQuickTouchUtils::flush(&window); + QCOMPARE(textInputObject->selectedText().isEmpty(), !expectDefaultSelectByMouse); + if (expectDefaultSelectByMouse) + QCOMPARE(textInputObject->cursorPosition(), cursorPos); + else + QCOMPARE_NE(textInputObject->cursorPosition(), cursorPos); } void tst_qquicktextinput::touchscreenSetsFocusAndMovesCursor() |