diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-28 03:01:34 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-28 03:01:34 +0200 |
commit | 012556df80470e294c1adaf1b442e1eb8729c598 (patch) | |
tree | 1871aaa41c9eaabd27b64d34458d02f85995f187 /tests | |
parent | 5df2972e560dab4a1778444dc1dbe0c95c86be21 (diff) | |
parent | bc93333958e469e2bd79319befb23328a9de38a9 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I6d731149b21d02164220f6cdc485d9e4ae31bd13
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 86 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_popup.qml | 6 |
2 files changed, 89 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 22b36725..8e8f9c2f 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -755,6 +755,12 @@ TestCase { control.x = testCase.width - control.width / 2 compare(control.x, testCase.width - control.width / 2) compare(control.popup.contentItem.parent.x, testCase.width - control.width / 2) + + // close the popup when hidden (QTBUG-67684) + control.popup.open() + tryCompare(control.popup, "opened", true) + control.visible = false + tryCompare(control.popup, "visible", false) } function test_mouse() { @@ -1594,4 +1600,84 @@ TestCase { tryCompare(control.popup, "visible", true) compare(control.popup.height, control.popup.topPadding + control.popup.bottomPadding) } + + Component { + id: keysMonitor + Item { + property int pressedKeys: 0 + property int releasedKeys: 0 + property int lastPressedKey: 0 + property int lastReleasedKey: 0 + property alias comboBox: comboBox + + width: 200 + height: 200 + + Keys.onPressed: { ++pressedKeys; lastPressedKey = event.key } + Keys.onReleased: { ++releasedKeys; lastReleasedKey = event.key } + + ComboBox { + id: comboBox + } + } + } + + function test_keyClose_data() { + return [ + { tag: "Escape", key: Qt.Key_Escape }, + { tag: "Back", key: Qt.Key_Back } + ] + } + + function test_keyClose(data) { + var container = createTemporaryObject(keysMonitor, testCase) + verify(container) + + var control = comboBox.createObject(container) + verify(control) + + control.forceActiveFocus() + verify(control.activeFocus) + + var pressedKeys = 0 + var releasedKeys = 0 + + // popup not visible -> propagates + keyPress(data.key) + compare(container.pressedKeys, ++pressedKeys) + compare(container.lastPressedKey, data.key) + + keyRelease(data.key) + compare(container.releasedKeys, ++releasedKeys) + compare(container.lastReleasedKey, data.key) + + verify(control.activeFocus) + + // popup visible -> handled -> does not propagate + control.popup.open() + tryCompare(control.popup, "opened", true) + + keyPress(data.key) + compare(container.pressedKeys, pressedKeys) + + keyRelease(data.key) + // Popup receives the key release event if it has an exit transition, but + // not if it has been immediately closed on press, without a transition. + // ### TODO: Should Popup somehow always block the key release event? + if (!control.popup.exit) + ++releasedKeys + compare(container.releasedKeys, releasedKeys) + + tryCompare(control.popup, "visible", false) + verify(control.activeFocus) + + // popup not visible -> propagates + keyPress(data.key) + compare(container.pressedKeys, ++pressedKeys) + compare(container.lastPressedKey, data.key) + + keyRelease(data.key) + compare(container.releasedKeys, ++releasedKeys) + compare(container.lastReleasedKey, data.key) + } } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 9ff01e40..3106b22f 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1358,7 +1358,7 @@ TestCase { Shortcut { id: shortcut - sequence: "Tab" + sequence: "A" onActivated: popup.visible = !popup.visible } } @@ -1376,11 +1376,11 @@ TestCase { verify(shortcutActivatedSpy.valid) waitForRendering(window.contentItem) - keyClick(Qt.Key_Tab) + keyClick(Qt.Key_A) compare(shortcutActivatedSpy.count, 1) tryCompare(control, "visible", true) - keyClick(Qt.Key_Tab) + keyClick(Qt.Key_A) compare(shortcutActivatedSpy.count, 2) tryCompare(control, "visible", false) } |