aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-04 16:03:14 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-07 10:00:07 +0000
commit28a94cd2d48c97b813265367a163544ac26c2063 (patch)
treecd6fb429d96865cb7f716ba9e52fd5617a9ed1c3 /tests
parent6e53de99b0d75063a6892f64f2e0d9f6a3105375 (diff)
ComboBox: fix activation
The highlighted index is always -1 when the popup is hidden. Thus, when pressing enter/return, it should only activate the highlighted index when the popup is visible to avoid setting the current index to -1. Change-Id: I7a66e347bf2e4b62a67eb39b119ca1de299f16ef Task-number: QTBUG-51645 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_combobox.qml35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index b112f20c..901b2424 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -717,4 +717,39 @@ TestCase {
control.destroy()
}
+
+ function test_activation_data() {
+ return [
+ { tag: "open:enter", key: Qt.Key_Enter, open: true },
+ { tag: "open:return", key: Qt.Key_Return, open: true },
+ { tag: "closed:enter", key: Qt.Key_Enter, open: false },
+ { tag: "closed:return", key: Qt.Key_Return, open: false }
+ ]
+ }
+
+ // QTBUG-51645
+ function test_activation(data) {
+ var control = comboBox.createObject(window.contentItem, {currentIndex: 1, model: ["Apple", "Orange", "Banana"]})
+ verify(control)
+
+ waitForRendering(control)
+ control.forceActiveFocus()
+ verify(control.activeFocus)
+
+ if (data.open)
+ keyClick(Qt.Key_Space)
+ compare(control.popup.visible, data.open)
+
+ compare(control.currentIndex, 1)
+ compare(control.currentText, "Orange")
+ compare(control.displayText, "Orange")
+
+ keyClick(data.key)
+
+ compare(control.currentIndex, 1)
+ compare(control.currentText, "Orange")
+ compare(control.displayText, "Orange")
+
+ control.destroy()
+ }
}