aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/data/jsimportfail
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto/qml/qqmlecmascript/data/jsimportfail
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/data/jsimportfail')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js13
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js11
11 files changed, 98 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
new file mode 100644
index 0000000000..73193a35a5
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+// This should fail, since if the script does have imports
+// of its own, it should run in its own context.
+
+import "importWithImports.js" as TestImportScoping
+
+QtObject {
+ id: testQtObject
+ property int componentError: TestImportScoping.componentError()
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
new file mode 100644
index 0000000000..ef2fc591b3
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+import "testModuleImport.js" as TestModuleImport
+
+QtObject {
+ property int importedModuleEnumValue: JsQtTest.MyQmlObject.EnumValue3 // should fail - the typenames available in TestModuleImport should not be available in this scope
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
new file mode 100644
index 0000000000..d0c37ad9ba
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+import "testScriptImport.js" as TestScriptImport
+
+QtObject {
+ property string importScriptFunctionValue: TestScriptImport.ImportOneJs.greetingString() // should fail - the context of TestScriptImport is private to TestScriptImport.
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
new file mode 100644
index 0000000000..edd103bd82
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+import "testModuleImport.js" as TestModuleImport
+
+QtObject {
+ id: testQtObject
+ property int importedModuleAttachedPropertyValue: testQtObject.TestModuleImport.JsQtTest.MyQmlObject.value // should fail - the context of TestScriptImport is private to TestScriptImport.
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
new file mode 100644
index 0000000000..28e2026f8d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+import "testScriptImport.js" as TestScriptImport
+
+QtObject {
+ property string importScriptFunctionValue: ImportOneJs.greetingString() // should fail - the typenames in TestScriptImport should not be visible from this scope
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
new file mode 100644
index 0000000000..45fd9c75dd
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
@@ -0,0 +1,7 @@
+function greetingString() {
+ return 'Hello, World!';
+}
+
+function importOneFunction() {
+ return '1';
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
new file mode 100644
index 0000000000..ad0e6946a2
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
@@ -0,0 +1,11 @@
+.pragma library
+
+// .pragma library, so shouldn't inherit imports from any .qml file.
+function importValue() {
+ var i = 3;
+ var errorIsOne = Component.error == 1; // this line should fail.
+ if (errorIsOne == true) {
+ i = i + 4;
+ }
+ return i;
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
new file mode 100644
index 0000000000..6d77ceccb1
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
@@ -0,0 +1,13 @@
+.import "importOne.js" as ImportOne
+
+// This js file has imports, so should not inherit
+// scope from the QML file which includes it.
+
+function componentError() {
+ var i = 3;
+ var errorIsOne = Component.error == 1; // this line should fail.
+ if (errorIsOne == true) {
+ i = i + 4;
+ }
+ return i;
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
new file mode 100644
index 0000000000..f04ce007d8
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+
+import "importPragmaLibrary.js" as ImportPragmaLibrary
+
+QtObject {
+ id: testQtObject
+ property int testValue: ImportPragmaLibrary.importValue()
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
new file mode 100644
index 0000000000..69bc1c9887
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
@@ -0,0 +1,8 @@
+.import Qt.test 1.0 as JsQtTest // test that we can import elements from .js files
+
+function importedAttachedPropertyValue(obj) {
+ return obj.JsQtTest.MyQmlObject.value; // attached property, value = 19.
+}
+
+var importedEnumValue = JsQtTest.MyQmlObject.EnumValue3 // the actual value of this enum value is "2"
+
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
new file mode 100644
index 0000000000..2ecccd8816
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
@@ -0,0 +1,11 @@
+.import "importOne.js" as ImportOneJs // test that we can import scripts from .js files
+
+var greetingText = ImportOneJs.greetingString()
+
+function randomInteger(min, max) {
+ if (max > min) {
+ if (min > 10) return min;
+ return max;
+ }
+ return min;
+}