summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-03-16 13:09:21 +1000
committerMartin Jones <martin.jones@nokia.com>2011-03-16 16:36:25 +1000
commit234a4b614e30ec2ad3e161c0dcd4d339182ff9ec (patch)
tree7b3dc807cda77141bd1e20901249dd2adf92cd98 /tests/auto
parent733578aec105c2d2bdb3f6ef57ee3195ebb79696 (diff)
Qt.include() used in WorkerScript is broken on Windows.
The script local filename was used to resolve the source URL rather than the script URL. Change-Id: I78aa23eadbd76e100bb872b6ac9459aa9a5ee5ce Task-number: QTBUG-17977 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/Global.js1
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp19
4 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
new file mode 100644
index 0000000000..6bdb4a56b9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
@@ -0,0 +1 @@
+var data = "World"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
new file mode 100644
index 0000000000..0385d91170
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
@@ -0,0 +1,5 @@
+WorkerScript.onMessage = function(msg) {
+ var res = Qt.include("Global.js");
+ WorkerScript.sendMessage(msg + " " + data)
+}
+
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
new file mode 100644
index 0000000000..595cb2b552
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
@@ -0,0 +1,5 @@
+import QtQuick 1.0
+
+BaseWorker {
+ source: "script_include.js"
+}
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 4b922fb9fb..b64e10c50d 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -79,6 +79,7 @@ private slots:
void messaging_sendQObjectList();
void messaging_sendJsObject();
void script_with_pragma();
+ void script_included();
void scriptError_onLoad();
void scriptError_onCall();
@@ -226,6 +227,24 @@ void tst_QDeclarativeWorkerScript::script_with_pragma()
delete worker;
}
+void tst_QDeclarativeWorkerScript::script_included()
+{
+ QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_include.qml");
+ QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QString value("Hello");
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
+
+ qApp->processEvents();
+ delete worker;
+}
+
static QString qdeclarativeworkerscript_lastWarning;
static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg)
{