aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-03-19 12:02:44 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-03-22 06:58:42 +0000
commit1f118ce85b8c29d713d2feae529ec8a71ba28048 (patch)
treea00fc88c01b89dd0b48b8d0c9ac9853a57091e1c /tests/auto
parentbb30edf15815006bac3ecddfa958055a92057600 (diff)
Fix Shortcuts in Popups with window context not being activated
Before this patch, this code wouldn't work: Popup { id: popup Shortcut { sequence: "Tab" onActivated: popup.visible = !popup.visible } } Even though Popup is aware of its Window, the Shortcut object is parented to Popup::contentItem, which does not have a Window associated with it while the Popup is hidden. The fix is to check if the item has a window in QQuickShortcutContext::matcher(), so that that check fails and the QQuickPopup itself is used to access the window. Change-Id: Ia1c5d75ad6b82fb4c8b7664b6d418d84428b1ddf Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_popup.qml38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index 3f9f5e48..a6c24cb7 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.4
+import QtQuick 2.11
import QtTest 1.0
import QtQuick.Controls 2.3
import QtQuick.Templates 2.3 as T
@@ -1269,4 +1269,40 @@ TestCase {
compare(control.background.width, 200 + (control.background.leftInset || 0) + (control.background.rightInset || 0))
compare(control.background.height, 100 + (control.background.topInset || 0) + (control.background.bottomInset || 0))
}
+
+
+ Component {
+ id: shortcutWindowComponent
+ ApplicationWindow {
+ id: window
+ width: 360
+ height: 360
+ visible: true
+
+ property alias popup: popup
+
+ Popup {
+ id: popup
+
+ Shortcut {
+ sequence: "Tab"
+ onActivated: popup.visible = !popup.visible
+ }
+ }
+ }
+ }
+
+ function test_shortcut() {
+ // Tests that a Shortcut with Qt.WindowShortcut context
+ // that is declared within a Popup is activated.
+ var window = createTemporaryObject(shortcutWindowComponent, testCase)
+ var control = window.popup
+
+ waitForRendering(window.contentItem)
+ keyClick(Qt.Key_Tab)
+ tryCompare(control, "visible", true)
+
+ keyClick(Qt.Key_Tab)
+ tryCompare(control, "visible", false)
+ }
}