diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-14 06:14:17 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-14 06:14:17 (GMT) |
commit | 22a00ee975545704cd0d70314f45f3b3ecf7ab01 (patch) | |
tree | 316c165d37c263cc1ff237a9ef1f872dba861a39 /tests | |
parent | 4f9c026a02c2ecf0d19e7aee4ecae82e64cbaee8 (diff) | |
download | Qt-22a00ee975545704cd0d70314f45f3b3ecf7ab01.zip Qt-22a00ee975545704cd0d70314f45f3b3ecf7ab01.tar.gz Qt-22a00ee975545704cd0d70314f45f3b3ecf7ab01.tar.bz2 |
Autotest for QVariant value types
Diffstat (limited to 'tests')
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml new file mode 100644 index 0000000..a08f3db --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/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/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 86cbaa5..104d22f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -76,6 +76,7 @@ class MyTypeObject : public QObject 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(QVariant variant READ variant NOTIFY changed) public: MyTypeObject() : @@ -152,6 +153,8 @@ public: QFont font() const { return m_font; } void setFont(const QFont &v) { m_font = v; emit changed(); } + QVariant variant() const { return sizef(); } + void emitRunScript() { emit runScript(); } signals: diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index a5cf051..ce857a0 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -77,6 +77,7 @@ private slots: void quaternion(); void matrix4x4(); void font(); + void variant(); void bindingAssignment(); void bindingRead(); @@ -210,6 +211,19 @@ void tst_qdeclarativevaluetypes::sizef() } } +void tst_qdeclarativevaluetypes::variant() +{ + QDeclarativeComponent component(&engine, TEST_FILE("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_qdeclarativevaluetypes::sizereadonly() { { |