diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-06-29 12:25:20 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-16 04:46:50 +0200 |
commit | 432a48b8f2d9ebaef1bd7be4a168a45524faaf68 (patch) | |
tree | de7ff211c9e1b3b2bd0156b464bacbfbea475a1d /tests/auto/qml/qqmlecmascript | |
parent | 9bc216f6fa34484bf582cbc3ccd2bb7b45826bc7 (diff) |
Support remote import paths
Probe for installed modules in import path elements which are not local
to the machine. Note that all local paths in the import path list will
be tried before any remote locations are probed.
Task-number: QTBUG-21386
Change-Id: I4f7b9e54e54c1d62a5e7cb7f059ee1e9319ef054
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
5 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js new file mode 100644 index 0000000000..e6e41bc6b2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsModuleRemoteImport.js @@ -0,0 +1,5 @@ +.import com.nokia.JsRemoteModule 1.0 as JsModule + +function importedValue() { + return JsModule.ScriptAPI.greeting(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml new file mode 100644 index 0000000000..4199bb022d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testJsRemoteImport.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +import com.nokia.JsModule 1.0 +import com.nokia.JsModule 1.0 as RenamedModule +import "testJsModuleRemoteImport.js" as TestJsModuleImport + +QtObject { + id: testQtObject + + property string importedScriptStringValue: ScriptAPI.greeting(); + property string renamedScriptStringValue: RenamedModule.ScriptAPI.greeting(); + property string reimportedScriptStringValue: TestJsModuleImport.importedValue(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js b/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js new file mode 100644 index 0000000000..b90033eeb4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/ScriptAPI.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 0 + +function greeting() { return "Hello" } + diff --git a/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir b/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir new file mode 100644 index 0000000000..c33d1e7a0d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/remote/com/nokia/JsRemoteModule/qmldir @@ -0,0 +1 @@ +ScriptAPI 1.0 ScriptAPI.js diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index aaa6d365bd..c7763fcbd4 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3784,6 +3784,17 @@ void tst_qqmlecmascript::importScripts_data() << QVariant(QString("Hello")) << QVariant(QString("Hello"))); + QTest::newRow("import module which exports a script which imports a remote module") + << testFileUrl("jsimport/testJsRemoteImport.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("importedScriptStringValue") + << QLatin1String("renamedScriptStringValue") + << QLatin1String("reimportedScriptStringValue")) + << (QVariantList() << QVariant(QString("Hello")) + << QVariant(QString("Hello")) + << QVariant(QString("Hello"))); + QTest::newRow("malformed import statement") << testFileUrl("jsimportfail/malformedImport.qml") << QString() @@ -3870,6 +3881,15 @@ void tst_qqmlecmascript::importScripts() QFETCH(QStringList, propertyNames); QFETCH(QVariantList, propertyValues); + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory() + "/remote"); + + QStringList importPathList = engine.importPathList(); + + QString remotePath(QLatin1String("http://127.0.0.1:8111/")); + engine.addImportPath(remotePath); + QQmlComponent component(&engine, testfile); if (!errorMessage.isEmpty()) @@ -3879,6 +3899,8 @@ void tst_qqmlecmascript::importScripts() foreach (const QString &warning, warningMessages) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + QTRY_VERIFY(component.isReady()); + QObject *object = component.create(); if (!errorMessage.isEmpty()) { QVERIFY(object == 0); @@ -3888,6 +3910,8 @@ void tst_qqmlecmascript::importScripts() QCOMPARE(object->property(propertyNames.at(i).toLatin1().constData()), propertyValues.at(i)); delete object; } + + engine.setImportPathList(importPathList); } void tst_qqmlecmascript::scarceResources_other() |