aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_combobox.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/controls/data/tst_combobox.qml')
-rw-r--r--tests/auto/controls/data/tst_combobox.qml49
1 files changed, 46 insertions, 3 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index d74c52aa..55ac3e8d 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -69,7 +69,7 @@ TestCase {
id: comboBox
ComboBox {
delegate: ItemDelegate {
- width: parent.width
+ width: popup.width
}
}
}
@@ -137,6 +137,36 @@ TestCase {
control.destroy()
}
+ function test_objects() {
+ var control = comboBox.createObject(window.contentItem)
+ verify(control)
+
+ var items = [
+ { text: "Apple" },
+ { text: "Orange" },
+ { text: "Banana" }
+ ]
+
+ control.model = items
+ compare(control.model, items)
+
+ compare(control.count, 3)
+ compare(control.currentIndex, 0)
+ compare(control.currentText, "Apple")
+
+ control.currentIndex = 2
+ compare(control.currentIndex, 2)
+ compare(control.currentText, "Banana")
+
+ control.model = null
+ compare(control.model, null)
+ compare(control.count, 0)
+ compare(control.currentIndex, -1)
+ compare(control.currentText, "")
+
+ control.destroy()
+ }
+
function test_number() {
var control = comboBox.createObject(window.contentItem)
verify(control)
@@ -201,11 +231,24 @@ TestCase {
ListElement { name: "Banana"; color: "yellow" }
}
- function test_textRole() {
+ property var fruitarray: [
+ { name: "Apple", color: "red" },
+ { name: "Orange", color: "orange" },
+ { name: "Banana", color: "yellow" }
+ ]
+
+ function test_textRole_data() {
+ return [
+ { tag: "ListModel", model: fruitmodel },
+ { tag: "ObjectArray", model: fruitarray }
+ ]
+ }
+
+ function test_textRole(data) {
var control = comboBox.createObject(window.contentItem)
verify(control)
- control.model = fruitmodel
+ control.model = data.model
compare(control.count, 3)
compare(control.currentIndex, 0)
compare(control.currentText, "")