summaryrefslogtreecommitdiffstats
path: root/tests/auto/math3d/qmatrixnxn
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-07-29 23:42:25 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-07-29 23:42:25 (GMT)
commitb2c0b95d38b75035c60a20fdc6bfa5f47371f801 (patch)
tree80c1afc7ff78169e903e4de87e503ca8b9602096 /tests/auto/math3d/qmatrixnxn
parented436d4e6e1bffa4a9dd6032ef9f745a735fc8fd (diff)
downloadQt-b2c0b95d38b75035c60a20fdc6bfa5f47371f801.zip
Qt-b2c0b95d38b75035c60a20fdc6bfa5f47371f801.tar.gz
Qt-b2c0b95d38b75035c60a20fdc6bfa5f47371f801.tar.bz2
Add math3d unit tests for QObject properties and metatypes
Reviewed-by: trustme
Diffstat (limited to 'tests/auto/math3d/qmatrixnxn')
-rw-r--r--tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index d799c1b..fe1d0db 100644
--- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -170,6 +170,9 @@ private slots:
void mapRect_data();
void mapRect();
+ void properties();
+ void metaTypes();
+
private:
static void setMatrix(QMatrix2x2& m, const qreal *values);
static void setMatrixDirect(QMatrix2x2& m, const qreal *values);
@@ -3331,6 +3334,50 @@ void tst_QMatrix::mapRect()
QVERIFY(mri == tri);
}
+class tst_QMatrix4x4Properties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix)
+public:
+ tst_QMatrix4x4Properties(QObject *parent = 0) : QObject(parent) {}
+
+ QMatrix4x4 matrix() const { return m; }
+ void setMatrix(const QMatrix4x4& value) { m = value; }
+
+private:
+ QMatrix4x4 m;
+};
+
+// Test getting and setting matrix properties via the metaobject system.
+void tst_QMatrix::properties()
+{
+ tst_QMatrix4x4Properties obj;
+
+ QMatrix4x4 m1(uniqueValues4);
+ obj.setMatrix(m1);
+
+ QMatrix4x4 m2 = qVariantValue<QMatrix4x4>(obj.property("matrix"));
+ QVERIFY(isSame(m2, uniqueValues4));
+
+ QMatrix4x4 m3(transposedValues4);
+ obj.setProperty("matrix", qVariantFromValue(m3));
+
+ m2 = qVariantValue<QMatrix4x4>(obj.property("matrix"));
+ QVERIFY(isSame(m2, transposedValues4));
+}
+
+void tst_QMatrix::metaTypes()
+{
+ QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)),
+ QByteArray("QMatrix4x4"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4));
+
+ QVERIFY(qMetaTypeId<QMatrix4x4>() == QMetaType::QMatrix4x4);
+}
+
QTEST_APPLESS_MAIN(tst_QMatrix)
#include "tst_qmatrixnxn.moc"