From d3967bfdedd8a4a27804690043c1b8d4d8066334 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 18 Apr 2018 15:21:57 +0200 Subject: Popup::test_shortcut(): use "A" instead of "Tab" for shortcut The recently merged stabilization patch showed that the shortcut isn't delivered, and the logs show some focus stuff going on before it fails. If the flakiness is related to focus handling as a result of the tab press, we can try a different key. Change-Id: I6094f11de9d938fd18ad5af8b39b0a1489443638 Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_popup.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 2a6d585c..559e3b59 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -1287,7 +1287,7 @@ TestCase { Shortcut { id: shortcut - sequence: "Tab" + sequence: "A" onActivated: popup.visible = !popup.visible } } @@ -1305,11 +1305,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) } -- cgit v1.2.3 From ec0ad4ca9207acbc524a109ffbacb6cbb0fa18a8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 12:45:24 +0200 Subject: ComboBox: reset when hidden Close the popup and reset the pressed state. Same as in focusOutEvent(). Task-number: QTBUG-67684 Change-Id: I51143175b0f90f3edd116723481faed6ac6e7988 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_combobox.qml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 22b36725..801712be 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() { -- cgit v1.2.3 From def92f7b657ee9247beffffcb0cadd1eca8be3c6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 14:05:25 +0200 Subject: ComboBox: don't block the escape/back key Accept Key_Escape or Key_Back only if it actually close the popup. If the popup is not visible, the key is not handled, and the event should therefore propagate (and potentially close the app on Android). Change-Id: Ibdb0cab8e0ac47005c5112f7ca4882288f1f5a17 Task-number: QTBUG-67684 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_combobox.qml | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 801712be..7f8bc4e8 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -1600,4 +1600,75 @@ 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) + + // popup not visible -> propagates + keyPress(data.key) + compare(container.pressedKeys, 1) + compare(container.lastPressedKey, data.key) + + keyRelease(data.key) + compare(container.releasedKeys, 1) + 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, 1) + + keyRelease(data.key) + compare(container.releasedKeys, 2) // ### TODO: should Popup block the key release? + + verify(control.activeFocus) + + // popup not visible -> propagates + keyPress(data.key) + compare(container.pressedKeys, 2) + compare(container.lastPressedKey, data.key) + + keyRelease(data.key) + compare(container.releasedKeys, 3) + compare(container.lastReleasedKey, data.key) + } } -- cgit v1.2.3 From 110b7187cef4a920423e860ef0e10f819c283fa2 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 24 Apr 2018 22:24:14 +0200 Subject: Revert "ComboBox: don't block the escape/back key" This change got integrated by sick COIN. This reverts commit def92f7b657ee9247beffffcb0cadd1eca8be3c6. Task-number: QTBUG-67930 Change-Id: I541579d7112ba386b227b7892d4e0aa8e2bd4edf Reviewed-by: J-P Nurmi --- tests/auto/controls/data/tst_combobox.qml | 71 ------------------------------- 1 file changed, 71 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 7f8bc4e8..801712be 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -1600,75 +1600,4 @@ 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) - - // popup not visible -> propagates - keyPress(data.key) - compare(container.pressedKeys, 1) - compare(container.lastPressedKey, data.key) - - keyRelease(data.key) - compare(container.releasedKeys, 1) - 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, 1) - - keyRelease(data.key) - compare(container.releasedKeys, 2) // ### TODO: should Popup block the key release? - - verify(control.activeFocus) - - // popup not visible -> propagates - keyPress(data.key) - compare(container.pressedKeys, 2) - compare(container.lastPressedKey, data.key) - - keyRelease(data.key) - compare(container.releasedKeys, 3) - compare(container.lastReleasedKey, data.key) - } } -- cgit v1.2.3 From bc93333958e469e2bd79319befb23328a9de38a9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 14:05:25 +0200 Subject: ComboBox: don't block the escape/back key (with fixed test) Accept Key_Escape or Key_Back only if it actually close the popup. If the popup is not visible, the key is not handled, and the event should therefore propagate (and potentially close the app on Android). Note: def92f7 had a broken test (didn't take the popup exit transition into account) and thus, blocked the CI and got rejected in 110b718. Task-number: QTBUG-67684 Change-Id: I46b4731b3006721f3737cf909fbd97331ac6d8ed Reviewed-by: Liang Qi Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_combobox.qml | 80 +++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 801712be..8e8f9c2f 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -1600,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) + } } -- cgit v1.2.3