aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qquicklistmodelworkerscript/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qquicklistmodelworkerscript/data')
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/model.qml26
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/script.js13
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.js8
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml33
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js9
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml33
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js8
-rw-r--r--tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml32
8 files changed, 162 insertions, 0 deletions
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/model.qml b/tests/auto/qml/qquicklistmodelworkerscript/data/model.qml
new file mode 100644
index 0000000000..5973ea8adf
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/model.qml
@@ -0,0 +1,26 @@
+import QtQuick 2.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
+ }
+ }
+
+ function runEval(js) {
+ eval(js);
+ }
+}
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/script.js b/tests/auto/qml/qquicklistmodelworkerscript/data/script.js
new file mode 100644
index 0000000000..66a4acb8a8
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/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/qml/qquicklistmodelworkerscript/data/workerremoveelement.js b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.js
new file mode 100644
index 0000000000..cb9dfa66aa
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.js
@@ -0,0 +1,8 @@
+WorkerScript.onMessage = function(msg) {
+ if (msg.action == 'removeItem') {
+ msg.model.remove(0);
+ } else if (msg.action == 'dosync') {
+ msg.model.sync();
+ }
+ WorkerScript.sendMessage({'done': true})
+}
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml
new file mode 100644
index 0000000000..e2361acf6b
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremoveelement.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+
+Item {
+ id: item
+ property variant model
+ property bool done: false
+
+ WorkerScript {
+ id: worker
+ source: "workerremoveelement.js"
+ onMessage: {
+ item.done = true
+ }
+ }
+
+ function addItem() {
+ model.append({ 'data': 1 });
+
+ var element = model.get(0);
+ }
+
+ function removeItemViaWorker() {
+ done = false
+ var msg = { 'action': 'removeItem', 'model': model }
+ worker.sendMessage(msg);
+ }
+
+ function doSync() {
+ done = false
+ var msg = { 'action': 'dosync', 'model': model }
+ worker.sendMessage(msg);
+ }
+}
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js
new file mode 100644
index 0000000000..f63dd68839
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.js
@@ -0,0 +1,9 @@
+WorkerScript.onMessage = function(msg) {
+ if (msg.action == 'removeList') {
+ msg.model.remove(0);
+ } else if (msg.action == 'dosync') {
+ msg.model.sync();
+ }
+ WorkerScript.sendMessage({'done': true})
+}
+
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml
new file mode 100644
index 0000000000..bdb5e024d8
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workerremovelist.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+
+Item {
+ id: item
+ property variant model
+ property bool done: false
+
+ WorkerScript {
+ id: worker
+ source: "workerremovelist.js"
+ onMessage: {
+ item.done = true
+ }
+ }
+
+ function addList() {
+ model.append({ 'data': [ { 'subData': 1 } ] });
+
+ var element = model.get(0);
+ }
+
+ function removeListViaWorker() {
+ done = false
+ var msg = { 'action': 'removeList', 'model': model }
+ worker.sendMessage(msg);
+ }
+
+ function doSync() {
+ done = false
+ var msg = { 'action': 'dosync', 'model': model }
+ worker.sendMessage(msg);
+ }
+}
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js b/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js
new file mode 100644
index 0000000000..9b8d8fa7f3
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.js
@@ -0,0 +1,8 @@
+WorkerScript.onMessage = function(msg) {
+ if (msg.action == 'addItem') {
+ msg.model.get(0).level0.append({ 'level1': 33 });
+ } else if (msg.action == 'dosync') {
+ msg.model.sync();
+ }
+ WorkerScript.sendMessage({'done': true})
+}
diff --git a/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml b/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml
new file mode 100644
index 0000000000..c21cd43e7e
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodelworkerscript/data/workersync.qml
@@ -0,0 +1,32 @@
+import QtQuick 2.0
+
+Item {
+ id: item
+ property variant model
+ property bool done: false
+
+ WorkerScript {
+ id: worker
+ source: "workersync.js"
+ onMessage: {
+ item.done = true
+ }
+ }
+
+ function addItem0() {
+ model.append({ 'level0': [ { 'level1': 29 } ] });
+ model.append({ 'level0': [ { 'level1': 37 } ] });
+ }
+
+ function addItemViaWorker() {
+ done = false
+ var msg = { 'action': 'addItem', 'model': model }
+ worker.sendMessage(msg);
+ }
+
+ function doSync() {
+ done = false
+ var msg = { 'action': 'dosync', 'model': model }
+ worker.sendMessage(msg);
+ }
+}