diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-05-22 16:33:47 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-05-25 08:11:24 +0200 |
| commit | ed61e7c6d2ae80935b02c6eedc293e3b875520d7 (patch) | |
| tree | f1f39767b7c97608a45f42192e0efb475dd6fb20 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 7bdeea2c309150c8b49558b135232926d6a89c50 (diff) | |
QmlCompiler: Explicitly cast operations that result in QString
We may be using QStringBuilder, and that can be stored in QVariant (and
possibly other places).
Fixes: QTBUG-125576
Change-Id: Ib31e31591a3333e51f1d5594ee05fdb8f0744714
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 9b66143f62..53cc068e8c 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -256,6 +256,7 @@ private slots: void voidConversion(); void voidFunction(); void writeBack(); + void writeVariantMap(); }; static QByteArray arg1() @@ -5107,6 +5108,22 @@ void tst_QmlCppCodegen::writeBack() QCOMPARE(person->property("ints"), QVariant::fromValue(QList<int>({12, 22, 2, 1, 0, 0, 33}))); } +void tst_QmlCppCodegen::writeVariantMap() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/StringBuilderTestTypes/writeVariantMap.qml"_s)); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + const QVariantMap v = object->property("data").toMap(); + QCOMPARE(v.size(), 1); + const QVariant textPlain = v[u"text/plain"_s]; + QCOMPARE(textPlain.metaType(), QMetaType::fromType<QString>()); + QCOMPARE(textPlain.toString(), u"%Drag Me%"_s); + +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
