summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-04-19 11:42:49 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-04-21 07:13:51 (GMT)
commit202af3021362d3c8066bc479a95e7aad889bd928 (patch)
tree03587443c77403321c18e384b3277abd576e9ba3 /tests
parent2ac290f56c6ad4f3e236034a7b99ecdb598ecc3a (diff)
downloadQt-202af3021362d3c8066bc479a95e7aad889bd928.zip
Qt-202af3021362d3c8066bc479a95e7aad889bd928.tar.gz
Qt-202af3021362d3c8066bc479a95e7aad889bd928.tar.bz2
Make the dynamic creation functions on the Qt object
Also updated examples to still work, and the dynamic example now uses exceptions a little, to demonstrate that it can be done. Exceptions are also now filled out with the QML error data. Task-number: QT-2801 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponent.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml18
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp6
3 files changed, 17 insertions, 17 deletions
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
index 412c467..253a4e3 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
@@ -6,15 +6,15 @@ QtObject {
property string relativeUrl
property string absoluteUrl
- property QtObject incorectArgCount1: createComponent()
- property QtObject incorectArgCount2: createComponent("main.qml", 10)
+ property QtObject incorectArgCount1: Qt.createComponent()
+ property QtObject incorectArgCount2: Qt.createComponent("main.qml", 10)
Component.onCompleted: {
- emptyArg = (createComponent("") == null);
- var r = createComponent("createComponentData.qml");
+ emptyArg = (Qt.createComponent("") == null);
+ var r = Qt.createComponent("createComponentData.qml");
relativeUrl = r.url;
- var a = createComponent("http://www.example.com/test.qml");
+ var a = Qt.createComponent("http://www.example.com/test.qml");
absoluteUrl = a.url;
}
}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
index 8e6c58e..9fe169d 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
@@ -4,11 +4,11 @@ Item {
id: root
// errors resulting in exceptions
- property QtObject incorrectArgCount1: createQmlObject()
- property QtObject incorrectArgCount2: createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10)
- property QtObject noParent: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0)
- property QtObject notAvailable: createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root)
- property QtObject errors: createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml")
+ property QtObject incorrectArgCount1: Qt.createQmlObject()
+ property QtObject incorrectArgCount2: Qt.createQmlObject("import Qt 4.6\nQtObject{}", root, "main.qml", 10)
+ property QtObject noParent: Qt.createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13}", 0)
+ property QtObject notAvailable: Qt.createQmlObject("import Qt 4.6\nQtObject{Blah{}}", root)
+ property QtObject errors: Qt.createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml")
property bool emptyArg: false
@@ -16,16 +16,16 @@ Item {
Component.onCompleted: {
// errors resulting in nulls
- emptyArg = (createQmlObject("", root) == null);
+ emptyArg = (Qt.createQmlObject("", root) == null);
try {
- createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root)
+ Qt.createQmlObject("import Qt 4.6\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root)
} catch (error) {
console.log("RunTimeError: ",error.message);
}
- var o = createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\n}", root);
+ var o = Qt.createQmlObject("import Qt 4.6\nQtObject{\nproperty int test: 13\n}", root);
success = (o.test == 13);
- createQmlObject("import Qt 4.6\nItem {}\n", root);
+ Qt.createQmlObject("import Qt 4.6\nItem {}\n", root);
}
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 4d22b0a..24fad14 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -354,11 +354,11 @@ void tst_qdeclarativeqt::createQmlObject()
QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml"));
QString warning1 = component.url().toString() + ":7: Error: expected 2 or 3 parameters";
- QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n";
- QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n";
+ QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject() failed to create object : " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n";
+ QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject() failed to create object : " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n";
QString warning4 = component.url().toString()+ ":9: Error: parent object not found";
QString warning5 = component.url().toString()+ ":8: Error: expected 2 or 3 parameters";
- QString warning6 = "RunTimeError: Qt.createQmlObject(): " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n";
+ QString warning6 = "RunTimeError: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));