aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2018-11-21 11:34:32 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2018-12-13 17:53:19 +0000
commit0a92b02f1784a8934490633edcfed79fc685bfa2 (patch)
tree2686826b9c64dc7e760ae5a2a169b13658a48e0d /tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
parent9929c250a3829aec82955da91413bc7673dc159d (diff)
Fix Keys.onShortcutOverride for TextEdit
It was not possible to override a shortcut with Keys.onShortcutOverride for TextEdit. This was because the ShortcutOverride event sent to the TextEdit was not passed on to the default event() implementation (of the base class) in the case that the QQuickTextEdit did not handle the ShortcutOverride event. Fixes: QTBUG-68711 Change-Id: I981738d8f92c77eadb8dd98b4245290d430525d3 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index da15ca6b48..f32da44daa 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);
@@ -5671,6 +5673,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"