diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-06-09 09:41:38 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-06-09 09:41:38 (GMT) |
commit | bc3abd32ed1c5a872d7a7817c1af0a13f442d536 (patch) | |
tree | 37d617a7baf54844bb4c396628b867ecb3b0b29e /tests/auto/qobject/tst_qobject.cpp | |
parent | 6d25d222b2bb418139e123b59366db908ee3188a (diff) | |
parent | 91ceb21d1d5f6447a47853b6625fb51d2f21cf16 (diff) | |
download | Qt-bc3abd32ed1c5a872d7a7817c1af0a13f442d536.zip Qt-bc3abd32ed1c5a872d7a7817c1af0a13f442d536.tar.gz Qt-bc3abd32ed1c5a872d7a7817c1af0a13f442d536.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qt-main/qgraphicssceneindex
Diffstat (limited to 'tests/auto/qobject/tst_qobject.cpp')
-rw-r--r-- | tests/auto/qobject/tst_qobject.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 399d021..d76c7d4 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -106,6 +106,7 @@ private slots: void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); + void qrealProperty(); void property(); void recursiveSignalEmission(); void blockingQueuedConnection(); @@ -1113,6 +1114,7 @@ class PropertyObject : public QObject Q_PROPERTY(QVariant variant READ variant WRITE setVariant) Q_PROPERTY(CustomType* custom READ custom WRITE setCustom) Q_PROPERTY(float myFloat READ myFloat WRITE setMyFloat) + Q_PROPERTY(qreal myQReal READ myQReal WRITE setMyQReal) public: enum Alpha { @@ -1148,6 +1150,9 @@ public: void setMyFloat(float value) { m_float = value; } inline float myFloat() const { return m_float; } + void setMyQReal(qreal value) { m_qreal = value; } + qreal myQReal() const { return m_qreal; } + private: Alpha m_alpha; Priority m_priority; @@ -1156,6 +1161,7 @@ private: QVariant m_variant; CustomType *m_custom; float m_float; + qreal m_qreal; }; Q_DECLARE_METATYPE(PropertyObject::Priority) @@ -2348,6 +2354,27 @@ void tst_QObject::floatProperty() QVERIFY(qVariantValue<float>(v) == 128.0f); } +void tst_QObject::qrealProperty() +{ + PropertyObject obj; + const int idx = obj.metaObject()->indexOfProperty("myQReal"); + QVERIFY(idx > 0); + QMetaProperty prop = obj.metaObject()->property(idx); + QVERIFY(prop.isValid()); + QVERIFY(prop.type() == uint(QMetaType::type("qreal"))); + QVERIFY(!prop.write(&obj, QVariant("Hello"))); + + QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVariant v = prop.read(&obj); + QCOMPARE(v.userType(), qMetaTypeId<qreal>()); + QVERIFY(qVariantValue<qreal>(v) == 128.0); + + QVERIFY(prop.write(&obj, qVariantFromValue(double(127)))); + v = prop.read(&obj); + QCOMPARE(v.userType(), qMetaTypeId<qreal>()); + QVERIFY(qVariantValue<qreal>(v) == 127.0); +} + class DynamicPropertyObject : public PropertyObject { public: |