aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/data')
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObject.qml13
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml43
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createParentReference.qml12
-rw-r--r--tests/auto/qml/qqmlcomponent/data/incubateObject.qml36
4 files changed, 104 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/createObject.qml b/tests/auto/qml/qqmlcomponent/data/createObject.qml
new file mode 100644
index 0000000000..da5db8e8e6
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/createObject.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Item{
+ id: root
+ property QtObject qobject : null
+ property QtObject declarativeitem : null
+ Component{id: a; QtObject{} }
+ Component{id: b; Item{} }
+ Component.onCompleted: {
+ root.qobject = a.createObject(root);
+ root.declarativeitem = b.createObject(root);
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
new file mode 100644
index 0000000000..122c6a87c8
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+
+Item{
+ id: root
+ property QtObject declarativerectangle : null
+ property QtObject declarativeitem : null
+
+ property QtObject bindingTestObject : null
+ property QtObject bindingThisTestObject : null
+
+ Component{
+ id: a
+ Rectangle {
+ property Rectangle innerRect: Rectangle { border.width: 20 }
+ }
+ }
+ Component{
+ id: b
+ Item{
+ property bool testBool: false
+ property int testInt: null
+ property QtObject testObject: null
+ }
+ }
+
+ // test passing in bindings
+ width: 100
+ Component {
+ id: c
+ Item {
+ property int testValue
+ width: 300
+ }
+ }
+
+ Component.onCompleted: {
+ root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white", "border.width":3, "innerRect.border.width": 20});
+ root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root});
+
+ root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) }) // use root.width
+ root.bindingThisTestObject = c.createObject(root, {'testValue': (function(){return this.width * 3}) }) // use width of Item within 'c'
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/data/createParentReference.qml b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
new file mode 100644
index 0000000000..daa5d3c167
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/createParentReference.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 100
+ height: 100
+
+ function createChild() {
+ Qt.createQmlObject("import QtQuick 2.0;" +
+ "Item { width: parent.width; }", root);
+ }
+}
diff --git a/tests/auto/qml/qqmlcomponent/data/incubateObject.qml b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
new file mode 100644
index 0000000000..c11319db30
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.0
+
+Item{
+ id: root
+
+ property bool test1: false
+ property bool test2: false
+
+ property var i
+
+ Component{
+ id: component
+ Item {
+ property int dummy: 13
+ property int dummy2: 26
+ }
+ }
+
+ Component.onCompleted: {
+ i = component.incubateObject(null, { dummy2: 19 });
+
+ if (i.status != Component.Loading) return;
+ if (i.object != null) return;
+
+ i.onStatusChanged = function(status) {
+ if (status != Component.Ready) return;
+ if (i.object == null) return;
+ if (i.object.dummy != 13) return;
+ if (i.object.dummy2 != 19) return;
+ test2 = true;
+ }
+
+ test1 = true;
+ }
+}
+