aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlvaluetypeproviders/data
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-08-01 10:27:17 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-10 05:40:49 +0200
commit4350877d6deb58f36df24164c6edde3302a3f1a3 (patch)
tree5b1b121c1ce21aff1717de500282a5951f4e1267 /tests/auto/qml/qqmlvaluetypeproviders/data
parent34ae6deb78c30a80570e0c0dda7b2f071abdbf68 (diff)
Permit value types with metatype IDs >= QMetaType::User
Remove the assumption that value types must be types defined by Qt, having metatype IDs below QMetaType::User. Task-number: QTBUG-26352 Change-Id: Ib5a56ff2e7892e82adf17a3a1e7517a0c9fe0534 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypeproviders/data')
-rw-r--r--tests/auto/qml/qqmlvaluetypeproviders/data/userType.qml88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypeproviders/data/userType.qml b/tests/auto/qml/qqmlvaluetypeproviders/data/userType.qml
new file mode 100644
index 0000000000..d2f748c4c4
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypeproviders/data/userType.qml
@@ -0,0 +1,88 @@
+import QtQuick 2.0
+import Test 1.0
+
+Item {
+ property bool success: false
+
+ // Test user value type stored as both var and variant
+ property var testValue1
+ property variant testValue2
+ property variant testValue3
+ property var testValue4
+
+ TestValueExporter {
+ id: assignmentValueType
+ testValue.property1: 1
+ testValue.property2: 3.1415927
+ }
+
+ TestValueExporter {
+ id: v4BindingValueType
+ testValue.property1: 1 + 2
+ testValue.property2: 3.1415927 / 2.0
+ }
+
+ TestValueExporter {
+ id: v8BindingValueType
+ testValue.property1: if (true) 1 + 2
+ testValue.property2: if (true) 3.1415927 / 2.0
+ }
+
+ function numberEqual(lhs, rhs) {
+ var d = (lhs - rhs)
+ return (Math.abs(d) < 0.0001)
+ }
+
+ Component.onCompleted: {
+ // Poperties assigned the result of Q_INVOKABLE:
+ testValue1 = testValueExporter.getTestValue()
+ testValue2 = testValueExporter.getTestValue()
+
+ if (testValue1.property1 != 333) return
+ if (!numberEqual(testValue1.property2, 666.999)) return
+
+ if (testValue2.property1 != 333) return
+ if (!numberEqual(testValue2.property2, 666.999)) return
+
+ if (testValue1 != testValue2) return
+
+ // Write to the properties of the value type
+ testValue1.property1 = 1
+ testValue1.property2 = 3.1415927
+
+ testValue2.property1 = 1
+ testValue2.property2 = 3.1415927
+
+ if (testValue1.property1 != 1) return
+ if (!numberEqual(testValue1.property2, 3.1415927)) return
+
+ if (testValue2.property1 != 1) return
+ if (!numberEqual(testValue2.property2, 3.1415927)) return
+
+ if (testValue1 != testValue2) return
+
+ // Assignment of value type properties
+ testValue3 = testValue1
+ testValue4 = testValue2
+
+ if (testValue3.property1 != 1) return
+ if (!numberEqual(testValue3.property2, 3.1415927)) return
+
+ if (testValue4.property1 != 1) return
+ if (!numberEqual(testValue4.property2, 3.1415927)) return
+
+ if (testValue3 != testValue4) return
+
+ // Access a value-type property of a QObject
+ var vt = testValueExporter.testValue
+ if (vt.property1 != 0) return
+ if (!numberEqual(vt.property2, 0.0)) return
+
+ testValueExporter.testValue = testValue4
+
+ if (vt.property1 != 1) return
+ if (!numberEqual(vt.property2, 3.1415927)) return
+
+ success = true
+ }
+}