aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlvaluetypes/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes/data')
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml25
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml40
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml
new file mode 100644
index 0000000000..6063917dd4
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/variant_write.1.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+Item {
+ property bool complete: false
+ property bool success: false
+
+ property variant v1: Qt.vector3d(1,2,3)
+ property variant v2: Qt.vector3d(4,5,6)
+ property variant v3: v1.plus(v2) // set up doomed binding
+
+ Component.onCompleted: {
+ complete = false;
+ success = true;
+
+ v1 = Qt.vector2d(1,2) // changing the type of the property shouldn't cause crash
+
+ v1.x = 8;
+ v2.x = 9;
+
+ if (v1 != Qt.vector2d(8,2)) success = false;
+ if (v2 != Qt.vector3d(9,5,6)) success = false;
+
+ complete = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml
new file mode 100644
index 0000000000..0dbfd2a012
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/variant_write.2.qml
@@ -0,0 +1,40 @@
+import QtQuick 2.0
+
+Item {
+ property bool complete: false
+ property bool success: false
+
+ property variant v1
+
+ Component.onCompleted: {
+ complete = false;
+ success = true;
+
+ // store a js reference to the VariantReference vt in a temp var.
+ v1 = Qt.vector3d(1,2,3)
+ var ref = v1;
+ ref.z = 5
+ if (v1 != Qt.vector3d(1,2,5)) success = false;
+
+ // now change the type of a reference, and attempt a valid write.
+ v1 = Qt.vector2d(1,2);
+ ref.x = 5;
+ if (v1 != Qt.vector2d(5,2)) success = false;
+
+ // now change the type of a reference, and attempt an invalid write.
+ v1 = Qt.rgba(1,0,0,1);
+ ref.x = 5;
+ if (v1.toString() != Qt.rgba(1,0,0,1).toString()) success = false;
+ v1 = 6;
+ ref.x = 5;
+ if (v1 != 6) success = false;
+
+ // now change the type of a reference, and attempt an invalid read.
+ v1 = Qt.vector3d(1,2,3);
+ ref = v1;
+ v1 = Qt.vector2d(1,2);
+ if (ref.z == 3) success = false;
+
+ complete = true;
+ }
+}