diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-04 15:46:48 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-05 19:48:26 +0100 |
commit | 37019a96db01b99a76b67b9e655bc457e8edb5a1 (patch) | |
tree | a8979cda9124b77ad28211750612e2b31f4ad344 /tests/auto | |
parent | 1845ae01929cdaf6aa50ae096fe5c249f14b1f18 (diff) |
[new compiler] Fix propagation of imported scripts for anonymous components
We must take the imported scripts from the creation context. Fixes various
errors in Qt Quick Controls.
Change-Id: I336d8ffa0537cefd4eeac15f98bbf1b0a5c784af
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/jsimport/creationContext.qml | 24 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 15 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/creationContext.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/creationContext.qml new file mode 100644 index 0000000000..c4d0c7284c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/creationContext.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 +import "importFour.js" as SomeScript + +Item { + id: root + property bool success: false; + Component { + id: testComponent + Item { + property string valueFromScript: SomeScript.greetingString() + } + } + property Loader loader; + signal loaded + onLoaded: { + success = (loader.item.valueFromScript === SomeScript.greetingString()) + } + Component.onCompleted: { + loader = Qt.createQmlObject("import QtQuick 2.0; Loader {}", this, "dynamic loader") + loader.onLoaded.connect(loaded) + loader.sourceComponent = testComponent + } +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index f9f3ac2d4c..6163628ab5 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -169,6 +169,7 @@ private slots: void singletonTypeResolution(); void importScripts_data(); void importScripts(); + void importCreationContext(); void scarceResources(); void scarceResources_data(); void scarceResources_other(); @@ -4210,6 +4211,20 @@ void tst_qqmlecmascript::importScripts() engine.setImportPathList(importPathList); } +void tst_qqmlecmascript::importCreationContext() +{ + QQmlComponent component(&engine, testFileUrl("jsimport/creationContext.qml")); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + bool success = object->property("success").toBool(); + if (!success) { + QSignalSpy readySpy(object.data(), SIGNAL(loaded())); + readySpy.wait(); + } + success = object->property("success").toBool(); + QVERIFY(success); +} + void tst_qqmlecmascript::scarceResources_other() { /* These tests require knowledge of state, since we test values after |