diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-01-25 17:06:30 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-01-26 08:21:02 +0000 |
commit | 3242a3be7c7cc84e6fcda3e90a7713d9fda16915 (patch) | |
tree | d2cfdbb78ecddfe971aa8c8e8b271c20e6f596e9 /tests/auto | |
parent | 08cbefe5bb7e65ff14f8663eae53d614616f2037 (diff) |
ComboBox: add support for object array
Change-Id: Ia43ba18cfd7ce9f5c4c28e239645320af5ba41e7
Task-number: QTBUG-50141
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index d74c52aa..d4b36b17 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -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, "") |