From 04b0d1b217229494e317ab0dfcd0b15436d67f70 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 11 Oct 2019 08:45:39 +0200 Subject: QQuickTextInput::remove: Fix selection logic Fixes: QTBUG-77814 Change-Id: I96b8990656117430eb12fc4b294a8ece612d3a4b Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann Reviewed-by: Ulf Hermann --- .../auto/quick/qquicktextinput/data/qtbug77841.qml | 22 ++++++++++++++++++++++ .../quick/qquicktextinput/tst_qquicktextinput.cpp | 13 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/auto/quick/qquicktextinput/data/qtbug77841.qml (limited to 'tests/auto/quick/qquicktextinput') diff --git a/tests/auto/quick/qquicktextinput/data/qtbug77841.qml b/tests/auto/quick/qquicktextinput/data/qtbug77841.qml new file mode 100644 index 0000000000..ebb43a8f82 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/qtbug77841.qml @@ -0,0 +1,22 @@ +import QtQuick 2.12 + +Item { + id: root + width: 600 + height: 300 + + TextInput { + id: qwe + objectName: "qwe" + width: 500 + height: 100 + font.pixelSize: 50 + text: "123456" + focus: true + } + + Component.onCompleted: { + qwe.insert(0, "***") + qwe.remove(0, 3) + } +} diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index ed2d535fda..cab4e1145f 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -230,6 +230,7 @@ private slots: void padding(); void QTBUG_51115_readOnlyResetsSelection(); + void QTBUG_77814_InsertRemoveNoSelection(); private: void simulateKey(QWindow *, int key); @@ -7003,6 +7004,18 @@ void tst_qquicktextinput::QTBUG_51115_readOnlyResetsSelection() QCOMPARE(obj->selectedText(), QString()); } +void tst_qquicktextinput::QTBUG_77814_InsertRemoveNoSelection() +{ + QQuickView view; + view.setSource(testFileUrl("qtbug77841.qml")); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QQuickTextInput *textInput = view.rootObject()->findChild("qwe"); + QVERIFY(textInput); + + QCOMPARE(textInput->selectedText(), QString()); +} + QTEST_MAIN(tst_qquicktextinput) #include "tst_qquicktextinput.moc" -- cgit v1.2.3 From 164a890573dacf619f2b4c48714fae49f0ab9711 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Oct 2019 11:00:53 +0200 Subject: Handle -no-feature-shortcut Preparing for the extraction of QGuiShortcut, the shortcut feature will changed to follow the convention of using QT_REQUIRE_CONFIG(shortcut) in the affected class headers. Add the required exclusions to prevent compile errors when disabling shortcuts. Task-number: QTBUG-76493 Change-Id: Icad95584ae12aa97a56b56ef27206cef1b1ba48f Reviewed-by: Joerg Bornemann --- .../quick/qquicktextinput/tst_qquicktextinput.cpp | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'tests/auto/quick/qquicktextinput') diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index cab4e1145f..1d12121a6f 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -146,7 +146,7 @@ private slots: void cursorRectangle(); void navigation(); void navigation_RTL(); -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void copyAndPaste(); void copyAndPasteKeySequence(); void canPasteEmpty(); @@ -181,15 +181,19 @@ private slots: void remove_data(); void remove(); +#if QT_CONFIG(shortcut) void keySequence_data(); void keySequence(); +#endif void undo_data(); void undo(); void redo_data(); void redo(); +#if QT_CONFIG(shortcut) void undo_keypressevents_data(); void undo_keypressevents(); +#endif void clear(); void backspaceSurrogatePairs(); @@ -236,7 +240,9 @@ private: void simulateKey(QWindow *, int key); void simulateKeys(QWindow *window, const QList &keys); +#if QT_CONFIG(shortcut) void simulateKeys(QWindow *window, const QKeySequence &sequence); +#endif QQmlEngine engine; QStringList standard; @@ -264,6 +270,8 @@ void tst_qquicktextinput::simulateKeys(QWindow *window, const QList &keys) } } +#if QT_CONFIG(shortcut) + void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence) { for (int i = 0; i < sequence.count(); ++i) { @@ -281,6 +289,8 @@ QList &operator <<(QList &keys, const QKeySequence &sequence) return keys; } +#endif // QT_CONFIG(shortcut) + template QList &operator <<(QList &keys, const char (&characters)[N]) { for (int i = 0; i < N - 1; ++i) { @@ -2586,7 +2596,7 @@ void tst_qquicktextinput::navigation_RTL() QVERIFY(input->hasActiveFocus()); } -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_qquicktextinput::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2684,7 +2694,7 @@ void tst_qquicktextinput::copyAndPaste() } #endif -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_qquicktextinput::copyAndPasteKeySequence() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2752,7 +2762,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence() } #endif -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_qquicktextinput::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -2768,7 +2778,7 @@ void tst_qquicktextinput::canPasteEmpty() } #endif -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_qquicktextinput::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -2784,7 +2794,7 @@ void tst_qquicktextinput::canPaste() } #endif -#if QT_CONFIG(clipboard) +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_qquicktextinput::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -5098,6 +5108,7 @@ void tst_qquicktextinput::remove() QVERIFY(cursorPositionSpy.count() > 0); } +#if QT_CONFIG(shortcut) void tst_qquicktextinput::keySequence_data() { QTest::addColumn("text"); @@ -5283,6 +5294,8 @@ void tst_qquicktextinput::keySequence() QCOMPARE(textInput->selectedText(), selectedText); } +#endif // QT_CONFIG(shortcut) + #define NORMAL 0 #define REPLACE_UNTIL_END 1 @@ -5556,6 +5569,8 @@ void tst_qquicktextinput::redo() QCOMPARE(spy.count(), 2); } +#if QT_CONFIG(shortcut) + void tst_qquicktextinput::undo_keypressevents_data() { QTest::addColumn("keys"); @@ -5860,6 +5875,8 @@ void tst_qquicktextinput::undo_keypressevents() QVERIFY(textInput->text().isEmpty()); } +#endif // QT_CONFIG(shortcut) + void tst_qquicktextinput::clear() { QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; -- cgit v1.2.3