aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index da15ca6b48..ce2a8eb257 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -36,6 +36,7 @@
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlcomponent.h>
#include <QtGui/qguiapplication.h>
+#include <private/qquickrectangle_p.h>
#include <private/qquicktextedit_p.h>
#include <private/qquicktextedit_p_p.h>
#include <private/qquicktext_p.h>
@@ -205,6 +206,7 @@ private slots:
void padding();
void QTBUG_51115_readOnlyResetsSelection();
+ void keys_shortcutoverride();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -1260,6 +1262,34 @@ void tst_qquicktextedit::persistentSelection()
edit->setFocus(true);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+ // QTBUG-50587 (persistentSelection with readOnly)
+ edit->setReadOnly(true);
+
+ edit->setPersistentSelection(false);
+ QCOMPARE(edit->persistentSelection(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setPersistentSelection(true);
+ QCOMPARE(edit->persistentSelection(), true);
+ QCOMPARE(spy.count(), 3);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
}
void tst_qquicktextedit::selectionOnFocusOut()
@@ -5671,6 +5701,36 @@ void tst_qquicktextedit::QTBUG_51115_readOnlyResetsSelection()
QCOMPARE(obj->selectedText(), QString());
}
+void tst_qquicktextedit::keys_shortcutoverride()
+{
+ // Tests that QML TextEdit receives Keys.onShortcutOverride (QTBUG-68711)
+ QQuickView view;
+ view.setSource(testFileUrl("keys_shortcutoverride.qml"));
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ QObject *root = view.rootObject();
+ QVERIFY(root);
+
+ QQuickTextEdit *textEdit = root->findChild<QQuickTextEdit*>();
+ QVERIFY(textEdit);
+ QQuickRectangle *rectangle = root->findChild<QQuickRectangle*>(QLatin1String("rectangle"));
+ QVERIFY(rectangle);
+
+ // Precondition: check if its not already changed
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("nobody"));
+
+ // send Key_Escape to the Rectangle
+ QVERIFY(rectangle->hasActiveFocus());
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("Rectangle"));
+
+ // send Key_Escape to TextEdit
+ textEdit->setFocus(true);
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("TextEdit"));
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"