diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-29 10:46:00 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-29 10:46:00 (GMT) |
commit | d406a899943c6d56d921bc290a009415a3c4eba5 (patch) | |
tree | c48f12180910251b4572cb3600a72332ff5f34f5 /tests/auto/declarative/qmlecmascript | |
parent | 696b55195f1ad40a077683dbc533c73baf1536ee (diff) | |
download | Qt-d406a899943c6d56d921bc290a009415a3c4eba5.zip Qt-d406a899943c6d56d921bc290a009415a3c4eba5.tar.gz Qt-d406a899943c6d56d921bc290a009415a3c4eba5.tar.bz2 |
Support array-literal Script::source values
Diffstat (limited to 'tests/auto/declarative/qmlecmascript')
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" |