aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextinput
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-11-18 16:15:01 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2019-11-25 15:34:40 +0100
commitf1f395b37da163bce2dc3b5fc4e298bb4f56a3e7 (patch)
tree9ce2ba89a86ed754a8ecb8f52181770853e21a08 /tests/auto/quick/qquicktextinput
parentba494aaa24defe1401f621b791891e696b308756 (diff)
parent0ee087f5a5edd7d1aa39fd15e0dc85985320c09a (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug77841.qml22
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp42
2 files changed, 58 insertions, 6 deletions
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..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();
@@ -230,12 +234,15 @@ private slots:
void padding();
void QTBUG_51115_readOnlyResetsSelection();
+ void QTBUG_77814_InsertRemoveNoSelection();
private:
void simulateKey(QWindow *, int key);
void simulateKeys(QWindow *window, const QList<Key> &keys);
+#if QT_CONFIG(shortcut)
void simulateKeys(QWindow *window, const QKeySequence &sequence);
+#endif
QQmlEngine engine;
QStringList standard;
@@ -263,6 +270,8 @@ void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
}
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
{
for (int i = 0; i < sequence.count(); ++i) {
@@ -280,6 +289,8 @@ QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
return keys;
}
+#endif // QT_CONFIG(shortcut)
+
template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
{
for (int i = 0; i < N - 1; ++i) {
@@ -2585,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())
@@ -2683,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())
@@ -2751,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();
@@ -2767,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");
@@ -2783,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())
@@ -5097,6 +5108,7 @@ void tst_qquicktextinput::remove()
QVERIFY(cursorPositionSpy.count() > 0);
}
+#if QT_CONFIG(shortcut)
void tst_qquicktextinput::keySequence_data()
{
QTest::addColumn<QString>("text");
@@ -5282,6 +5294,8 @@ void tst_qquicktextinput::keySequence()
QCOMPARE(textInput->selectedText(), selectedText);
}
+#endif // QT_CONFIG(shortcut)
+
#define NORMAL 0
#define REPLACE_UNTIL_END 1
@@ -5555,6 +5569,8 @@ void tst_qquicktextinput::redo()
QCOMPARE(spy.count(), 2);
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextinput::undo_keypressevents_data()
{
QTest::addColumn<KeyList>("keys");
@@ -5859,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 }";
@@ -7003,6 +7021,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<QQuickTextInput*>("qwe");
+ QVERIFY(textInput);
+
+ QCOMPARE(textInput->selectedText(), QString());
+}
+
QTEST_MAIN(tst_qquicktextinput)
#include "tst_qquicktextinput.moc"