aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-08-02 10:04:16 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-02 08:50:21 +0200
commit0db6db0263defcd6ff84769b7d927d5a51606f6c (patch)
treeec30dca485b9cf576a70d4b232d6525f3d569c90 /tests
parent29e71ca376f48bafc2105b656a702f3edd4501a8 (diff)
Add support for comparing value-type properties
This commit allows value-types to be compared with each other and with variants. It also adds a toString() function for each value type, to allow conversion to (and comparison with) string. Task-number: QTBUG-14731 Change-Id: I5bde2820917b2fe19b581724977398680617de34 Reviewed-on: http://codereview.qt.nokia.com/1636 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml31
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml35
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml22
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml22
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml25
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml25
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml24
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml21
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml23
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h18
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp229
14 files changed, 544 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml
new file mode 100644
index 0000000000..efbb0e3d0b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml
new file mode 100644
index 0000000000..94292302cc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/point_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml
new file mode 100644
index 0000000000..c0041b4bb1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/pointf_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml
new file mode 100644
index 0000000000..0d70137934
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml
new file mode 100644
index 0000000000..0e82f596af
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/rect_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml
new file mode 100644
index 0000000000..c511c2dfc4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/rectf_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml
new file mode 100644
index 0000000000..6ac4049558
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/size_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml
new file mode 100644
index 0000000000..1fd4711c15
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/sizef_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml
new file mode 100644
index 0000000000..c74a049454
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml
new file mode 100644
index 0000000000..eb8fb5bb76
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml
new file mode 100644
index 0000000000..7bda1d17f4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml
new file mode 100644
index 0000000000..3ea42a59ce
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
index 6d6f868617..1efab0c423 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
@@ -65,11 +65,14 @@ class MyTypeObject : public QObject
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)
@@ -82,10 +85,13 @@ 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),
@@ -113,6 +119,10 @@ public:
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(); }
@@ -121,6 +131,10 @@ public:
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(); }
@@ -129,6 +143,10 @@ public:
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(); }
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index aa4c014d99..5869310ef6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -134,6 +134,26 @@ void tst_qdeclarativevaluetypes::point()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::pointf()
@@ -159,6 +179,26 @@ void tst_qdeclarativevaluetypes::pointf()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::size()
@@ -184,6 +224,26 @@ void tst_qdeclarativevaluetypes::size()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::sizef()
@@ -209,6 +269,26 @@ void tst_qdeclarativevaluetypes::sizef()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::variant()
@@ -293,6 +373,26 @@ void tst_qdeclarativevaluetypes::rect()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::rectf()
@@ -320,6 +420,26 @@ void tst_qdeclarativevaluetypes::rectf()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::vector2d()
@@ -345,6 +465,24 @@ void tst_qdeclarativevaluetypes::vector2d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::vector3d()
@@ -371,6 +509,25 @@ void tst_qdeclarativevaluetypes::vector3d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::vector4d()
@@ -398,6 +555,24 @@ void tst_qdeclarativevaluetypes::vector4d()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::quaternion()
@@ -425,6 +600,24 @@ void tst_qdeclarativevaluetypes::quaternion()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::matrix4x4()
@@ -471,6 +664,24 @@ void tst_qdeclarativevaluetypes::matrix4x4()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::font()
@@ -576,6 +787,24 @@ void tst_qdeclarativevaluetypes::font()
delete object;
}
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("font_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QFont(Arial,29,-1,0,63,1,1,1,0,0)");
+ 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;
+ }
}
// Test bindings can write to value types