diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-19 09:29:34 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-30 10:47:17 +0200 |
commit | b9bfdea0e2c6721d2306af0ecc44f88da9988957 (patch) | |
tree | 2cfc6b8f9b43a221d0cdb4c92d0bd868696ab952 /tests/auto/qml/qjsvalue | |
parent | 975a6bff84815f536abf1324394193b8180edeaa (diff) |
QML: Un-specialcase QStringList and QVariantList conversion
Those are just regular sequences these days. They can be written back.
Drop some now-dead code and deduplicate the value type conversion code
in the process. We should try the (more common) value type conversion
before the sequence conversion, but after all the "simple" conversions.
[ChangeLog][QtQml][Important Behavior Changes] Converting a QVariantList
to a QJSValue via, for example QJSEngine::toScriptValue() does not
produce a JavaScript array anymore, but rather a better suited sequence
object that behaves almost like a JavaScript array. The only difference
is that its QJSValue::isArray() will return false now.
Fixes: QTBUG-113690
Change-Id: Ib176c34d59c45a6b5cff68d029c4b1b87d7aa192
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qjsvalue')
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 516abed9e8..1090ed9716 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1085,13 +1085,8 @@ void tst_QJSValue::toVariant() QVariantList listIn; listIn << 123 << "hello"; QJSValue array = eng.toScriptValue(listIn); - QVERIFY(array.isArray()); QCOMPARE(array.property("length").toInt(), 2); - QVariant retained = array.toVariant(QJSValue::RetainJSObjects); - QCOMPARE(retained.metaType(), QMetaType::fromType<QJSValue>()); - QVERIFY(retained.value<QJSValue>().strictlyEquals(array)); - QVariant ret = array.toVariant(); QCOMPARE(ret.typeId(), QMetaType::QVariantList); QVariantList listOut = ret.toList(); @@ -1100,7 +1095,6 @@ void tst_QJSValue::toVariant() QCOMPARE(listOut.at(i), listIn.at(i)); // round-trip conversion QJSValue array2 = eng.toScriptValue(ret); - QVERIFY(array2.isArray()); QCOMPARE(array2.property("length").toInt(), array.property("length").toInt()); for (int i = 0; i < array.property("length").toInt(); ++i) QVERIFY(array2.property(i).strictlyEquals(array.property(i))); @@ -2345,8 +2339,6 @@ void tst_QJSValue::strictlyEquals() { QJSValue var1 = eng.toScriptValue(QVariant(QStringList() << "a")); QJSValue var2 = eng.toScriptValue(QVariant(QStringList() << "a")); - QVERIFY(var1.isArray()); - QVERIFY(var2.isArray()); QVERIFY(!var1.strictlyEquals(var2)); } { |