aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlvaluetypes
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto/qml/qqmlvaluetypes
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml5
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml13
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml29
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml31
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml36
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml27
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml27
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_compare.qml37
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_read.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_write.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml42
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml42
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml42
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.js13
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml11
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.1.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.2.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.3.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.4.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.5.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_compare.qml31
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_read.qml18
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml14
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.qml16
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml35
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml22
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml21
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_compare.qml22
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_read.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_write.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml22
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml23
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml25
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_read.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_write.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml25
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/returnValues.qml17
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml14
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_compare.qml23
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_read.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_write.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml24
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml6
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml5
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueSources.qml5
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml14
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/variant_read.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml21
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml23
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml23
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml10
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml9
-rw-r--r--tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro18
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.cpp48
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.h219
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp1306
85 files changed, 2754 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
new file mode 100644
index 0000000000..f625d081e5
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property bool boldProperty: false
+
+ font.bold: boldProperty
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
new file mode 100644
index 0000000000..0bdccce5be
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int dataProperty: 7
+
+ point: Qt.point(dataProperty, dataProperty)
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
new file mode 100644
index 0000000000..151c49971e
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int dataProperty: 7
+
+ point.x: dataProperty
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
new file mode 100644
index 0000000000..ce2e82d0f8
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: 10
+ rect.x: value
+
+ onRunScript: { rect = Qt.rect(10, 10, 10, 10) }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
new file mode 100644
index 0000000000..d431b4ae08
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property variant value
+
+ rect: value
+
+ onRunScript: { rect.x = 44 }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
new file mode 100644
index 0000000000..a8a72f515b
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: 10
+ rect.x: value
+
+ onRunScript: { rect.x = 42; }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
new file mode 100644
index 0000000000..a65218669b
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: 10
+
+ rect.x: value
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
new file mode 100644
index 0000000000..fd25c9f0a7
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: 13
+
+ rect.x: value
+ rect: "10,10,10x10"
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
new file mode 100644
index 0000000000..538d776fba
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: rect.x
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
new file mode 100644
index 0000000000..3a48c8bdb1
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
@@ -0,0 +1,13 @@
+import Test 1.0
+
+MyTypeObject {
+ property variant object
+ object: MyTypeObject {
+ rect.x: 19
+ rect.y: 33
+ rect.width: 5
+ rect.height: 99
+ }
+
+ rect: object.rect
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
new file mode 100644
index 0000000000..2a1b936da6
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
@@ -0,0 +1,29 @@
+import Test 1.0
+import QtQuick 2.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+
+ font.italic: italicProperty
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding worked
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != true) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
new file mode 100644
index 0000000000..84b465c565
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
@@ -0,0 +1,31 @@
+import Test 1.0
+import QtQuick 2.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+
+ font.italic: italicProperty
+ font.bold: false
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding was removed by constant write
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
new file mode 100644
index 0000000000..f1212f8039
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
@@ -0,0 +1,36 @@
+import Test 1.0
+import QtQuick 2.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+ property bool boldProperty2: false
+
+ font.italic: italicProperty
+ font.bold: boldProperty2
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding was overridden
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ boldProperty2 = true;
+ if (font.italic != true) return;
+ if (font.bold != true) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
new file mode 100644
index 0000000000..9c5e950660
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
@@ -0,0 +1,27 @@
+import Test 1.0
+import QtQuick 2.0
+
+BindingsSpliceCorrectlyType4 {
+ property bool test: false
+
+ property int dataProperty2: 8
+
+ point.x: dataProperty2
+
+ Component.onCompleted: {
+ if (point.x != 8) return;
+ if (point.y != 4) return;
+
+ dataProperty = 9;
+
+ if (point.x != 8) return;
+ if (point.y != 4) return;
+
+ dataProperty2 = 13;
+
+ if (point.x != 13) return;
+ if (point.y != 4) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
new file mode 100644
index 0000000000..7d87ba1782
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
@@ -0,0 +1,27 @@
+import Test 1.0
+import QtQuick 2.0
+
+BindingsSpliceCorrectlyType5 {
+ property bool test: false
+
+ property int dataProperty2: 8
+
+ point: Qt.point(dataProperty2, dataProperty2);
+
+ Component.onCompleted: {
+ if (point.x != 8) return;
+ if (point.y != 8) return;
+
+ dataProperty = 9;
+
+ if (point.x != 8) return;
+ if (point.y != 8) return;
+
+ dataProperty2 = 13;
+
+ if (point.x != 13) return;
+ if (point.y != 13) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
new file mode 100644
index 0000000000..8701dae612
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
@@ -0,0 +1,37 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_r: color.r
+ property real v_g: color.g
+ property real v_b: color.b
+ property real v_a: color.a
+ property variant copy: color
+ property string colorToString: color.toString()
+
+ // compare different colors
+ property bool colorEqualsIdenticalRgba: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true
+ property bool colorEqualsDifferentAlpha: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44)) // false
+ property bool colorEqualsDifferentRgba: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44)) // false
+
+ // compare different color.toString()s
+ property bool colorToStringEqualsColorString: (color.toString() == colorToString) // true
+ property bool colorToStringEqualsDifferentAlphaString: (color.toString() == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // true
+ property bool colorToStringEqualsDifferentRgbaString: (color.toString() == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false
+
+ // compare colors to strings
+ property bool colorEqualsColorString: (color == colorToString) // false
+ property bool colorEqualsDifferentAlphaString: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // false
+ property bool colorEqualsDifferentRgbaString: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false
+
+ // compare colors to various value types
+ property bool equalsColor: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true
+ property bool equalsVector3d: (color == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (color == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (color == Qt.point(10, 4)) // false
+ property bool equalsRect: (color == Qt.rect(2, 3, 109, 102)) // false
+
+ // ensure comparison directionality doesn't matter
+ property bool equalsColorRHS: (Qt.rgba(0.2, 0.88, 0.6, 0.34) == color) // true
+ property bool colorEqualsCopy: (color == copy) // true
+ property bool copyEqualsColor: (copy == color) // true
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_read.qml b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
new file mode 100644
index 0000000000..bc92b1e5f9
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_r: color.r
+ property real v_g: color.g
+ property real v_b: color.b
+ property real v_a: color.a
+ property variant copy: color
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_write.qml b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
new file mode 100644
index 0000000000..3f1bad4aa6
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ color.r: if (true) 0.5
+ color.g: if (true) 0.38
+ color.b: if (true) 0.3
+ color.a: if (true) 0.7
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
new file mode 100644
index 0000000000..923922c55a
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
@@ -0,0 +1,42 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 800
+ height: 600
+
+ property alias font: myText.font
+
+ property int myPixelSize: 12
+ property int myPixelSize2: 24
+
+ Text {
+ id: other
+ font.pixelSize: 6
+ }
+
+ Text {
+ id: myText
+
+ text: "Hello world!"
+ font.pixelSize: myPixelSize
+ }
+
+ states: State {
+ name: "Swapped"
+ PropertyChanges {
+ target: myText
+ font: other.font
+ }
+ }
+
+ function toggle() {
+ if (root.state == "") root.state = "Swapped"; else root.state = "";
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";}
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
new file mode 100644
index 0000000000..9804af4df6
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
@@ -0,0 +1,42 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 800
+ height: 600
+
+ property alias font: myText.font
+
+ property int myPixelSize: 12
+ property int myPixelSize2: 24
+
+ Text {
+ id: other
+ font.pixelSize: 6
+ }
+
+ Text {
+ id: myText
+
+ text: "Hello world!"
+ font: other.font
+ }
+
+ states: State {
+ name: "Swapped"
+ PropertyChanges {
+ target: myText
+ font.pixelSize: myPixelSize
+ }
+ }
+
+ function toggle() {
+ if (root.state == "") root.state = "Swapped"; else root.state = "";
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";}
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
new file mode 100644
index 0000000000..b5bb7f8ccc
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
@@ -0,0 +1,42 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ width: 800
+ height: 600
+
+ property alias font: myText.font
+
+ property int myPixelSize: 12
+ property int myPixelSize2: 24
+
+ Text {
+ id: other
+ font.pixelSize: 6
+ }
+
+ Text {
+ id: myText
+
+ text: "Hello world!"
+ font.pixelSize: myPixelSize
+ }
+
+ states: State {
+ name: "Swapped"
+ PropertyChanges {
+ target: myText
+ font.pixelSize: myPixelSize2
+ }
+ }
+
+ function toggle() {
+ if (root.state == "") root.state = "Swapped"; else root.state = "";
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";}
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
new file mode 100644
index 0000000000..af298ffbd0
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
@@ -0,0 +1,13 @@
+var savedReference;
+
+function startup()
+{
+ savedReference = object.rect;
+ console.log("Test: " + savedReference.x);
+}
+
+function afterDelete()
+{
+ console.log("Test: " + savedReference.x);
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
new file mode 100644
index 0000000000..4f7ad39db0
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
@@ -0,0 +1,11 @@
+import Test 1.0
+import QtQuick 2.0
+import "deletedObject.js" as JS
+
+MyTypeObject {
+ property variant object
+
+ object: MyTypeObject {}
+ Component.onCompleted: JS.startup()
+ onRunScript: JS.afterDelete()
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
new file mode 100644
index 0000000000..cb01a80669
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: "AllUppercase"
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
new file mode 100644
index 0000000000..93f1ed59bc
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.capitalization: if (1) "AllUppercase"
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
new file mode 100644
index 0000000000..cc7861a122
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+import QtQuick 2.0
+
+MyTypeObject {
+ font.capitalization: Font.AllUppercase
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
new file mode 100644
index 0000000000..cf41c90b90
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+import QtQuick 2.0 as MyQt
+
+MyTypeObject {
+ font.capitalization: MyQt.Font.AllUppercase
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
new file mode 100644
index 0000000000..de279dba6c
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+import QtQuick 2.0 as MyQt
+
+MyTypeObject {
+ MyQt.Component.onCompleted: {
+ font.capitalization = MyQt.Font.AllUppercase
+ }
+}
+
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
new file mode 100644
index 0000000000..efbb0e3d0b
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
@@ -0,0 +1,31 @@
+import Test 1.0
+
+MyTypeObject {
+ property string f_family: font.family
+ property bool f_bold: font.bold
+ property int f_weight: font.weight
+ property bool f_italic: font.italic
+ property bool f_underline: font.underline
+ property bool f_overline: font.overline
+ property bool f_strikeout: font.strikeout
+ property real f_pointSize: font.pointSize
+ property int f_pixelSize: font.pixelSize
+ property int f_capitalization: font.capitalization
+ property real f_letterSpacing: font.letterSpacing
+ property real f_wordSpacing: font.wordSpacing;
+ property variant copy: font
+ property string tostring: font.toString()
+
+ // compare to string
+ property bool equalsString: (font == tostring)
+
+ // compare fonts to various value types
+ property bool equalsColor: (font == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (font == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (font == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (font == Qt.point(10, 4)) // false
+ property bool equalsRect: (font == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (font == font) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_read.qml b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
new file mode 100644
index 0000000000..d73bb132d3
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
@@ -0,0 +1,18 @@
+import Test 1.0
+
+MyTypeObject {
+ property string f_family: font.family
+ property bool f_bold: font.bold
+ property int f_weight: font.weight
+ property bool f_italic: font.italic
+ property bool f_underline: font.underline
+ property bool f_overline: font.overline
+ property bool f_strikeout: font.strikeout
+ property real f_pointSize: font.pointSize
+ property int f_pixelSize: font.pixelSize
+ property int f_capitalization: font.capitalization
+ property real f_letterSpacing: font.letterSpacing
+ property real f_wordSpacing: font.wordSpacing;
+ property variant copy: font
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
new file mode 100644
index 0000000000..b559389efb
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ font.pixelSize: 10
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
new file mode 100644
index 0000000000..913ac50738
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ font.pixelSize: 10
+ font.pointSize: 19
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
new file mode 100644
index 0000000000..2ec69d7281
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ font.pointSize: 19
+ font.pixelSize: 10
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
new file mode 100644
index 0000000000..5297a8260d
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+import Test 1.0
+
+Item {
+ MyTypeObject {
+ objectName: "object1"
+ font.pixelSize: 19
+ }
+ MyTypeObject {
+ objectName: "object2"
+ font.pointSize: 14
+ }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
new file mode 100644
index 0000000000..ff4d0a1004
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
@@ -0,0 +1,16 @@
+import Test 1.0
+
+MyTypeObject {
+ font.family: if(1) "Helvetica"
+ font.bold: if(1) false
+ font.weight: "Normal"
+ font.italic: if(1) false
+ font.underline: if(1) false
+ font.overline: if(1) false
+ font.strikeout: if(1) false
+ font.pointSize: if(1) 15
+ font.capitalization: "AllLowercase"
+ font.letterSpacing: if(1) 9.7
+ font.wordSpacing: if(1) 11.2
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
new file mode 100644
index 0000000000..94292302cc
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
@@ -0,0 +1,35 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_m11: matrix.m11
+ property real v_m12: matrix.m12
+ property real v_m13: matrix.m13
+ property real v_m14: matrix.m14
+ property real v_m21: matrix.m21
+ property real v_m22: matrix.m22
+ property real v_m23: matrix.m23
+ property real v_m24: matrix.m24
+ property real v_m31: matrix.m31
+ property real v_m32: matrix.m32
+ property real v_m33: matrix.m33
+ property real v_m34: matrix.m34
+ property real v_m41: matrix.m41
+ property real v_m42: matrix.m42
+ property real v_m43: matrix.m43
+ property real v_m44: matrix.m44
+ property variant copy: matrix
+ property string tostring: matrix.toString()
+
+ // compare to string
+ property bool equalsString: (matrix == tostring)
+
+ // compare matrix4x4s to various value types
+ property bool equalsColor: (matrix == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (matrix == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (matrix == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (matrix == Qt.point(10, 4)) // false
+ property bool equalsRect: (matrix == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (matrix == matrix) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
new file mode 100644
index 0000000000..6c4a68258c
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
@@ -0,0 +1,22 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_m11: matrix.m11
+ property real v_m12: matrix.m12
+ property real v_m13: matrix.m13
+ property real v_m14: matrix.m14
+ property real v_m21: matrix.m21
+ property real v_m22: matrix.m22
+ property real v_m23: matrix.m23
+ property real v_m24: matrix.m24
+ property real v_m31: matrix.m31
+ property real v_m32: matrix.m32
+ property real v_m33: matrix.m33
+ property real v_m34: matrix.m34
+ property real v_m41: matrix.m41
+ property real v_m42: matrix.m42
+ property real v_m43: matrix.m43
+ property real v_m44: matrix.m44
+ property variant copy: matrix
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
new file mode 100644
index 0000000000..2a9f154d6f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
@@ -0,0 +1,21 @@
+import Test 1.0
+
+MyTypeObject {
+ matrix.m11: if (true) 11
+ matrix.m12: if (true) 12
+ matrix.m13: if (true) 13
+ matrix.m14: if (true) 14
+ matrix.m21: if (true) 21
+ matrix.m22: if (true) 22
+ matrix.m23: if (true) 23
+ matrix.m24: if (true) 24
+ matrix.m31: if (true) 31
+ matrix.m32: if (true) 32
+ matrix.m33: if (true) 33
+ matrix.m34: if (true) 34
+ matrix.m41: if (true) 41
+ matrix.m42: if (true) 42
+ matrix.m43: if (true) 43
+ matrix.m44: if (true) 44
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
new file mode 100644
index 0000000000..c0041b4bb1
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
@@ -0,0 +1,22 @@
+import Test 1.0
+
+MyTypeObject {
+ property int p_x: point.x
+ property int p_y: point.y
+ property variant copy: point
+ property string tostring: point.toString()
+
+ // compare to string
+ property bool equalsString: (point == tostring)
+
+ // compare points to various value types
+ property bool equalsColor: (point == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (point == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (point == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (point == Qt.point(10, 4)) // true
+ property bool equalsRect: (point == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (point == point) // true
+ property bool equalsOther: (point == Qt.point(15, 4)) // false
+ property bool pointEqualsPointf: (point == pointfpoint) // true
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_read.qml b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
new file mode 100644
index 0000000000..4bb6c5384c
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int p_x: point.x
+ property int p_y: point.y
+ property variant copy: point
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_write.qml b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
new file mode 100644
index 0000000000..063525a6f0
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ point.x: if (true) 11
+ point.y: if (true) 12
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
new file mode 100644
index 0000000000..0d70137934
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
@@ -0,0 +1,22 @@
+import Test 1.0
+
+MyTypeObject {
+ property int p_x: point.x
+ property int p_y: point.y
+ property variant copy: point
+ property string tostring: pointf.toString()
+
+ // compare to string
+ property bool equalsString: (pointf == tostring)
+
+ // compare pointfs to various value types
+ property bool equalsColor: (pointf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (pointf == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (pointf == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (pointf == Qt.point(11.3, -10.9)) // true
+ property bool equalsRect: (pointf == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (pointf == pointf) // true
+ property bool equalsOther: (pointf == Qt.point(6.3, -4.9)) // false
+ property bool pointfEqualsPoint: (pointfpoint == point) // true
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
new file mode 100644
index 0000000000..0eab6daabe
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property real p_x: pointf.x
+ property real p_y: pointf.y
+ property variant copy: pointf
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
new file mode 100644
index 0000000000..9ee3fc1bda
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ pointf.x: if (true) 6.8
+ pointf.y: if (true) 9.3
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
new file mode 100644
index 0000000000..0e82f596af
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
@@ -0,0 +1,23 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_scalar: quaternion.scalar
+ property real v_x: quaternion.x
+ property real v_y: quaternion.y
+ property real v_z: quaternion.z
+ property variant copy: quaternion
+ property string tostring: quaternion.toString()
+
+ // compare to string
+ property bool equalsString: (quaternion == tostring)
+
+ // compare quaternions to various value types
+ property bool equalsColor: (quaternion == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (quaternion == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (quaternion == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (quaternion == Qt.point(10, 4)) // false
+ property bool equalsRect: (quaternion == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (quaternion == quaternion) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
new file mode 100644
index 0000000000..d1a21dc926
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_scalar: quaternion.scalar
+ property real v_x: quaternion.x
+ property real v_y: quaternion.y
+ property real v_z: quaternion.z
+ property variant copy: quaternion
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
new file mode 100644
index 0000000000..0c3e5afd98
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ quaternion.scalar: if (true) 88.5
+ quaternion.x: if (true) -0.3
+ quaternion.y: if (true) -12.9
+ quaternion.z: if (true) 907.4
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
new file mode 100644
index 0000000000..c511c2dfc4
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
@@ -0,0 +1,25 @@
+import Test 1.0
+
+MyTypeObject {
+ property int r_x: rect.x
+ property int r_y: rect.y
+ property int r_width: rect.width
+ property int r_height: rect.height
+ property variant copy: rect
+ property string tostring: rect.toString()
+
+ // compare to string
+ property bool equalsString: (rect == tostring)
+
+ // compare rects to various value types
+ property bool equalsColor: (rect == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (rect == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (rect == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (rect == Qt.point(10, 4)) // false
+ property bool equalsRect: (rect == Qt.rect(2, 3, 109, 102)) // true
+
+ property bool equalsSelf: (rect == rect) // true
+ property bool equalsOther: (rect == Qt.rect(6, 9, 99, 92)) // false
+ property bool rectEqualsRectf: (rect == rectfrect) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
new file mode 100644
index 0000000000..c3b37a7099
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property int r_x: rect.x
+ property int r_y: rect.y
+ property int r_width: rect.width
+ property int r_height: rect.height
+ property variant copy: rect
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
new file mode 100644
index 0000000000..8add45305c
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ rect.x: if (true) 1234
+ rect.y: if (true) 7
+ rect.width: if (true) 56
+ rect.height: if (true) 63
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
new file mode 100644
index 0000000000..6ac4049558
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
@@ -0,0 +1,25 @@
+import Test 1.0
+
+MyTypeObject {
+ property real r_x: rectf.x
+ property real r_y: rectf.y
+ property real r_width: rectf.width
+ property real r_height: rectf.height
+ property variant copy: rectf
+ property string tostring: rectf.toString()
+
+ // compare to string
+ property bool equalsString: (rectf == tostring)
+
+ // compare rectfs to various value types
+ property bool equalsColor: (rectf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (rectf == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (rectf == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (rectf == Qt.point(10, 4)) // false
+ property bool equalsRect: (rectf == Qt.rect(103.8, 99.2, 88.1, 77.6)) // true
+
+ property bool equalsSelf: (rectf == rectf) // true
+ property bool equalsOther: (rectf == Qt.rect(13.8, 9.2, 78.7, 96.2)) // false
+ property bool rectfEqualsRect: (rectfrect == rect) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
new file mode 100644
index 0000000000..6ff3ce30bf
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real r_x: rectf.x
+ property real r_y: rectf.y
+ property real r_width: rectf.width
+ property real r_height: rectf.height
+ property variant copy: rectf
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
new file mode 100644
index 0000000000..1e6ff4ff90
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ rectf.x: if (true) 70.1
+ rectf.y: if (true) -113.2
+ rectf.width: if (true) 80924.8
+ rectf.height: if (true) 99.2
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
new file mode 100644
index 0000000000..1f9816f666
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
@@ -0,0 +1,17 @@
+import Test 1.0
+import QtQuick 2.0
+
+MyTypeObject {
+ property bool test1: false;
+ property bool test2: false;
+
+ Component.onCompleted: {
+ var a = method();
+
+ test1 = (a.width == 13)
+ test2 = (a.height == 14)
+
+ size = a;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
new file mode 100644
index 0000000000..cbecb4379a
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+import Test 1.0
+
+MyTypeObject {
+ property int valuePre;
+ property int valuePost;
+
+ Component.onCompleted: { valuePre = rect.x; rect.x = 19; valuePost = rect.x; }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
new file mode 100644
index 0000000000..42fccfac5a
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
@@ -0,0 +1,14 @@
+import Test 1.0
+
+MyTypeObject {
+ property variant object
+ object: MyTypeObject {
+ rect.x: 19
+ rect.y: 33
+ rect.width: 5
+ rect.height: 99
+ }
+
+ onRunScript: rect = object.rect
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
new file mode 100644
index 0000000000..1fd4711c15
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
@@ -0,0 +1,23 @@
+import Test 1.0
+
+MyTypeObject {
+ property int s_width: size.width
+ property int s_height: size.height
+ property variant copy: size
+ property string tostring: size.toString()
+
+ // compare to string
+ property bool equalsString: (size == tostring)
+
+ // compare sizes to various value types
+ property bool equalsColor: (size == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (size == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (size == Qt.size(1912, 1913)) // true
+ property bool equalsPoint: (size == Qt.point(10, 4)) // false
+ property bool equalsRect: (size == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (size == size) // true
+ property bool equalsOther: (size == Qt.size(1212, 1313)) // false
+ property bool sizeEqualsSizef: (size == sizefsize) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_read.qml b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
new file mode 100644
index 0000000000..a49fd9f760
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int s_width: size.width
+ property int s_height: size.height
+ property variant copy: size
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_write.qml b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
new file mode 100644
index 0000000000..2f9d10e45f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ size.width: if (true) 13
+ size.height: if (true) 88
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
new file mode 100644
index 0000000000..c74a049454
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
@@ -0,0 +1,24 @@
+import Test 1.0
+
+MyTypeObject {
+ property real s_width: sizef.width
+ property real s_height: sizef.height
+ property variant copy: sizef
+ property string tostring: sizef.toString()
+
+ // compare to string
+ property bool equalsString: (sizef == tostring)
+
+ // compare sizefs to various value types
+ property bool equalsColor: (sizef == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (sizef == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (sizef == Qt.size(0.1, 100923.2)) // true
+ property bool equalsPoint: (sizef == Qt.point(10, 4)) // false
+ property bool equalsRect: (sizef == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (sizef == sizef) // true
+ property bool equalsOther: (size == Qt.size(3.1, 923.2)) // false
+ property bool sizefEqualsSize: (sizefsize == size) // true
+}
+
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
new file mode 100644
index 0000000000..96cd425f17
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real s_width: sizef.width
+ property real s_height: sizef.height
+ property variant copy: sizef
+}
+
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
new file mode 100644
index 0000000000..f16f0bdf93
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ sizef.width: if (true) 44.3
+ sizef.height: if (true) 92.8
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
new file mode 100644
index 0000000000..7f708a0899
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int s_width: sizereadonly.width
+ property int s_height: sizereadonly.height
+ property variant copy: sizereadonly
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
new file mode 100644
index 0000000000..3254557014
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ sizereadonly: "13x88"
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
new file mode 100644
index 0000000000..656d718b05
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ sizereadonly.width: if (true) 13
+ sizereadonly.height: if (true) 88
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
new file mode 100644
index 0000000000..b8e3f0d41b
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ sizereadonly.width: 13
+ sizereadonly.height: 88
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
new file mode 100644
index 0000000000..68b54b571e
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+import QtQuick 2.0
+
+MyTypeObject {
+ Component.onCompleted: {
+ sizereadonly.width = 13;
+ }
+}
+
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
new file mode 100644
index 0000000000..b687f89eef
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+
+MyTypeObject {
+ rect.x: 9
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
new file mode 100644
index 0000000000..0897847d2d
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int value: 13;
+
+ MyOffsetValueInterceptor on rect.x {}
+ rect.x: value
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
new file mode 100644
index 0000000000..717f3502c0
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
@@ -0,0 +1,5 @@
+import Test 1.0
+
+MyTypeObject {
+ MyConstantValueSource on rect.x {}
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
new file mode 100644
index 0000000000..9b56abbbed
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+QtObject {
+ property int x;
+ property int y;
+ property int z;
+
+ Component.onCompleted: {
+ var vec3 = Qt.vector3d(1, 2, 3);
+ x = vec3.x;
+ y = vec3.y;
+ z = vec3.z;
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
new file mode 100644
index 0000000000..a08f3db94f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real s_width: variant.width
+ property real s_height: variant.height
+ property variant copy: variant
+}
+
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
new file mode 100644
index 0000000000..eb8fb5bb76
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
@@ -0,0 +1,21 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector2.x
+ property real v_y: vector2.y
+ property variant copy: vector2
+ property string tostring: vector2.toString()
+
+ // compare to string
+ property bool equalsString: (vector2 == tostring)
+
+ // compare vector2ds to various value types
+ property bool equalsColor: (vector2 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (vector2 == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (vector2 == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (vector2 == Qt.point(10, 4)) // false
+ property bool equalsRect: (vector2 == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (vector2 == vector2)
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
new file mode 100644
index 0000000000..fc315f7abf
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector2.x
+ property real v_y: vector2.y
+ property variant copy: vector2
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
new file mode 100644
index 0000000000..f0e35ff200
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ vector2.x: if (true) -0.3
+ vector2.y: if (true) -12.9
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
new file mode 100644
index 0000000000..7bda1d17f4
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
@@ -0,0 +1,23 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector.x
+ property real v_y: vector.y
+ property real v_z: vector.z
+ property variant copy: vector
+ property string tostring: vector.toString()
+
+ // compare to string
+ property bool equalsString: (vector == tostring)
+
+ // compare vector3ds to various value types
+ property bool equalsColor: (vector == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (vector == Qt.vector3d(23.88, 3.1, 4.3)) // true
+ property bool equalsSize: (vector == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (vector == Qt.point(10, 4)) // false
+ property bool equalsRect: (vector == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (vector == vector) // true
+ property bool equalsOther: (vector == Qt.vector3d(3.1, 2.2, 923.2)) // false
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
new file mode 100644
index 0000000000..f1e876dbb9
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector.x
+ property real v_y: vector.y
+ property real v_z: vector.z
+ property variant copy: vector
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
new file mode 100644
index 0000000000..9c1bf7620a
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ vector.x: if (true) -0.3
+ vector.y: if (true) -12.9
+ vector.z: if (true) 907.4
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
new file mode 100644
index 0000000000..3ea42a59ce
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
@@ -0,0 +1,23 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector4.x
+ property real v_y: vector4.y
+ property real v_z: vector4.z
+ property real v_w: vector4.w
+ property variant copy: vector4
+ property string tostring: vector4.toString()
+
+ // compare to string
+ property bool equalsString: (vector4 == tostring)
+
+ // compare vector4ds to various value types
+ property bool equalsColor: (vector4 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false
+ property bool equalsVector3d: (vector4 == Qt.vector3d(1, 2, 3)) // false
+ property bool equalsSize: (vector4 == Qt.size(1912, 1913)) // false
+ property bool equalsPoint: (vector4 == Qt.point(10, 4)) // false
+ property bool equalsRect: (vector4 == Qt.rect(2, 3, 109, 102)) // false
+
+ property bool equalsSelf: (vector4 == vector4) // true
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
new file mode 100644
index 0000000000..f9d5d6053e
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
@@ -0,0 +1,10 @@
+import Test 1.0
+
+MyTypeObject {
+ property real v_x: vector4.x
+ property real v_y: vector4.y
+ property real v_z: vector4.z
+ property real v_w: vector4.w
+ property variant copy: vector4
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
new file mode 100644
index 0000000000..548698126d
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
@@ -0,0 +1,9 @@
+import Test 1.0
+
+MyTypeObject {
+ vector4.x: if (true) -0.3
+ vector4.y: if (true) -12.9
+ vector4.z: if (true) 907.4
+ vector4.w: if (true) 88.5
+}
+
diff --git a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
new file mode 100644
index 0000000000..6051f65936
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmlvaluetypes
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_qqmlvaluetypes.cpp \
+ testtypes.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.cpp b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
new file mode 100644
index 0000000000..ef9f268b2f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+void registerTypes()
+{
+ qmlRegisterType<MyTypeObject>("Test", 1, 0, "MyTypeObject");
+ qmlRegisterType<MyConstantValueSource>("Test", 1, 0, "MyConstantValueSource");
+ qmlRegisterType<MyOffsetValueInterceptor>("Test", 1, 0, "MyOffsetValueInterceptor");
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h
new file mode 100644
index 0000000000..813c58567f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <QMatrix4x4>
+#include <QFont>
+#include <QColor>
+#include <qqml.h>
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
+ Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
+ Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
+ Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
+ Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
+ Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
+ Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
+ Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
+ Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
+ Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
+ Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_pointfpoint(10.0, 4.0),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_sizefsize(1912.0, 1913.0),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_rectfrect(2.0, 3.0, 109.0, 102.0),
+ m_vector2(32.88, 1.3),
+ m_vector(23.88, 3.1, 4.3),
+ m_vector4(54.2, 23.88, 3.1, 4.3),
+ m_quaternion(4.3, 54.2, 23.88, 3.1),
+ m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
+ {
+ m_font.setFamily("Arial");
+ m_font.setBold(true);
+ m_font.setWeight(QFont::DemiBold);
+ m_font.setItalic(true);
+ m_font.setUnderline(true);
+ m_font.setOverline(true);
+ m_font.setStrikeOut(true);
+ m_font.setPointSize(29);
+ m_font.setCapitalization(QFont::AllLowercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ m_color.setRedF(0.2);
+ m_color.setGreenF(0.88);
+ m_color.setBlueF(0.6);
+ m_color.setAlphaF(0.34);
+ }
+
+ QPoint m_point;
+ QPoint point() const { return m_point; }
+ void setPoint(const QPoint &v) { m_point = v; emit changed(); }
+
+ QPointF m_pointf;
+ QPointF pointf() const { return m_pointf; }
+ void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
+
+ QPointF m_pointfpoint;
+ QPointF pointfpoint() const { return m_pointfpoint; }
+ void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
+
+ QSize m_size;
+ QSize size() const { return m_size; }
+ void setSize(const QSize &v) { m_size = v; emit changed(); }
+
+ QSizeF m_sizef;
+ QSizeF sizef() const { return m_sizef; }
+ void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
+
+ QSizeF m_sizefsize;
+ QSizeF sizefsize() const { return m_sizefsize; }
+ void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
+
+ QRect m_rect;
+ QRect rect() const { return m_rect; }
+ void setRect(const QRect &v) { m_rect = v; emit changed(); }
+
+ QRectF m_rectf;
+ QRectF rectf() const { return m_rectf; }
+ void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
+
+ QRectF m_rectfrect;
+ QRectF rectfrect() const { return m_rectfrect; }
+ void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
+
+ QVector2D m_vector2;
+ QVector2D vector2() const { return m_vector2; }
+ void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+
+ QVector4D m_vector4;
+ QVector4D vector4() const { return m_vector4; }
+ void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
+
+ QQuaternion m_quaternion;
+ QQuaternion quaternion() const { return m_quaternion; }
+ void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
+
+ QMatrix4x4 m_matrix;
+ QMatrix4x4 matrix() const { return m_matrix; }
+ void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; emit changed(); }
+
+ QColor m_color;
+ QColor color() const { return m_color; }
+ void setColor(const QColor &v) { m_color = v; emit changed(); }
+
+ QVariant variant() const { return sizef(); }
+
+ void emitRunScript() { emit runScript(); }
+
+signals:
+ void changed();
+ void runScript();
+
+public slots:
+ QSize method() { return QSize(13, 14); }
+};
+
+class MyConstantValueSource : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ virtual void setTarget(const QQmlProperty &p) { p.write(3345); }
+};
+
+class MyOffsetValueInterceptor : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+public:
+ virtual void setTarget(const QQmlProperty &p) { prop = p; }
+ virtual void write(const QVariant &value) { QQmlPropertyPrivate::write(prop, value.toInt() + 13, QQmlPropertyPrivate::BypassInterceptor); }
+
+private:
+ QQmlProperty prop;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
new file mode 100644
index 0000000000..695dbe4147
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -0,0 +1,1306 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+#include "testtypes.h"
+
+QT_BEGIN_NAMESPACE
+extern int qt_defaultDpi();
+QT_END_NAMESPACE
+
+class tst_qqmlvaluetypes : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlvaluetypes() {}
+
+private slots:
+ void initTestCase();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void sizereadonly();
+ void rect();
+ void rectf();
+ void vector2d();
+ void vector3d();
+ void vector4d();
+ void quaternion();
+ void matrix4x4();
+ void font();
+ void color();
+ void variant();
+
+ void bindingAssignment();
+ void bindingRead();
+ void staticAssignment();
+ void scriptAccess();
+ void autoBindingRemoval();
+ void valueSources();
+ void valueInterceptors();
+ void bindingConflict();
+ void deletedObject();
+ void bindingVariantCopy();
+ void scriptVariantCopy();
+ void cppClasses();
+ void enums();
+ void conflictingBindings();
+ void returnValues();
+ void varAssignment();
+ void bindingsSpliceCorrectly();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlvaluetypes::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+void tst_qqmlvaluetypes::point()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("point_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toInt(), 10);
+ QCOMPARE(object->property("p_y").toInt(), 4);
+ QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPoint(10, 4)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointEqualsPointf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::pointf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("p_x").toDouble()), float(11.3));
+ QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9));
+ QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPointF(11.3, -10.9)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointfEqualsPoint").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::size()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("size_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSize(1912, 1913)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizeEqualsSizef").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::sizef()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
+ QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSizeF(0.1, 100923)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizefEqualsSize").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::variant()
+{
+ QQmlComponent component(&engine, testFileUrl("variant_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
+ QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+}
+
+void tst_qqmlvaluetypes::sizereadonly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object);
+
+ QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913));
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toInt(), 2);
+ QCOMPARE(object->property("r_y").toInt(), 3);
+ QCOMPARE(object->property("r_width").toInt(), 109);
+ QCOMPARE(object->property("r_height").toInt(), 102);
+ QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRect(2, 3, 109, 102)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectEqualsRectf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rectf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("r_x").toDouble()), float(103.8));
+ QCOMPARE(float(object->property("r_y").toDouble()), float(99.2));
+ QCOMPARE(float(object->property("r_width").toDouble()), float(88.1));
+ QCOMPARE(float(object->property("r_height").toDouble()), float(77.6));
+ QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectfEqualsRect").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector2d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector2D(32.88, 1.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector3d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), true);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector4d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::quaternion()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::matrix4x4()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
+ QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
+ QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
+ QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
+ QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
+ QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
+ QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
+ QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
+ QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
+ QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
+ QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
+ QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
+ QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
+ QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
+ QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
+ QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
+ QCOMPARE(object->property("copy"),
+ QVariant(QMatrix4x4(1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
+ 21, 22, 23, 24,
+ 31, 32, 33, 34,
+ 41, 42, 43, 44));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::font()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("font_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("f_family").toString(), object->font().family());
+ QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
+ QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
+ QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
+ QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
+ QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
+ QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
+ QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
+ QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)));
+ QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
+ QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
+ QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
+
+ QCOMPARE(object->property("copy"), QVariant(object->font()));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QFont font;
+ font.setFamily("Helvetica");
+ font.setBold(false);
+ font.setWeight(QFont::Normal);
+ font.setItalic(false);
+ font.setUnderline(false);
+ font.setStrikeOut(false);
+ font.setPointSize(15);
+ font.setCapitalization(QFont::AllLowercase);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
+ font.setWordSpacing(11.2);
+
+ QFont f = object->font();
+ QCOMPARE(f.family(), font.family());
+ QCOMPARE(f.bold(), font.bold());
+ QCOMPARE(f.weight(), font.weight());
+ QCOMPARE(f.italic(), font.italic());
+ QCOMPARE(f.underline(), font.underline());
+ QCOMPARE(f.strikeOut(), font.strikeOut());
+ QCOMPARE(f.pointSize(), font.pointSize());
+ QCOMPARE(f.capitalization(), font.capitalization());
+ QCOMPARE(f.letterSpacing(), font.letterSpacing());
+ QCOMPARE(f.wordSpacing(), font.wordSpacing());
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+
+ // Test pixelSize and pointSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.4.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.5.qml"));
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
+ QVERIFY(object1 != 0);
+ MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2");
+ QVERIFY(object2 != 0);
+
+ QCOMPARE(object1->font().pixelSize(), 19);
+ QCOMPARE(object2->font().pointSize(), 14);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')');
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::color()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("color_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
+ QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
+ QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
+ QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
+ QColor comparison;
+ comparison.setRedF(0.2);
+ comparison.setGreenF(0.88);
+ comparison.setBlueF(0.6);
+ comparison.setAlphaF(0.34);
+ QCOMPARE(object->property("copy"), QVariant(comparison));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QColor newColor;
+ newColor.setRedF(0.5);
+ newColor.setGreenF(0.38);
+ newColor.setBlueF(0.3);
+ newColor.setAlphaF(0.7);
+ QCOMPARE(object->color(), newColor);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QString colorString("#33e199");
+ QCOMPARE(object->property("colorToString").toString(), colorString);
+ QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
+ QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false);
+ QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false);
+ QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false);
+ QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false);
+
+ QCOMPARE(object->property("equalsColor").toBool(), true);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+
+ // Color == Property and Property == Color should return the same result.
+ QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool());
+ QCOMPARE(object->property("colorEqualsCopy").toBool(), true);
+ QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool());
+
+ delete object;
+ }
+}
+
+// Test bindings can write to value types
+void tst_qqmlvaluetypes::bindingAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 92);
+
+ delete object;
+}
+
+// Test bindings can read from value types
+void tst_qqmlvaluetypes::bindingRead()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingRead.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 2);
+
+ object->setRect(QRect(19, 3, 88, 2));
+
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+}
+
+// Test static values can assign to value types
+void tst_qqmlvaluetypes::staticAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("staticAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 9);
+
+ delete object;
+}
+
+// Test scripts can read/write value types
+void tst_qqmlvaluetypes::scriptAccess()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptAccess.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("valuePre").toInt(), 2);
+ QCOMPARE(object->rect().x(), 19);
+ QCOMPARE(object->property("valuePost").toInt(), 19);
+
+ delete object;
+}
+
+// Test that assigning a constant from script removes any binding
+void tst_qqmlvaluetypes::autoBindingRemoval()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect().x(), 42);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 42);
+
+ delete object;
+ }
+
+ /*
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
+
+ QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ delete object;
+ }
+*/
+}
+
+// Test that property value sources assign to value types
+void tst_qqmlvaluetypes::valueSources()
+{
+ QQmlComponent component(&engine, testFileUrl("valueSources.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 3345);
+
+ delete object;
+}
+
+static void checkNoErrors(QQmlComponent& component)
+{
+ QList<QQmlError> errors = component.errors();
+ if (errors.isEmpty())
+ return;
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
+ }
+}
+
+// Test that property value interceptors can be applied to value types
+void tst_qqmlvaluetypes::valueInterceptors()
+{
+ QQmlComponent component(&engine, testFileUrl("valueInterceptors.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->setProperty("value", 99);
+
+ QCOMPARE(object->rect().x(), 112);
+
+ delete object;
+}
+
+// Test that you can't assign a binding to the "root" value type, and a sub-property
+void tst_qqmlvaluetypes::bindingConflict()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingConflict.qml"));
+ QCOMPARE(component.isError(), true);
+}
+
+#define CPP_TEST(type, v) \
+{ \
+ type *t = new type; \
+ QVariant value(v); \
+ t->setValue(value); \
+ QCOMPARE(t->value(), value); \
+ delete t; \
+}
+
+// Test that accessing a reference to a valuetype after the owning object is deleted
+// doesn't crash
+void tst_qqmlvaluetypes::deletedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "Test: 2");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(dObject != 0);
+ delete dObject;
+
+ QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
+ object->emitRunScript();
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in a binding
+void tst_qqmlvaluetypes::bindingVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in script
+void tst_qqmlvaluetypes::scriptVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+
+// Test that the value type classes can be used manually
+void tst_qqmlvaluetypes::cppClasses()
+{
+ CPP_TEST(QQmlPointValueType, QPoint(19, 33));
+ CPP_TEST(QQmlPointFValueType, QPointF(33.6, -23));
+ CPP_TEST(QQmlSizeValueType, QSize(-100, 18));
+ CPP_TEST(QQmlSizeFValueType, QSizeF(-100.7, 18.2));
+ CPP_TEST(QQmlRectValueType, QRect(13, 39, 10928, 88));
+ CPP_TEST(QQmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
+ CPP_TEST(QQmlVector2DValueType, QVector2D(19.7, 1002));
+ CPP_TEST(QQmlVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QQmlVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlMatrix4x4ValueType,
+ QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
+ CPP_TEST(QQmlFontValueType, QFont("Helvetica"));
+
+}
+
+void tst_qqmlvaluetypes::enums()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.5.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+}
+
+// Tests switching between "conflicting" bindings (eg. a binding on the core
+// property, to a binding on the value-type sub-property)
+void tst_qqmlvaluetypes::conflictingBindings()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::returnValues()
+{
+ QQmlComponent component(&engine, testFileUrl("returnValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("size").toSize(), QSize(13, 14));
+
+ delete object;
+}
+
+void tst_qqmlvaluetypes::varAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("varAssignment.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("x").toInt(), 1);
+ QCOMPARE(object->property("y").toInt(), 2);
+ QCOMPARE(object->property("z").toInt(), 3);
+
+ delete object;
+}
+
+// Test bindings splice together correctly
+void tst_qqmlvaluetypes::bindingsSpliceCorrectly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qqmlvaluetypes)
+
+#include "tst_qqmlvaluetypes.moc"