aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGlenn Watson <glenn.watson@nokia.com>2012-07-24 11:41:50 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-08 07:55:19 +0200
commit6ebf215fdaf2d757ab90ae4d46c4b938e978e2dc (patch)
tree515da352f1cc4d5567b6d93f0b19952b2e27d705 /tests
parent92562eacbc3c614a83a734f1108ed7df02415eae (diff)
Add type name to singleton (module api) implementations.
This change renames the previous module api implementation to singleton types. When a singleton type is registered, a type name must be provided that is used when accessing the API from QML. This makes the implementation more consistent with the rest of QML. Task-number: QTBUG-26549 Change-Id: Iab0bb1ccf516bd3ae20aee562a64d22976e0aecd Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/DeleteRootObjectInCreationComponentBase.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/HRMDPComponent.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/OnDestructionComponent.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/QQmlDataDestroyedComponent2Base.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SignalEmittedComponent.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/fallbackBindings.3.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/fallbackBindings.4.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.2.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.3.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importSingletonType.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportSingletonType.qml (renamed from tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml)2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml21
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml30
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml32
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml12
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml12
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonType.qml21
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeCaching.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeEnums.qml8
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeNoQualifier.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeWriting.qml30
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonType.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeCaching.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeNoQualifier.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeWriting.qml32
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeImportOrder.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMajorVersionFail.qml (renamed from tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml)4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMinorVersionFail.qml (renamed from tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml)4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeResolution.qml17
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp52
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h15
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp159
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/changeversion.js6
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation-a.js4
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-a.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-b.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-creation.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly-error.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen1.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen2.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js2
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection.js2
-rw-r--r--tests/auto/qml/qquickconnection/data/singletontype-target.qml (renamed from tests/auto/qml/qquickconnection/data/moduleapi-target.qml)6
-rw-r--r--tests/auto/qml/qquickconnection/tst_qquickconnection.cpp18
-rw-r--r--tests/auto/qml/v4/data/singletonType.qml (renamed from tests/auto/qml/v4/data/moduleApi.qml)4
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp18
-rw-r--r--tests/benchmarks/qml/holistic/testtypes.cpp14
59 files changed, 438 insertions, 239 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/DeleteRootObjectInCreationComponentBase.qml b/tests/auto/qml/qqmlecmascript/data/DeleteRootObjectInCreationComponentBase.qml
index ce542d3dbd..1d5dbe88d5 100644
--- a/tests/auto/qml/qqmlecmascript/data/DeleteRootObjectInCreationComponentBase.qml
+++ b/tests/auto/qml/qqmlecmascript/data/DeleteRootObjectInCreationComponentBase.qml
@@ -6,9 +6,9 @@ Rectangle {
color: "red"
function flipOwnership() {
- ModApi.trackObject(base);
- ModApi.trackedObject(); // flip the ownership.
- if (!ModApi.trackedObjectHasJsOwnership())
+ ModApi.QObject.trackObject(base);
+ ModApi.QObject.trackedObject(); // flip the ownership.
+ if (!ModApi.QObject.trackedObjectHasJsOwnership())
derived.testConditionsMet = false;
else
derived.testConditionsMet = true;
diff --git a/tests/auto/qml/qqmlecmascript/data/HRMDPComponent.qml b/tests/auto/qml/qqmlecmascript/data/HRMDPComponent.qml
index 897fd990ec..fab55fa0d1 100644
--- a/tests/auto/qml/qqmlecmascript/data/HRMDPComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/HRMDPComponent.qml
@@ -6,10 +6,10 @@ Item {
property var varCanary: 12
Component.onCompleted: {
- QObjectApi.qobjectTestWritableProperty = 42;
+ QObjectApi.QObject.qobjectTestWritableProperty = 42;
}
Component.onDestruction: {
- QObjectApi.qobjectTestWritableProperty = 43;
+ QObjectApi.QObject.qobjectTestWritableProperty = 43;
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/OnDestructionComponent.qml b/tests/auto/qml/qqmlecmascript/data/OnDestructionComponent.qml
index dcf46725cd..76e0ec3793 100644
--- a/tests/auto/qml/qqmlecmascript/data/OnDestructionComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/OnDestructionComponent.qml
@@ -5,5 +5,5 @@ Item {
id: sec
property int a: 10
- Component.onDestruction: ModApi.setSpecificProperty(sec, "a", 20);
+ Component.onDestruction: ModApi.QObject.setSpecificProperty(sec, "a", 20);
}
diff --git a/tests/auto/qml/qqmlecmascript/data/QQmlDataDestroyedComponent2Base.qml b/tests/auto/qml/qqmlecmascript/data/QQmlDataDestroyedComponent2Base.qml
index 486e88a9e3..a93fe69ef3 100644
--- a/tests/auto/qml/qqmlecmascript/data/QQmlDataDestroyedComponent2Base.qml
+++ b/tests/auto/qml/qqmlecmascript/data/QQmlDataDestroyedComponent2Base.qml
@@ -8,9 +8,9 @@ Rectangle {
property bool testConditionsMet: false
onXChanged: {
- ModApi.trackObject(base);
- ModApi.trackedObject(); // flip the ownership.
- if (!ModApi.trackedObjectHasJsOwnership())
+ ModApi.QObject.trackObject(base);
+ ModApi.QObject.trackedObject(); // flip the ownership.
+ if (!ModApi.QObject.trackedObjectHasJsOwnership())
testConditionsMet = false;
else
testConditionsMet = true;
diff --git a/tests/auto/qml/qqmlecmascript/data/SignalEmittedComponent.qml b/tests/auto/qml/qqmlecmascript/data/SignalEmittedComponent.qml
index a7866a33fb..a291e7b275 100644
--- a/tests/auto/qml/qqmlecmascript/data/SignalEmittedComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/SignalEmittedComponent.qml
@@ -5,7 +5,7 @@ Item {
id: sec
property int a: 10
Component.onDestruction: {
- ModApi.setSpecificProperty(sec, "a", 20);
+ ModApi.QObject.setSpecificProperty(sec, "a", 20);
}
function setSuccessPropertyOf(obj, val) {
diff --git a/tests/auto/qml/qqmlecmascript/data/fallbackBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/fallbackBindings.3.qml
index 4080b8dcdf..ee7a7e8448 100644
--- a/tests/auto/qml/qqmlecmascript/data/fallbackBindings.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/fallbackBindings.3.qml
@@ -1,9 +1,9 @@
import QtQuick 2.0
-import Qt.test.fallbackBindingsObject 1.0 as ModuleAPI
+import Qt.test.fallbackBindingsObject 1.0 as SingletonType
Item {
property bool success: false
- property string foo: ModuleAPI.test
+ property string foo: SingletonType.Fallback.test
Component.onCompleted: success = (foo == '100')
}
diff --git a/tests/auto/qml/qqmlecmascript/data/fallbackBindings.4.qml b/tests/auto/qml/qqmlecmascript/data/fallbackBindings.4.qml
index b7bd294c9f..1a6c694bf7 100644
--- a/tests/auto/qml/qqmlecmascript/data/fallbackBindings.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/fallbackBindings.4.qml
@@ -1,9 +1,9 @@
import QtQuick 2.0
-import Qt.test.fallbackBindingsDerived 1.0 as ModuleAPI
+import Qt.test.fallbackBindingsDerived 1.0 as SingletonType
Item {
property bool success: false
- property string foo: ModuleAPI.test
+ property string foo: SingletonType.Fallback.test
Component.onCompleted: success = (foo == 'hello')
}
diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.2.qml
index 00f09e159c..83eecf1703 100644
--- a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.2.qml
@@ -16,7 +16,7 @@ Item {
if (testProp == null) success = false; // should not have triggered delete notify / zeroed testProp value
if (testProp.variantCanary != 5) success = false; // should not have deleted vmemo of object referenced by testProp
if (testProp.varCanary != 12) success = false; // should not have collected vmemo vmeProperties
- if (QObjectApi.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
}
// then we remove the reference.
@@ -26,6 +26,6 @@ Item {
// after a gc (and deferred deletion process) the object should be gone
function ensureDeletion() {
- if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.3.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.3.qml
index 57fee6384b..6eaa54a8dc 100644
--- a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.3.qml
@@ -16,13 +16,13 @@ Item {
if (testProp == null) success = false; // should not have triggered delete notify / zeroed testProp value
if (testProp.variantCanary != 5) success = false; // should not have deleted vmemo of object referenced by testProp
if (testProp.varCanary != 12) success = false; // should not have collected vmemo vmeProperties
- if (QObjectApi.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
}
// then we manually delete the item being referenced
function manuallyDelete() {
- QObjectApi.deleteQObject(testProp);
- if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
+ QObjectApi.QObject.deleteQObject(testProp);
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
}
// after a gc (and deferred deletion process) the object should be gone
diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml
index 30dd4bcaea..be914fa676 100644
--- a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.dynprop.qml
@@ -16,7 +16,7 @@ Item {
if (testProp == null) success = false; // should not have triggered delete notify / zeroed testProp value
if (testProp.variantCanary != 5) success = false; // should not have deleted vmemo of object referenced by testProp
if (testProp.varCanary != 12) success = false; // should not have collected vmemo vmeProperties
- if (QObjectApi.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 42) success = false; // should not have been set to 43.
}
// then we remove the reference.
@@ -26,6 +26,6 @@ Item {
// after a gc (and deferred deletion process) the object should be gone
function ensureDeletion() {
- if (QObjectApi.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
+ if (QObjectApi.QObject.qobjectTestWritableProperty != 43) success = false; // should have been set to 43.
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
deleted file mode 100644
index 7a4f434665..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
+++ /dev/null
@@ -1,5 +0,0 @@
-.import Qt.test 1.0 as QObjectModuleApi
-
-function testFunc() {
- return QObjectModuleApi.qobjectTestProperty
-}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importSingletonType.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importSingletonType.js
new file mode 100644
index 0000000000..6c53a0c47d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importSingletonType.js
@@ -0,0 +1,5 @@
+.import Qt.test 1.0 as QObjectSingletonType
+
+function testFunc() {
+ return QObjectSingletonType.QObject.qobjectTestProperty
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportSingletonType.qml
index b3e545dd7c..f817fbf135 100644
--- a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportSingletonType.qml
@@ -1,5 +1,5 @@
import QtQuick 2.0
-import "importModuleApi.js" as Script
+import "importSingletonType.js" as Script
Item {
property variant testValue: 5
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
deleted file mode 100644
index 718a64652d..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
+++ /dev/null
@@ -1,21 +0,0 @@
-import QtQuick 2.0
-
-import Qt.test 1.0 as QtTest // module API installed into existing uri
-import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject module API installed into new uri
-import Qt.test.qobjectApi 1.3 as QtTestMinorVersionQObjectApi // qobject module API installed into existing uri with new minor version
-import Qt.test.qobjectApi 2.0 as QtTestMajorVersionQObjectApi // qobject module API installed into existing uri with new major version
-import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) module API installed into a new uri
-
-QtObject {
- property int existingUriTest: QtTest.qobjectTestProperty
- property int qobjectTest: QtTestQObjectApi.qobjectTestProperty
- property int qobjectMethodTest: 2
- property int qobjectMinorVersionTest: QtTestMinorVersionQObjectApi.qobjectTestProperty
- property int qobjectMajorVersionTest: QtTestMajorVersionQObjectApi.qobjectTestProperty
- property int qobjectParentedTest: QtTestParentedQObjectApi.qobjectTestProperty
-
- Component.onCompleted: {
- qobjectMethodTest = QtTestQObjectApi.qobjectTestMethod();
- }
-}
-
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
deleted file mode 100644
index 56a55e4e9b..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
+++ /dev/null
@@ -1,10 +0,0 @@
-import QtQuick 2.0
-
-import Qt.test 1.0 as QtTest // module API installed into existing uri
-import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) module API installed into a new uri
-
-QtObject {
- property int existingUriTest: QtTest.qobjectTestProperty
- property int qobjectParentedTest: QtTestParentedQObjectApi.qobjectTestProperty
-}
-
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
deleted file mode 100644
index da5ffd5e76..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 2.0
-import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject module API installed into new uri
-
-QtObject {
- property int enumValue: QtTestQObjectApi.EnumValue2;
- property int enumMethod: QtTestQObjectApi.qobjectEnumTestMethod(QtTestQObjectApi.EnumValue1);
-}
-
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
deleted file mode 100644
index e4a68d14ea..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 2.0
-import Qt.test 1.0 as QtTest // qobject module API installed into existing uri
-
-QtObject {
- property int firstProperty: 1
- property int secondProperty: 2
- property int readOnlyProperty: QtTest.qobjectTestProperty
- property int writableProperty: QtTest.qobjectTestWritableProperty
- property int writableFinalProperty: QtTest.qobjectTestWritableFinalProperty
-
- onFirstPropertyChanged: {
- // In this case, we want to attempt to set the module API property.
- // This should fail, as the module API property is read only.
- if (firstProperty != QtTest.qobjectTestProperty) {
- QtTest.qobjectTestProperty = firstProperty; // should silently fail.
- }
- }
-
- onSecondPropertyChanged: {
- // In this case, we want to attempt to set the module API properties.
- // This should succeed, as the module API properties are writable.
- if (secondProperty != QtTest.qobjectTestWritableProperty) {
- QtTest.qobjectTestWritableProperty = secondProperty; // should succeed.
- }
- if (secondProperty != QtTest.qobjectTestWritableFinalProperty) {
- QtTest.qobjectTestWritableFinalProperty = secondProperty; // should succeed.
- }
- }
-}
-
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
deleted file mode 100644
index 7c4e20489d..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 2.0
-import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri
-
-QtObject {
- property int scriptTest: QtTestScriptApi.scriptTestProperty // script module api's only provide properties.
-}
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
deleted file mode 100644
index 90974b5969..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import QtQuick 2.0
-import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri
-
-QtObject {
- property int scriptTest: QtTestScriptApi.scriptTestProperty
-}
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
deleted file mode 100644
index 02461d59ed..0000000000
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import QtQuick 2.0
-import Qt.test.scriptApi 1.0 as QtTestScriptApi
-import Qt.test.scriptApi 2.0 as QtTestScriptApi2
-
-QtObject {
- property int firstProperty
- property int readBack
-
- property int secondProperty
- property int unchanged
-
- onFirstPropertyChanged: {
- if (QtTestScriptApi.scriptTestProperty != firstProperty) {
- QtTestScriptApi.scriptTestProperty = firstProperty;
- readBack = QtTestScriptApi.scriptTestProperty;
- }
- }
-
- onSecondPropertyChanged: {
- if (QtTestScriptApi2.scriptTestProperty != secondProperty) {
- QtTestScriptApi2.scriptTestProperty = secondProperty;
- unchanged = QtTestScriptApi2.scriptTestProperty;
- }
- }
-
- Component.onCompleted: {
- firstProperty = QtTestScriptApi.scriptTestProperty;
- readBack = QtTestScriptApi.scriptTestProperty;
- secondProperty = QtTestScriptApi2.scriptTestProperty;
- unchanged = QtTestScriptApi2.scriptTestProperty;
- }
-}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml
index ad5807b1cf..1143eaf919 100644
--- a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml
@@ -1,5 +1,5 @@
import QtQuick 2.0
-import Qt.test 1.0 as ModuleApi
+import Qt.test 1.0 as SingletonType
Item {
id: testOwnership
@@ -14,13 +14,13 @@ Item {
return; // failed to create component.
}
o.varprop = true; // causes initialization of varProperties.
- ModuleApi.trackObject(o); // stores QObject ptr
- if (ModuleApi.trackedObject() == null) return; // is still valid, should have a valid v8object.
+ SingletonType.QObject.trackObject(o); // stores QObject ptr
+ if (SingletonType.QObject.trackedObject() == null) return; // is still valid, should have a valid v8object.
o = new Date(); // causes object to be gc-able.
gc(); // collect object's v8object + varProperties, queues deleteLater.
- if (ModuleApi.trackedObject() != null) return; // v8object was previously collected.
- ModuleApi.setTrackedObjectProperty("varprop"); // deferences varProperties of object.
- test = !(ModuleApi.trackedObjectProperty("varprop")); // deferences varProperties of object.
+ if (SingletonType.QObject.trackedObject() != null) return; // v8object was previously collected.
+ SingletonType.QObject.setTrackedObjectProperty("varprop"); // deferences varProperties of object.
+ test = !(SingletonType.QObject.trackedObjectProperty("varprop")); // deferences varProperties of object.
// if we didn't crash, success.
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
index 12598b3b9f..384971b59c 100644
--- a/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
@@ -37,8 +37,8 @@ Item {
property bool enumTypeHasOwnProperty
property bool typenameHasOwnProperty
property bool typenameHasOwnProperty2
- property bool moduleApiTypeHasOwnProperty
- property bool moduleApiPropertyTypeHasOwnProperty
+ property bool singletonTypeTypeHasOwnProperty
+ property bool singletonTypePropertyTypeHasOwnProperty
function testHasOwnPropertySuccess() {
valueTypeHasOwnProperty = !typeObj.pointProperty.hasOwnProperty("nonexistentpropertyname");
valueTypeHasOwnProperty2 = typeObj.pointProperty.hasOwnProperty("x"); // should be true
@@ -50,8 +50,8 @@ Item {
enumTypeHasOwnProperty = !MyTypeObject.EnumVal1.hasOwnProperty("nonexistentpropertyname");
typenameHasOwnProperty = !MyTypeObject.hasOwnProperty("nonexistentpropertyname");
typenameHasOwnProperty2 = MyTypeObject.hasOwnProperty("EnumVal1"); // should be true.
- moduleApiTypeHasOwnProperty = !QtTestQObjectApi.hasOwnProperty("nonexistentpropertyname");
- moduleApiPropertyTypeHasOwnProperty = !QtTestQObjectApi.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname");
+ singletonTypeTypeHasOwnProperty = !QtTestQObjectApi.QObject.hasOwnProperty("nonexistentpropertyname");
+ singletonTypePropertyTypeHasOwnProperty = !QtTestQObjectApi.QObject.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname");
}
property bool enumNonValueHasOwnProperty
@@ -59,9 +59,9 @@ Item {
enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname");
}
- property bool moduleApiNonPropertyHasOwnProperty
+ property bool singletonTypeNonPropertyHasOwnProperty
function testHasOwnPropertyFailureTwo() {
- moduleApiNonPropertyHasOwnProperty = !QtTestQObjectApi.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname");
+ singletonTypeNonPropertyHasOwnProperty = !QtTestQObjectApi.QObject.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname");
}
property bool listAtInvalidHasOwnProperty
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonType.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonType.qml
new file mode 100644
index 0000000000..e0ada559ef
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonType.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+import Qt.test 1.0 as QtTest // singleton Type installed into existing uri
+import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject singleton Type installed into new uri
+import Qt.test.qobjectApi 1.3 as QtTestMinorVersionQObjectApi // qobject singleton Type installed into existing uri with new minor version
+import Qt.test.qobjectApi 2.0 as QtTestMajorVersionQObjectApi // qobject singleton Type installed into existing uri with new major version
+import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) singleton Type installed into a new uri
+
+QtObject {
+ property int existingUriTest: QtTest.QObject.qobjectTestProperty
+ property int qobjectTest: QtTestQObjectApi.QObject.qobjectTestProperty
+ property int qobjectMethodTest: 3
+ property int qobjectMinorVersionTest: QtTestMinorVersionQObjectApi.QObject.qobjectTestProperty
+ property int qobjectMajorVersionTest: QtTestMajorVersionQObjectApi.QObject.qobjectTestProperty
+ property int qobjectParentedTest: QtTestParentedQObjectApi.QObject.qobjectTestProperty
+
+ Component.onCompleted: {
+ qobjectMethodTest = QtTestQObjectApi.QObject.qobjectTestMethod();
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeCaching.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeCaching.qml
new file mode 100644
index 0000000000..03f07db290
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeCaching.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+
+import Qt.test 1.0 as QtTest // singleton Type installed into existing uri
+import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) singleton Type installed into a new uri
+
+QtObject {
+ property int existingUriTest: QtTest.QObject.qobjectTestProperty
+ property int qobjectParentedTest: QtTestParentedQObjectApi.QObject.qobjectTestProperty
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeEnums.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeEnums.qml
new file mode 100644
index 0000000000..2bd14d14a6
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeEnums.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject singleton Type installed into new uri
+
+QtObject {
+ property int enumValue: QtTestQObjectApi.QObject.EnumValue2;
+ property int enumMethod: QtTestQObjectApi.QObject.qobjectEnumTestMethod(QtTestQObjectApi.QObject.EnumValue1);
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeNoQualifier.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeNoQualifier.qml
new file mode 100644
index 0000000000..50a356568e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeNoQualifier.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+QtObject {
+ property int qobjectPropertyTest: QObject.qobjectTestProperty
+ property int qobjectMethodTest: 2
+
+ Component.onCompleted: {
+ qobjectMethodTest = QObject.qobjectTestMethod();
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeWriting.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeWriting.qml
new file mode 100644
index 0000000000..6870027d72
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/qobjectSingletonTypeWriting.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+import Qt.test 1.0 as QtTest // qobject singleton Type installed into existing uri
+
+QtObject {
+ property int firstProperty: 1
+ property int secondProperty: 2
+ property int readOnlyProperty: QtTest.QObject.qobjectTestProperty
+ property int writableProperty: QtTest.QObject.qobjectTestWritableProperty
+ property int writableFinalProperty: QtTest.QObject.qobjectTestWritableFinalProperty
+
+ onFirstPropertyChanged: {
+ // In this case, we want to attempt to set the singleton Type property.
+ // This should fail, as the singleton Type property is read only.
+ if (firstProperty != QtTest.QObject.qobjectTestProperty) {
+ QtTest.QObject.qobjectTestProperty = firstProperty; // should silently fail.
+ }
+ }
+
+ onSecondPropertyChanged: {
+ // In this case, we want to attempt to set the singleton Type properties.
+ // This should succeed, as the singleton Type properties are writable.
+ if (secondProperty != QtTest.QObject.qobjectTestWritableProperty) {
+ QtTest.QObject.qobjectTestWritableProperty = secondProperty; // should succeed.
+ }
+ if (secondProperty != QtTest.QObject.qobjectTestWritableFinalProperty) {
+ QtTest.QObject.qobjectTestWritableFinalProperty = secondProperty; // should succeed.
+ }
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonType.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonType.qml
new file mode 100644
index 0000000000..24b5112224
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonType.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import Qt.test.scriptApi 1.0 as QtTestScriptApi // script singleton Type installed into new uri
+
+QtObject {
+ property int scriptTest: QtTestScriptApi.Script.scriptTestProperty // script singleton type's only provide properties.
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeCaching.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeCaching.qml
new file mode 100644
index 0000000000..287258bdc6
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeCaching.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import Qt.test.scriptApi 1.0 as QtTestScriptApi // script singleton Type installed into new uri
+
+QtObject {
+ property int scriptTest: QtTestScriptApi.Script.scriptTestProperty
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeNoQualifier.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeNoQualifier.qml
new file mode 100644
index 0000000000..13896d9683
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeNoQualifier.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import Qt.test.scriptApi 1.0
+
+QtObject {
+ property int scriptTest: Script.scriptTestProperty // script singleton type's only provide properties.
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeWriting.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeWriting.qml
new file mode 100644
index 0000000000..ba98ea66bb
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/scriptSingletonTypeWriting.qml
@@ -0,0 +1,32 @@
+import QtQuick 2.0
+import Qt.test.scriptApi 1.0 as QtTestScriptApi
+import Qt.test.scriptApi 2.0 as QtTestScriptApi2
+
+QtObject {
+ property int firstProperty
+ property int readBack
+
+ property int secondProperty
+ property int unchanged
+
+ onFirstPropertyChanged: {
+ if (QtTestScriptApi.Script.scriptTestProperty != firstProperty) {
+ QtTestScriptApi.Script.scriptTestProperty = firstProperty;
+ readBack = QtTestScriptApi.Script.scriptTestProperty;
+ }
+ }
+
+ onSecondPropertyChanged: {
+ if (QtTestScriptApi2.Script.scriptTestProperty != secondProperty) {
+ QtTestScriptApi2.Script.scriptTestProperty = secondProperty;
+ unchanged = QtTestScriptApi2.Script.scriptTestProperty;
+ }
+ }
+
+ Component.onCompleted: {
+ firstProperty = QtTestScriptApi.Script.scriptTestProperty;
+ readBack = QtTestScriptApi.Script.scriptTestProperty;
+ secondProperty = QtTestScriptApi2.Script.scriptTestProperty;
+ unchanged = QtTestScriptApi2.Script.scriptTestProperty;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeImportOrder.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeImportOrder.qml
new file mode 100644
index 0000000000..9b0b648b0d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeImportOrder.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+import Qt.test.importOrderApi1 1.0
+import Qt.test.importOrderApi2 1.0
+
+QtObject {
+ property int v: Data.value
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMajorVersionFail.qml
index fb050f65bc..af20f8c77f 100644
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMajorVersionFail.qml
@@ -1,8 +1,8 @@
import QtQuick 2.0
-// this qml file attempts to import an invalid version of a qobject module API.
+// this qml file attempts to import an invalid version of a qobject singleton Type.
-import Qt.test.qobjectApi 4.0 as QtTestMajorVersionQObjectApi // qobject module API installed into existing uri with nonexistent major version
+import Qt.test.qobjectApi 4.0 as QtTestMajorVersionQObjectApi // qobject singleton Type installed into existing uri with nonexistent major version
QtObject {
property int qobjectMajorVersionTest: QtTestMajorVersionQObjectApi.qobjectTestProperty
diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMinorVersionFail.qml
index e06be667f7..04eee77e75 100644
--- a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeMinorVersionFail.qml
@@ -1,8 +1,8 @@
import QtQuick 2.0
-// this qml file attempts to import an invalid version of a qobject module API.
+// this qml file attempts to import an invalid version of a qobject singleton Type.
-import Qt.test.qobjectApi 1.2 as QtTestMinorVersionQObjectApi // qobject module API installed into existing uri with nonexistent minor version
+import Qt.test.qobjectApi 1.2 as QtTestMinorVersionQObjectApi // qobject singleton Type installed into existing uri with nonexistent minor version
QtObject {
property int qobjectMinorVersionTest: QtTestMinorVersionedQObjectApi.qobjectTestProperty
diff --git a/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeResolution.qml b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeResolution.qml
new file mode 100644
index 0000000000..c00a94c529
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/singletontype/singletonTypeResolution.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.0
+import Qt.test.importOrderApi 1.0
+import Qt.test.importOrderApi 1.0 as Namespace
+import NamespaceAndType 1.0
+import NamespaceAndType 1.0 as NamespaceAndType
+
+QtObject {
+ property bool success: false
+
+ Component.onCompleted: {
+ var s0 = Data.value === 37 && Namespace.Data.value === 37 && Data.value === Namespace.Data.value;
+ var s1 = NamespaceAndType.value === NamespaceAndType.NamespaceAndType.value &&
+ NamespaceAndType.value === 37 &&
+ NamespaceAndType.NamespaceAndType.value === 37;
+ success = (s0 === true) && (s1 === true);
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index 77670f74da..9669e371de 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -135,6 +135,33 @@ static QJSValue readonly_script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
return v;
}
+static QObject *testImportOrder_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testImportOrderApi *o = new testImportOrderApi(37);
+ return o;
+}
+
+static QObject *testImportOrder_api1(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testImportOrderApi *o = new testImportOrderApi(1);
+ return o;
+}
+
+static QObject *testImportOrder_api2(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testImportOrderApi *o = new testImportOrderApi(2);
+ return o;
+}
+
static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
@@ -266,14 +293,14 @@ void registerTypes()
qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
- qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
- qmlRegisterModuleApi<testQObjectApi>("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
- qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
+ qmlRegisterSingletonType("Qt.test",1,0,"Script",script_api); // register (script) singleton Type for an existing uri which contains elements
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test",1,0,"QObject",qobject_api); // register (qobject) for an existing uri for which another singleton Type was previously regd. Should replace!
+ qmlRegisterSingletonType("Qt.test.scriptApi",1,0,"Script",script_api); // register (script) singleton Type for a uri which doesn't contain elements
+ qmlRegisterSingletonType("Qt.test.scriptApi",2,0,"Script",readonly_script_api); // register (script) singleton Type for a uri which doesn't contain elements - will be made read-only
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,0,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,3,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, minor version set
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",2,0,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, major version set
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApiParented",1,0,"QObject",qobject_api_engine_parent); // register (parented qobject) singleton Type for a uri which doesn't contain elements
qRegisterMetaType<MyQmlObject::MyEnum2>("MyEnum2");
qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
@@ -288,13 +315,18 @@ void registerTypes()
qmlRegisterType<MyUnregisteredEnumTypeObject>("Qt.test", 1, 0, "MyUnregisteredEnumTypeObject");
- qmlRegisterModuleApi<FallbackBindingsObject>("Qt.test.fallbackBindingsObject", 1, 0, fallback_bindings_object);
- qmlRegisterModuleApi<FallbackBindingsObject>("Qt.test.fallbackBindingsDerived", 1, 0, fallback_bindings_derived);
+ qmlRegisterSingletonType<FallbackBindingsObject>("Qt.test.fallbackBindingsObject", 1, 0, "Fallback", fallback_bindings_object);
+ qmlRegisterSingletonType<FallbackBindingsObject>("Qt.test.fallbackBindingsDerived", 1, 0, "Fallback", fallback_bindings_derived);
qmlRegisterType<FallbackBindingsTypeObject>("Qt.test.fallbackBindingsObject", 1, 0, "FallbackBindingsType");
qmlRegisterType<FallbackBindingsTypeDerived>("Qt.test.fallbackBindingsDerived", 1, 0, "FallbackBindingsType");
qmlRegisterType<MyStringClass>("Qt.test", 1, 0, "MyStringClass");
+
+ qmlRegisterSingletonType<testImportOrderApi>("Qt.test.importOrderApi",1,0,"Data",testImportOrder_api);
+ qmlRegisterSingletonType<testImportOrderApi>("NamespaceAndType",1,0,"NamespaceAndType",testImportOrder_api);
+ qmlRegisterSingletonType<testImportOrderApi>("Qt.test.importOrderApi1",1,0,"Data",testImportOrder_api1);
+ qmlRegisterSingletonType<testImportOrderApi>("Qt.test.importOrderApi2",1,0,"Data",testImportOrder_api2);
}
#include "testtypes.moc"
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index eaecf71ba7..c05405ab53 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -1129,6 +1129,21 @@ private:
QObject *m_trackedObject;
};
+class testImportOrderApi : public QObject
+{
+ Q_OBJECT
+
+public:
+ testImportOrderApi(int value, QObject *parent = 0) : QObject(parent), m_value(value) {}
+
+ Q_PROPERTY(int value READ value)
+
+ int value() const { return m_value; }
+
+private:
+ int m_value;
+};
+
class CircularReferenceObject : public QObject,
public QV8GCCallback::Node
{
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index f6ec475d40..6fa6c3b49e 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -150,8 +150,13 @@ private slots:
void signalWithJSValueInVariant_twoEngines();
void signalWithQJSValue_data();
void signalWithQJSValue();
- void moduleApi_data();
- void moduleApi();
+ void singletonType_data();
+ void singletonType();
+ void singletonTypeImportOrder();
+ void singletonTypeResolution();
+ void singletonTypeConflicts1();
+ void singletonTypeConflicts2();
+ void singletonTypeConflicts3();
void importScripts_data();
void importScripts();
void scarceResources();
@@ -1632,15 +1637,15 @@ void tst_qqmlecmascript::objectHasOwnProperty()
QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true);
QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true);
QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true);
- QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("singletonTypeTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("singletonTypePropertyTypeHasOwnProperty").toBool(), true);
QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne");
QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false);
QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo");
- QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false);
+ QCOMPARE(child->property("singletonTypeNonPropertyHasOwnProperty").toBool(), false);
QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree");
QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false);
@@ -3527,7 +3532,7 @@ void tst_qqmlecmascript::signalWithQJSValue()
QVERIFY(object->qjsvalue().strictlyEquals(value));
}
-void tst_qqmlecmascript::moduleApi_data()
+void tst_qqmlecmascript::singletonType_data()
{
QTest::addColumn<QUrl>("testfile");
QTest::addColumn<QString>("errorMessage");
@@ -3539,20 +3544,42 @@ void tst_qqmlecmascript::moduleApi_data()
QTest::addColumn<QStringList>("readBackProperties");
QTest::addColumn<QVariantList>("readBackExpectedValues");
+ QTest::newRow("qobject, register + read + method [no qualifier]")
+ << testFileUrl("singletontype/qobjectSingletonTypeNoQualifier.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "qobjectPropertyTest" << "qobjectMethodTest")
+ << (QVariantList() << 20 << 1)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("script, register + read [no qualifier]")
+ << testFileUrl("singletontype/scriptSingletonTypeNoQualifier.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "scriptTest")
+ << (QVariantList() << 13)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
QTest::newRow("qobject, register + read + method")
- << testFileUrl("moduleapi/qobjectModuleApi.qml")
+ << testFileUrl("singletontype/qobjectSingletonType.qml")
<< QString()
<< QStringList()
<< (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
<< "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest")
- << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26)
+ << (QVariantList() << 20 << 20 << 2 << 20 << 20 << 26)
<< QStringList()
<< QVariantList()
<< QStringList()
<< QVariantList();
QTest::newRow("script, register + read")
- << testFileUrl("moduleapi/scriptModuleApi.qml")
+ << testFileUrl("singletontype/scriptSingletonType.qml")
<< QString()
<< QStringList()
<< (QStringList() << "scriptTest")
@@ -3563,7 +3590,7 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
QTest::newRow("qobject, caching + read")
- << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
+ << testFileUrl("singletontype/qobjectSingletonTypeCaching.qml")
<< QString()
<< QStringList()
<< (QStringList() << "existingUriTest" << "qobjectParentedTest")
@@ -3574,7 +3601,7 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
QTest::newRow("script, caching + read")
- << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
+ << testFileUrl("singletontype/scriptSingletonTypeCaching.qml")
<< QString()
<< QStringList()
<< (QStringList() << "scriptTest")
@@ -3585,9 +3612,9 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
QTest::newRow("qobject, writing + readonly constraints")
- << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
+ << testFileUrl("singletontype/qobjectSingletonTypeWriting.qml")
<< QString()
- << (QStringList() << QString(testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+ << (QStringList() << QString(testFileUrl("singletontype/qobjectSingletonTypeWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
<< (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty")
<< (QVariantList() << 20 << 50 << 10)
<< (QStringList() << "firstProperty" << "secondProperty")
@@ -3596,9 +3623,9 @@ void tst_qqmlecmascript::moduleApi_data()
<< (QVariantList() << 20 << 30 << 30);
QTest::newRow("script, writing + readonly constraints")
- << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
+ << testFileUrl("singletontype/scriptSingletonTypeWriting.qml")
<< QString()
- << (QStringList() << QString(testFileUrl("moduleapi/scriptModuleApiWriting.qml").toString() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
+ << (QStringList() << QString(testFileUrl("singletontype/scriptSingletonTypeWriting.qml").toString() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
<< (QStringList() << "readBack" << "unchanged")
<< (QVariantList() << 13 << 42)
<< (QStringList() << "firstProperty" << "secondProperty")
@@ -3606,8 +3633,8 @@ void tst_qqmlecmascript::moduleApi_data()
<< (QStringList() << "readBack" << "unchanged")
<< (QVariantList() << 30 << 42);
- QTest::newRow("qobject module API enum values in JS")
- << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
+ QTest::newRow("qobject singleton Type enum values in JS")
+ << testFileUrl("singletontype/qobjectSingletonTypeEnums.qml")
<< QString()
<< QStringList()
<< (QStringList() << "enumValue" << "enumMethod")
@@ -3618,7 +3645,7 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
QTest::newRow("qobject, invalid major version fail")
- << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
+ << testFileUrl("singletontype/singletonTypeMajorVersionFail.qml")
<< QString("QQmlComponent: Component is not ready")
<< QStringList()
<< QStringList()
@@ -3629,7 +3656,7 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
QTest::newRow("qobject, invalid minor version fail")
- << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
+ << testFileUrl("singletontype/singletonTypeMinorVersionFail.qml")
<< QString("QQmlComponent: Component is not ready")
<< QStringList()
<< QStringList()
@@ -3640,7 +3667,7 @@ void tst_qqmlecmascript::moduleApi_data()
<< QVariantList();
}
-void tst_qqmlecmascript::moduleApi()
+void tst_qqmlecmascript::singletonType()
{
QFETCH(QUrl, testfile);
QFETCH(QString, errorMessage);
@@ -3676,6 +3703,90 @@ void tst_qqmlecmascript::moduleApi()
}
}
+void tst_qqmlecmascript::singletonTypeImportOrder()
+{
+ QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeImportOrder.qml"));
+ QObject *object = component.create();
+ QVERIFY(object);
+ QVERIFY(object->property("v") == 1);
+ delete object;
+}
+
+void tst_qqmlecmascript::singletonTypeResolution()
+{
+ QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeResolution.qml"));
+ QObject *object = component.create();
+ QVERIFY(object);
+ QVERIFY(object->property("success") == true);
+ delete object;
+}
+
+void tst_qqmlecmascript::singletonTypeConflicts1()
+{
+ const char *warning = "Cannot register singleton type TypeName in uri Test.Conflict1 1.5 (a conflicting singleton type already exists)";
+ QTest::ignoreMessage(QtWarningMsg, warning);
+
+ int i0 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict1", 1, 5, "TypeName", 0);
+ QVERIFY(i0 != -1);
+
+ int i1 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict1", 2, 0, "TypeName", 0);
+ QVERIFY(i1 != -1);
+
+ int i2 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict1", 1, 5, "TypeName", 0);
+ QVERIFY(i2 == -1);
+
+ int i3 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict1", 1, 2, "TypeName", 0);
+ QVERIFY(i3 != -1);
+
+ int i4 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict1", 1, 8, "TypeName", 0);
+ QVERIFY(i4 != -1);
+}
+
+void tst_qqmlecmascript::singletonTypeConflicts2()
+{
+ int i0 = qmlRegisterType<MyQmlObject>("Test.Conflict2", 1, 5, "TypeName");
+ QVERIFY(i0 != -1);
+
+ int i2 = qmlRegisterType<MyQmlObject>("Test.Conflict2", 1, 8, "TypeName");
+ QVERIFY(i2 != -1);
+
+ int i3 = qmlRegisterType<MyQmlObject>("Test.Conflict2", 2, 0, "TypeName");
+ QVERIFY(i3 != -1);
+
+ int i4 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict2", 1, 0, "TypeName", 0);
+ QVERIFY(i4 != -1);
+
+ const char *warning2 = "Cannot register singleton type TypeName in uri Test.Conflict2 1.9 (a conflicting type already exists)";
+ QTest::ignoreMessage(QtWarningMsg, warning2);
+
+ int i5 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict2", 1, 9, "TypeName", 0);
+ QVERIFY(i5 == -1);
+}
+
+void tst_qqmlecmascript::singletonTypeConflicts3()
+{
+ int i0 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict3", 1, 0, "TypeName", 0);
+ QVERIFY(i0 != -1);
+
+ int i1 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict3", 1, 5, "TypeName", 0);
+ QVERIFY(i1 != -1);
+
+ int i2 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict3", 1, 8, "TypeName", 0);
+ QVERIFY(i2 != -1);
+
+ int i3 = qmlRegisterSingletonType<testImportOrderApi>("Test.Conflict3", 2, 0, "TypeName", 0);
+ QVERIFY(i3 != -1);
+
+ const char *warning = "Cannot register type TypeName in uri Test.Conflict3 1.0 (a conflicting singleton type already exists)";
+ QTest::ignoreMessage(QtWarningMsg, warning);
+
+ int i4 = qmlRegisterType<MyQmlObject>("Test.Conflict3", 1, 0, "TypeName");
+ QVERIFY(i4 == -1);
+
+ int i5 = qmlRegisterType<MyQmlObject>("Test.Conflict3", 1, 3, "TypeName");
+ QVERIFY(i5 != -1);
+}
+
void tst_qqmlecmascript::importScripts_data()
{
QTest::addColumn<QUrl>("testfile");
@@ -3767,8 +3878,8 @@ void tst_qqmlecmascript::importScripts_data()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(18));
- QTest::newRow("import module api into js import")
- << testFileUrl("jsimport/testImportModuleApi.qml")
+ QTest::newRow("import singleton type into js import")
+ << testFileUrl("jsimport/testImportSingletonType.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
@@ -7106,8 +7217,8 @@ void tst_qqmlecmascript::fallbackBindings_data()
QTest::newRow("Property without fallback") << "fallbackBindings.1.qml";
QTest::newRow("Property fallback") << "fallbackBindings.2.qml";
- QTest::newRow("ModuleAPI without fallback") << "fallbackBindings.3.qml";
- QTest::newRow("ModuleAPI fallback") << "fallbackBindings.4.qml";
+ QTest::newRow("SingletonType without fallback") << "fallbackBindings.3.qml";
+ QTest::newRow("SingletonType fallback") << "fallbackBindings.4.qml";
QTest::newRow("Attached without fallback") << "fallbackBindings.5.qml";
QTest::newRow("Attached fallback") << "fallbackBindings.6.qml";
}
diff --git a/tests/auto/qml/qqmlsqldatabase/data/changeversion.js b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
index 178ff7c4af..f466501ae3 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
@@ -3,7 +3,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000,
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000,
function(db) {
db.changeVersion("","1.0")
db.transaction(function(tx){
@@ -17,7 +17,7 @@ function test() {
});
- db = Sql.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000);
+ db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000);
if (db.version == "1.0")
db.changeVersion("1.0","2.0",function(tx)
@@ -37,7 +37,7 @@ function test() {
else
return "db.version should be 1.0, but is " + db.version;
- var db = Sql.openDatabaseSync("QmlTestDB-changeversion", "2.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-changeversion", "2.0", "Test database from Qt autotests", 1000000);
db.transaction(function(tx){
var rs = tx.executeSql('SELECT * FROM Utterance');
diff --git a/tests/auto/qml/qqmlsqldatabase/data/creation-a.js b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
index 25cba05451..65818e4981 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
@@ -3,7 +3,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000,
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000,
function(db) {
db.transaction(function(tx){
tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)');
@@ -11,7 +11,7 @@ function test() {
})
});
- var db = Sql.openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000,
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-creation-a", "1.0", "Test database from Qt autotests", 1000000,
function(db) {
r = "FAILED: should have already been created";
});
diff --git a/tests/auto/qml/qqmlsqldatabase/data/creation.js b/tests/auto/qml/qqmlsqldatabase/data/creation.js
index 64eb4c7b92..3eeef21429 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation.js
@@ -2,7 +2,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-creation", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-creation", "1.0", "Test database from Qt autotests", 1000000);
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
diff --git a/tests/auto/qml/qqmlsqldatabase/data/error-a.js b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
index d7e9b4fdff..6517c7a84d 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/error-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-error-a", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-error-a", "1.0", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
try {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/error-b.js b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
index 17e34c989e..b7369fa668 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/error-b.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-error-b", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-error-b", "1.0", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
db.transaction(
diff --git a/tests/auto/qml/qqmlsqldatabase/data/error-creation.js b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
index d66977d1e2..2d9ebb5b34 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
@@ -3,7 +3,7 @@
function test() {
var r="transaction_not_finished";
try {
- var db = Sql.openDatabaseSync("QmlTestDB-creation", "2.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-creation", "2.0", "Test database from Qt autotests", 1000000);
} catch (err) {
if (err.code != SQLException.VERSION_ERR)
r = "WRONG ERROR CODE="+err.code;
diff --git a/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
index 2cce3f613c..1db6d60cae 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
try {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
index 7af7c1c6a2..666f130d18 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-data/error-notransaction", "1.0", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
var v;
diff --git a/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
index b3df1be113..e2f2704927 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-iteration-forwardonly", "", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-iteration-forwardonly", "", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
db.transaction(
diff --git a/tests/auto/qml/qqmlsqldatabase/data/iteration.js b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
index 8d96dc2154..f83b767a7d 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/iteration.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-iteration", "", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-iteration", "", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
db.transaction(
diff --git a/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
index 39eb398004..e14d7002c1 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
@@ -2,7 +2,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-readonly-error", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-readonly-error", "1.0", "Test database from Qt autotests", 1000000);
db.transaction(
function(tx) {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/readonly.js b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
index 985c9ecab5..8dd7e78071 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/readonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
@@ -2,7 +2,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-readonly", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-readonly", "1.0", "Test database from Qt autotests", 1000000);
db.transaction(
function(tx) {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/reopen1.js b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
index 2171fb028e..5589f12def 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
@@ -2,7 +2,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000);
db.transaction(
function(tx) {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/reopen2.js b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
index 12c6135145..2f7f5a6097 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
@@ -2,7 +2,7 @@
function test() {
var r="transaction_not_finished";
- var db = Sql.openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-reopen", "1.0", "Test database from Qt autotests", 1000000);
db.transaction(
function(tx) {
diff --git a/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
index 9333ccfacb..fdb495632b 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-bindnames", "", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-bindnames", "", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
db.transaction(
diff --git a/tests/auto/qml/qqmlsqldatabase/data/selection.js b/tests/auto/qml/qqmlsqldatabase/data/selection.js
index 18d4dce80f..b7b1fe47e9 100644
--- a/tests/auto/qml/qqmlsqldatabase/data/selection.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection.js
@@ -1,7 +1,7 @@
.import QtQuick.LocalStorage 2.0 as Sql
function test() {
- var db = Sql.openDatabaseSync("QmlTestDB-selection", "", "Test database from Qt autotests", 1000000);
+ var db = Sql.LocalStorage.openDatabaseSync("QmlTestDB-selection", "", "Test database from Qt autotests", 1000000);
var r="transaction_not_finished";
db.transaction(
diff --git a/tests/auto/qml/qquickconnection/data/moduleapi-target.qml b/tests/auto/qml/qquickconnection/data/singletontype-target.qml
index 8803f24542..df6f8a0301 100644
--- a/tests/auto/qml/qquickconnection/data/moduleapi-target.qml
+++ b/tests/auto/qml/qquickconnection/data/singletontype-target.qml
@@ -1,5 +1,5 @@
import QtQuick 2.0
-import MyTestModuleApi 1.0 as MyTestModuleApi
+import MyTestSingletonType 1.0 as MyTestSingletonType
Item {
id: rootObject
@@ -10,12 +10,12 @@ Item {
property int moduleOtherSignalCount: 0
function setModuleIntProp() {
- MyTestModuleApi.intProp = newIntPropValue;
+ MyTestSingletonType.Api.intProp = newIntPropValue;
newIntPropValue = newIntPropValue + 1;
}
Connections {
- target: MyTestModuleApi
+ target: MyTestSingletonType.Api
onIntPropChanged: moduleIntPropChangedCount = moduleIntPropChangedCount + 1;
onOtherSignal: moduleOtherSignalCount = moduleOtherSignalCount + 1;
}
diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
index 1167281eb0..118d89e41e 100644
--- a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
+++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
@@ -62,7 +62,7 @@ private slots:
void unknownSignals();
void errors_data();
void errors();
- void moduleApiTarget();
+ void singletonTypeTarget();
private:
QQmlEngine engine;
@@ -225,14 +225,14 @@ void tst_qquickconnection::errors()
}
-class MyTestModuleApi : public QObject
+class MyTestSingletonType : public QObject
{
Q_OBJECT
Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
public:
- MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
- ~MyTestModuleApi() {}
+ MyTestSingletonType(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
+ ~MyTestSingletonType() {}
Q_INVOKABLE int otherMethod(int val) { return val + 4; }
@@ -256,15 +256,15 @@ static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
- MyTestModuleApi *api = new MyTestModuleApi();
+ MyTestSingletonType *api = new MyTestSingletonType();
return api;
}
// QTBUG-20937
-void tst_qquickconnection::moduleApiTarget()
+void tst_qquickconnection::singletonTypeTarget()
{
- qmlRegisterModuleApi<MyTestModuleApi>("MyTestModuleApi", 1, 0, module_api_factory);
- QQmlComponent component(&engine, testFileUrl("moduleapi-target.qml"));
+ qmlRegisterSingletonType<MyTestSingletonType>("MyTestSingletonType", 1, 0, "Api", module_api_factory);
+ QQmlComponent component(&engine, testFileUrl("singletontype-target.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
@@ -279,7 +279,7 @@ void tst_qquickconnection::moduleApiTarget()
QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
- // the module API emits otherSignal every 3 times the int property changes.
+ // the singleton Type emits otherSignal every 3 times the int property changes.
QMetaObject::invokeMethod(object, "setModuleIntProp");
QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);
diff --git a/tests/auto/qml/v4/data/moduleApi.qml b/tests/auto/qml/v4/data/singletonType.qml
index 9f3bf0ca8c..3fcbcae64d 100644
--- a/tests/auto/qml/v4/data/moduleApi.qml
+++ b/tests/auto/qml/v4/data/singletonType.qml
@@ -2,11 +2,11 @@ import Qt.test 1.0 as ModApi
import QtQuick 2.0
Item {
- property int testProp: ModApi.ip
+ property int testProp: ModApi.V4.ip
property int testProp2: 2
function getRandom() {
- testProp2 = ModApi.random();
+ testProp2 = ModApi.V4.random();
// testProp should also have changed.
}
}
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
index 98df72909f..90551e1aeb 100644
--- a/tests/auto/qml/v4/tst_v4.cpp
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -82,7 +82,7 @@ private slots:
void mathCeil();
void mathMax();
void mathMin();
- void moduleApi();
+ void singletonType();
void conversions_data();
void conversions();
@@ -607,13 +607,13 @@ void tst_v4::mathMin()
delete o;
}
-class V4ModuleApi : public QObject
+class V4SingletonType : public QObject
{
Q_OBJECT
Q_PROPERTY(int ip READ ip WRITE setIp NOTIFY ipChanged FINAL)
public:
- V4ModuleApi() : m_ip(12) {}
- ~V4ModuleApi() {}
+ V4SingletonType() : m_ip(12) {}
+ ~V4SingletonType() {}
Q_INVOKABLE int random() { static int prng = 3; prng++; m_ip++; emit ipChanged(); return prng; }
@@ -629,14 +629,14 @@ private:
static QObject *v4_module_api_factory(QQmlEngine*, QJSEngine*)
{
- return new V4ModuleApi;
+ return new V4SingletonType;
}
-void tst_v4::moduleApi()
+void tst_v4::singletonType()
{
- // register module api, providing typeinfo via template
- qmlRegisterModuleApi<V4ModuleApi>("Qt.test", 1, 0, v4_module_api_factory);
- QQmlComponent component(&engine, testFileUrl("moduleApi.qml"));
+ // register singleton type, providing typeinfo via template
+ qmlRegisterSingletonType<V4SingletonType>("Qt.test", 1, 0, "V4", v4_module_api_factory);
+ QQmlComponent component(&engine, testFileUrl("singletonType.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("testProp").toInt(), 12);
diff --git a/tests/benchmarks/qml/holistic/testtypes.cpp b/tests/benchmarks/qml/holistic/testtypes.cpp
index bf9ff5f34e..9a5dc087b1 100644
--- a/tests/benchmarks/qml/holistic/testtypes.cpp
+++ b/tests/benchmarks/qml/holistic/testtypes.cpp
@@ -82,13 +82,13 @@ void registerTypes()
qmlRegisterType<ScarceResourceProvider>("Qt.test", 1,0, "MyScarceResourceProvider");
qmlRegisterType<ArbitraryVariantProvider>("Qt.test", 1,0, "MyArbitraryVariantProvider");
- qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
- qmlRegisterModuleApi<testQObjectApi>("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
- qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
- qmlRegisterModuleApi<testQObjectApi>("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
+ qmlRegisterSingletonType("Qt.test",1,0,script_api); // register (script) singleton Type for an existing uri which contains elements
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another singleton Type was previously regd. Should replace!
+ qmlRegisterSingletonType("Qt.test.scriptApi",1,0,script_api); // register (script) singleton Type for a uri which doesn't contain elements
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, minor version set
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, major version set
+ qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) singleton Type for a uri which doesn't contain elements
}
//#include "testtypes.moc"