aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qtquick1/qdeclarativelistmodel/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtquick1/qdeclarativelistmodel/data')
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml24
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml22
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml25
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/script.js13
-rw-r--r--tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml20
5 files changed, 104 insertions, 0 deletions
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml
new file mode 100644
index 0000000000..93697f3307
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+Item {
+ property string result
+
+ ListModel {
+ id: model
+
+ ListElement {
+ val1: 1
+ val2: 2
+ val3: "str"
+ val4: false
+ val5: true
+ }
+ }
+
+ Component.onCompleted: {
+ var element = model.get(0);
+
+ for (var i in element)
+ result += i+"="+element[i]+(element[i] ? "Y" : "N")+":";
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml
new file mode 100644
index 0000000000..bfd547ed32
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.0
+
+Item {
+ id: item
+ property variant model
+ property bool done: false
+ property variant result
+
+ function evalExpressionViaWorker(commands) {
+ done = false
+ worker.sendMessage({'commands': commands, 'model': model})
+ }
+
+ WorkerScript {
+ id: worker
+ source: "script.js"
+ onMessage: {
+ item.result = messageObject.result
+ item.done = true
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml
new file mode 100644
index 0000000000..cc6d9de8a0
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml
@@ -0,0 +1,25 @@
+import QtQuick 1.0
+ListView {
+ width: 100
+ height: 250
+ delegate: Rectangle {
+ width: 100
+ height: 50
+ color: black ? "black": "white"
+ }
+ model: ListModel {
+ objectName: "listModel"
+ ListElement {
+ black: false
+ rounded: false
+ }
+ ListElement {
+ black: true
+ rounded: false
+ }
+ ListElement {
+ black: true
+ rounded: false
+ }
+ }
+}
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js
new file mode 100644
index 0000000000..66a4acb8a8
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js
@@ -0,0 +1,13 @@
+WorkerScript.onMessage = function(msg) {
+ var result = null
+ try {
+ for (var i=0; i<msg.commands.length; i++) {
+ var c = 'msg.model.' + msg.commands[i]
+ result = eval(c)
+ }
+ msg.model.sync()
+ } catch(e) { }
+ WorkerScript.sendMessage({'done': true, 'result': result})
+}
+
+
diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml
new file mode 100644
index 0000000000..ffe417ae2a
--- /dev/null
+++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/setmodelcachelist.qml
@@ -0,0 +1,20 @@
+import QtQuick 1.0
+
+ListModel {
+ id: model
+ property bool ok : false
+
+ Component.onCompleted: {
+ model.append({"attrs": []})
+ model.get(0)
+ model.set(0, {"attrs": [{'abc': 123, 'def': 456}] } )
+ ok = ( model.get(0).attrs.get(0).abc == 123
+ && model.get(0).attrs.get(0).def == 456 )
+
+ model.set(0, {"attrs": [{'abc': 789, 'def': 101}] } )
+ ok = ( model.get(0).attrs.get(0).abc == 789
+ && model.get(0).attrs.get(0).def == 101 )
+
+ }
+}
+