diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-01 23:02:43 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-02 12:49:15 +0000 |
commit | 4fb88d0f34e030223c75fc8903ef5d8325b649ed (patch) | |
tree | a691bdb06464050fce11ba8a5a9a04a4a91b5b64 /tests/auto/controls/data/tst_combobox.qml | |
parent | bfaa08a335f21e6fdf533969779f806883fe27b0 (diff) |
Fix ComboBox to scroll to the highlighted item
Change-Id: I57fefd8ba47796118e71902c6882e9918d462920
Tasl-number: QTBUG-55030
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_combobox.qml')
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 29bf62c8..479b1002 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -62,7 +62,17 @@ TestCase { } Component { + id: signalSpy + SignalSpy { } + } + + Component { id: comboBox + ComboBox { } + } + + Component { + id: emptyBox ComboBox { delegate: ItemDelegate { width: popup.width @@ -130,7 +140,7 @@ TestCase { } function test_objects() { - var control = comboBox.createObject(testCase) + var control = emptyBox.createObject(testCase) verify(control) var items = [ @@ -237,7 +247,7 @@ TestCase { } function test_textRole(data) { - var control = comboBox.createObject(testCase) + var control = emptyBox.createObject(testCase) verify(control) control.model = data.model @@ -442,7 +452,7 @@ TestCase { keyClick(Qt.Key_Space) compare(control.currentIndex, 1) - compare(control.highlightedIndex, -1) + tryCompare(control, "highlightedIndex", -1) control.destroy() } @@ -860,4 +870,51 @@ TestCase { control.destroy() } + + // QTBUG-55030 + function test_highlightRange() { + var control = comboBox.createObject(testCase, {model: 100}) + verify(control) + + control.currentIndex = 50 + compare(control.currentIndex, 50) + compare(control.highlightedIndex, -1) + + var openedSpy = signalSpy.createObject(control, {target: control.popup, signalName: "opened"}) + verify(openedSpy.valid) + + control.popup.open() + compare(control.highlightedIndex, 50) + tryCompare(openedSpy, "count", 1) + + var listview = control.popup.contentItem + verify(listview) + + var first = listview.itemAt(0, listview.contentY) + verify(first) + compare(first.text, "50") + + var closedSpy = signalSpy.createObject(control, {target: control.popup, signalName: "closed"}) + verify(closedSpy.valid) + + control.popup.close() + tryCompare(closedSpy, "count", 1) + compare(control.highlightedIndex, -1) + + control.currentIndex = 99 + compare(control.currentIndex, 99) + compare(control.highlightedIndex, -1) + + control.popup.open() + compare(control.highlightedIndex, 99) + tryCompare(openedSpy, "count", 2) + + var last = listview.itemAt(0, listview.contentY + listview.height - 1) + verify(last) + compare(last.text, "99") + + openedSpy.target = null + closedSpy.target = null + control.destroy() + } } |