From 2b8042182d77241ffe7e6b4edf4e727315f93147 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 12 Mar 2020 16:28:48 +0100 Subject: Check that QJSValue to set conversion works Also, fix the check to actually test the correct capabilities by using the containerCapabilities function; testing _iteratorCapabilities only worked by chance so far. Task-number: QTBUG-82743 Change-Id: I64f20c6bf1e47737c7b927f79e1e78c1a1603741 Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 3a4fba8002..16ea659fe9 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -5696,25 +5696,31 @@ class TestItem : public QObject { Q_OBJECT Q_PROPERTY( QVector positions MEMBER m_points ) + Q_PROPERTY( QSet barrays MEMBER m_barrays ) public: TestItem() = default; QVector< QPointF > m_points; + QSet m_barrays; }; Q_DECLARE_METATYPE(QVector); +Q_DECLARE_METATYPE(QSet); void tst_qqmllanguage::arrayToContainer() { QQmlEngine engine; qmlRegisterType("qt.test", 1, 0, "TestItem"); QVector points { QPointF (2.0, 3.0) }; + QSet barrays { QByteArray("hello"), QByteArray("world") }; engine.rootContext()->setContextProperty("test", QVariant::fromValue(points)); QQmlComponent component(&engine, testFileUrl("arrayToContainer.qml")); VERIFY_ERRORS(0); - QScopedPointer root(qobject_cast(component.createWithInitialProperties( {{"vector", QVariant::fromValue(points)}} ))); + QScopedPointer root(qobject_cast(component.createWithInitialProperties( {{"vector", QVariant::fromValue(points)}, {"myset", QVariant::fromValue(barrays)} } ))); QVERIFY(root); QCOMPARE(root->m_points.at(0), QPointF (2.0, 3.0) ); + QVERIFY(root->m_barrays.contains("hello")); + QVERIFY(root->m_barrays.contains("world")); } class EnumTester : public QObject -- cgit v1.2.3