summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlecmascript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qmlecmascript')
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.1.qml11
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.2.js8
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.2.qml11
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.3.qml13
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.4.qml15
-rw-r--r--tests/auto/declarative/qmlecmascript/data/externalScript.js6
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp48
7 files changed, 112 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml b/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml
new file mode 100644
index 0000000..2ac7b6e
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.1.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+QtObject {
+ property int test: external_script_func();
+
+ Script {
+ // Single source as non-array literal
+ source: "externalScript.js"
+ }
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.js b/tests/auto/declarative/qmlecmascript/data/externalScript.2.js
new file mode 100644
index 0000000..78c3a86
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.2.js
@@ -0,0 +1,8 @@
+function external_script_func2() {
+ return a;
+}
+
+function is_a_undefined() {
+ return a == undefined;
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml b/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml
new file mode 100644
index 0000000..dec657c
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.2.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+QtObject {
+ property int test: external_script_func();
+
+ Script {
+ // Single source as array
+ source: [ "externalScript.js" ]
+ }
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml b/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml
new file mode 100644
index 0000000..d7acf38
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.3.qml
@@ -0,0 +1,13 @@
+import Qt 4.6
+
+QtObject {
+ property int test: external_script_func();
+ property int test2: external_script_func2();
+ property bool test3: is_a_undefined();
+
+ Script {
+ // Multiple script
+ source: [ "externalScript.js", "externalScript.2.js" ]
+ }
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml b/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml
new file mode 100644
index 0000000..16211aa
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.4.qml
@@ -0,0 +1,15 @@
+import Qt 4.6
+
+QtObject {
+ property int test: external_script_func();
+ property bool test2: is_a_undefined();
+
+ // Disconnected scripts
+ Script {
+ source: "externalScript.js"
+ }
+
+ Script {
+ source: "externalScript.2.js"
+ }
+}
diff --git a/tests/auto/declarative/qmlecmascript/data/externalScript.js b/tests/auto/declarative/qmlecmascript/data/externalScript.js
new file mode 100644
index 0000000..8928652
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/externalScript.js
@@ -0,0 +1,6 @@
+var a = 92;
+
+function external_script_func() {
+ return a;
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index fe3ae6b..fb8bfb3 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -108,6 +108,7 @@ private slots:
void exceptionClearsOnReeval();
void transientErrors();
void shutdownErrors();
+ void externalScript();
private:
QmlEngine engine;
@@ -946,6 +947,53 @@ void tst_qmlecmascript::shutdownErrors()
QCOMPARE(transientErrorsMsgCount, 0);
}
+// Check that Script::source property works as expected
+void tst_qmlecmascript::externalScript()
+{
+ {
+ QmlComponent component(&engine, TEST_FILE("externalScript.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("externalScript.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("externalScript.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toInt(), 92);
+ QCOMPARE(object->property("test3").toBool(), false);
+
+ delete object;
+ }
+
+ {
+ QmlComponent component(&engine, TEST_FILE("externalScript.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+}
+
QTEST_MAIN(tst_qmlecmascript)
#include "tst_qmlecmascript.moc"