diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-05-12 10:19:14 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-05-15 18:35:15 +0000 |
commit | 1c51ae2911636e61a698967fd9c6aabd28f5ceb9 (patch) | |
tree | 1ae9c4a909b2012fffac479cd99a11b3cadefed7 /tests/auto/qml/qqmlvaluetypes | |
parent | 35d8d4bc2bf84a2ea9744382a5a2eb7a51aaea3a (diff) |
Fix visibility of properties in value types
It should be possible to enumerate the properties of value types (gadgets),
in order for things like JSON.stringify(Qt.point(10, 20)) to return something
sensible.
Task-number: QTBUG-43382
Task-number: QTBUG-34878
Change-Id: I3a2c09151ebe97fd97760dfbbf5a4f58e022bc94
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 300f5b90e5..f506d0f53a 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -30,6 +30,7 @@ #include <QQmlEngine> #include <QQmlComponent> #include <QDebug> +#include <QJSValueIterator> #include <private/qquickvaluetypes_p.h> #include <private/qqmlglobal_p.h> #include "../../shared/util.h" @@ -89,6 +90,7 @@ private slots: void customValueTypeInQml(); void gadgetInheritance(); void toStringConversion(); + void enumerableProperties(); private: QQmlEngine engine; @@ -1649,6 +1651,25 @@ void tst_qqmlvaluetypes::toStringConversion() QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g)); } +void tst_qqmlvaluetypes::enumerableProperties() +{ + QJSEngine engine; + DerivedGadget g; + QJSValue value = engine.toScriptValue(g); + QSet<QString> names; + QJSValueIterator it(value); + while (it.hasNext()) { + it.next(); + const QString name = it.name(); + QVERIFY(!names.contains(name)); + names.insert(name); + } + + QCOMPARE(names.count(), 2); + QVERIFY(names.contains(QStringLiteral("baseProperty"))); + QVERIFY(names.contains(QStringLiteral("derivedProperty"))); +} + QTEST_MAIN(tst_qqmlvaluetypes) |