diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-03-21 10:21:18 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-04-29 09:47:43 +0200 |
commit | 2c9c1590e6c9dc59bd786f4b41af32f1994bed2d (patch) | |
tree | 7cc1302426732093f1c88c1d7621a95854ade0e2 /tests | |
parent | ecc87ea07723998dcfa947353e4259ec8d057035 (diff) |
Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
26 files changed, 531 insertions, 478 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 9dc109b713..49fd064311 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -49,6 +49,8 @@ #define NO_INLINE __attribute__((noinline)) #endif +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) @@ -5226,11 +5228,11 @@ void tst_QJSEngine::concatAfterUnshift() test = test.concat([]) return test })() - )"_qs); + )"_s); QVERIFY2(!value.isError(), qPrintable(value.toString())); QVERIFY(value.isArray()); - QCOMPARE(value.property(0).toString(), u"val1"_qs); - QCOMPARE(value.property(1).toString(), u"val2"_qs); + QCOMPARE(value.property(0).toString(), u"val1"_s); + QCOMPARE(value.property(1).toString(), u"val2"_s); } void tst_QJSEngine::sortSparseArray() diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 648099e050..0ab0a81258 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -45,6 +45,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include "scriptstringprops.h" +using namespace Qt::StringLiterals; + class tst_qmlcachegen: public QQmlDataTest { Q_OBJECT @@ -822,7 +824,7 @@ void tst_qmlcachegen::scriptStringCachegenInteraction() QVERIFY(scripty->m_undef.isUndefinedLiteral()); QVERIFY(scripty->m_nul.isNullLiteral()); - QCOMPARE(scripty->m_str.stringLiteral(), u"hello"_qs); + QCOMPARE(scripty->m_str.stringLiteral(), u"hello"_s); QCOMPARE(scripty->m_num.numberLiteral(&ok), 42); ok = false; scripty->m_bol.booleanLiteral(&ok); diff --git a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h index f56b82539c..45354decf0 100644 --- a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h +++ b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h @@ -65,14 +65,14 @@ class OverriddenObjectName : public ObjectWithMethod public: OverriddenObjectName(QObject *parent = nullptr) : ObjectWithMethod(parent) { - m_objectName = u"borschtsch"_qs; + m_objectName = QStringLiteral("borschtsch"); nothing = 77; } QString objectName() const { return m_objectName.value(); } void setObjectName(const QString &objectName) { m_objectName.setValue(objectName); } QBindable<QString> objectNameBindable() { return QBindable<QString>(&m_objectName); } - Q_INVOKABLE QString doThing() const { return u"7"_qs; } + Q_INVOKABLE QString doThing() const { return QStringLiteral("7"); } int fff() const { return nothing.value(); } QBindable<int> nothingBindable() { return QBindable<int>(¬hing); } diff --git a/tests/auto/qml/qmlcppcodegen/data/person.cpp b/tests/auto/qml/qmlcppcodegen/data/person.cpp index e05e7b371a..e9dbbf071b 100644 --- a/tests/auto/qml/qmlcppcodegen/data/person.cpp +++ b/tests/auto/qml/qmlcppcodegen/data/person.cpp @@ -28,10 +28,12 @@ #include "person.h" +using namespace Qt::StringLiterals; + Person::Person(QObject *parent) - : QObject(parent), m_name(u"Bart"_qs), m_shoeSize(0) + : QObject(parent), m_name(u"Bart"_s), m_shoeSize(0) { - m_things.append(u"thing"_qs); + m_things.append(u"thing"_s); m_things.append(30); } @@ -50,7 +52,7 @@ void Person::setName(const QString &n) void Person::resetName() { - setName(u"Bart"_qs); + setName(u"Bart"_s); } int Person::shoeSize() const diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 696e579d87..cd528a2970 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -33,6 +33,8 @@ #include <QtCore/qprocess.h> #endif +using namespace Qt::StringLiterals; + Q_IMPORT_QML_PLUGIN(TestTypesPlugin) class tst_QmlCppCodegen : public QObject @@ -137,7 +139,7 @@ private slots: void tst_QmlCppCodegen::simpleBinding() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Test.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Test.qml"_s)); QScopedPointer<QObject> object(component.create()); QVERIFY2(!object.isNull(), component.errorString().toUtf8().constData()); QCOMPARE(object->property("foo").toInt(), int(3)); @@ -158,7 +160,7 @@ void tst_QmlCppCodegen::simpleBinding() void tst_QmlCppCodegen::anchorsFill() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/anchorsFill.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/anchorsFill.qml"_s)); QScopedPointer<QObject> object(component.create()); QVERIFY2(!object.isNull(), component.errorString().toUtf8().constData()); @@ -180,21 +182,21 @@ void tst_QmlCppCodegen::anchorsFill() void tst_QmlCppCodegen::signalHandler() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/signal.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/signal.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QCOMPARE(object->objectName(), QString()); QCOMPARE(object->property("ff").toInt(), 4); - object->setObjectName(u"foo"_qs); + object->setObjectName(u"foo"_s); QCOMPARE(object->property("ff").toInt(), 12); } void tst_QmlCppCodegen::idAccess() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/idAccess.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/idAccess.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -210,7 +212,7 @@ void tst_QmlCppCodegen::idAccess() object->setProperty("z", 14); QCOMPARE(object->property("y").toInt(), 48); - QObject *ttt = qmlContext(object.data())->objectForName(u"ttt"_qs); + QObject *ttt = qmlContext(object.data())->objectForName(u"ttt"_s); QFont f = qvariant_cast<QFont>(ttt->property("font")); QCOMPARE(f.pointSize(), 22); } @@ -226,7 +228,7 @@ void tst_QmlCppCodegen::globals() QQmlEngine engine; int exitCode = -1; QObject::connect(&engine, &QQmlEngine::exit, [&](int code) { exitCode = code; }); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/globals.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/globals.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); const QByteArray message = QByteArray("Start 2 ") + arg1(); @@ -239,29 +241,29 @@ void tst_QmlCppCodegen::globals() QObject *application = qvariant_cast<QObject *>(object->property("application")); QVERIFY(application); QCOMPARE(QString::fromUtf8(application->metaObject()->className()), - u"QQuickApplication"_qs); + u"QQuickApplication"_s); QTest::ignoreMessage(QtDebugMsg, "End"); QMetaObject::invokeMethod(application, "aboutToQuit"); const QVariant somewhere = object->property("somewhere"); QCOMPARE(somewhere.userType(), QMetaType::QUrl); - QCOMPARE(qvariant_cast<QUrl>(somewhere).toString(), u"qrc:/somewhere/else.qml"_qs); + QCOMPARE(qvariant_cast<QUrl>(somewhere).toString(), u"qrc:/somewhere/else.qml"_s); const QVariant somewhereString = object->property("somewhereString"); QCOMPARE(somewhereString.userType(), QMetaType::QString); - QCOMPARE(somewhereString.toString(), u"qrc:/somewhere/else.qml"_qs); + QCOMPARE(somewhereString.toString(), u"qrc:/somewhere/else.qml"_s); const QVariant plain = object->property("plain"); QCOMPARE(plain.userType(), QMetaType::QUrl); - QCOMPARE(qvariant_cast<QUrl>(plain).toString(), u"/not/here.qml"_qs); + QCOMPARE(qvariant_cast<QUrl>(plain).toString(), u"/not/here.qml"_s); } void tst_QmlCppCodegen::multiLookup() { // Multiple lookups of singletons (Qt in this case) don't clash with one another. QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/immediateQuit.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/immediateQuit.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); const QByteArray message = QByteArray("End: ") + arg1(); @@ -277,7 +279,7 @@ void tst_QmlCppCodegen::enums() { QQmlEngine engine; { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Enums.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Enums.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/Enums.qml:4:1: " @@ -288,11 +290,11 @@ void tst_QmlCppCodegen::enums() bool ok = false; QCOMPARE(object->property("appState").toInt(&ok), 2); QVERIFY(ok); - QCOMPARE(object->property("color").toString(), u"blue"_qs); + QCOMPARE(object->property("color").toString(), u"blue"_s); QTRY_COMPARE(object->property("appState").toInt(&ok), 1); QVERIFY(ok); - QCOMPARE(object->property("color").toString(), u"green"_qs); + QCOMPARE(object->property("color").toString(), u"green"_s); const auto func = qmlAttachedPropertiesFunction( object.data(), QMetaType::fromName("QQuickLayout*").metaObject()); @@ -306,19 +308,19 @@ void tst_QmlCppCodegen::enums() QCOMPARE(qvariant_cast<Qt::Alignment>(prop), Qt::AlignCenter); } { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumsInOtherObject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumsInOtherObject.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->property("color").toString(), u"blue"_qs); - QTRY_COMPARE(object->property("color").toString(), u"green"_qs); + QCOMPARE(object->property("color").toString(), u"blue"_s); + QTRY_COMPARE(object->property("color").toString(), u"green"_s); } } void tst_QmlCppCodegen::funcWithParams() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/funcWithParams.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/funcWithParams.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -328,7 +330,7 @@ void tst_QmlCppCodegen::funcWithParams() void tst_QmlCppCodegen::intOverflow() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/intOverflow.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/intOverflow.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -339,7 +341,7 @@ void tst_QmlCppCodegen::intOverflow() void tst_QmlCppCodegen::stringLength() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/stringLength.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/stringLength.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -349,17 +351,17 @@ void tst_QmlCppCodegen::stringLength() void tst_QmlCppCodegen::scopeVsObject() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/scopeVsObject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/scopeVsObject.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->property("objectName").toString(), u"foobar"_qs); + QCOMPARE(object->property("objectName").toString(), u"foobar"_s); } void tst_QmlCppCodegen::compositeTypeMethod() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositeTypeMethod.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositeTypeMethod.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -370,7 +372,7 @@ void tst_QmlCppCodegen::compositeTypeMethod() void tst_QmlCppCodegen::excessiveParameters() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/excessiveParameters.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/excessiveParameters.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -381,7 +383,7 @@ void tst_QmlCppCodegen::excessiveParameters() void tst_QmlCppCodegen::jsImport() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsimport.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsimport.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -391,7 +393,7 @@ void tst_QmlCppCodegen::jsImport() void tst_QmlCppCodegen::jsmoduleImport() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsmoduleimport.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsmoduleimport.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -407,11 +409,11 @@ void tst_QmlCppCodegen::jsmoduleImport() void tst_QmlCppCodegen::methods() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/methods.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/methods.qml"_s)); QVERIFY(component.isReady()); QTest::ignoreMessage(QtDebugMsg, "The Bar"); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(u"TypeError: .* is not a function"_qs)); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(u"TypeError: .* is not a function"_s)); QScopedPointer<QObject> obj(component.create()); QVERIFY(obj); BirthdayParty *party(qobject_cast<BirthdayParty *>(obj.data())); @@ -422,30 +424,30 @@ void tst_QmlCppCodegen::methods() bool foundGreen = false; bool foundFoo = false; for (int ii = 0; ii < party->guestCount(); ++ii) { - if (party->guest(ii)->name() == u"William Green"_qs) + if (party->guest(ii)->name() == u"William Green"_s) foundGreen = true; - if (party->guest(ii)->name() == u"The Foo"_qs) + if (party->guest(ii)->name() == u"The Foo"_s) foundFoo = true; } QVERIFY(foundGreen); QVERIFY(foundFoo); - QCOMPARE(obj->property("n1").toString(), u"onGurk"_qs); - QCOMPARE(obj->property("n2").toString(), u"onSemmeln"_qs); + QCOMPARE(obj->property("n1").toString(), u"onGurk"_s); + QCOMPARE(obj->property("n2").toString(), u"onSemmeln"_s); QCOMPARE(obj->property("n3"), QVariant()); { QVariant ret; obj->metaObject()->invokeMethod(obj.data(), "retrieveVar", Q_RETURN_ARG(QVariant, ret)); QCOMPARE(ret.typeId(), QMetaType::QString); - QCOMPARE(ret.toString(), u"Jack Smith"_qs); + QCOMPARE(ret.toString(), u"Jack Smith"_s); } { QString ret; obj->metaObject()->invokeMethod(obj.data(), "retrieveString", Q_RETURN_ARG(QString, ret)); - QCOMPARE(ret, u"Jack Smith"_qs); + QCOMPARE(ret, u"Jack Smith"_s); } QCOMPARE(party->host()->shoeSize(), 12); @@ -466,7 +468,7 @@ void tst_QmlCppCodegen::methods() void tst_QmlCppCodegen::math() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/math.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/math.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -477,7 +479,7 @@ void tst_QmlCppCodegen::math() void tst_QmlCppCodegen::unknownParameter() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unknownParameter.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unknownParameter.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -487,26 +489,26 @@ void tst_QmlCppCodegen::unknownParameter() void tst_QmlCppCodegen::array() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/array.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/array.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QJSValue value1 = object->property("values1").value<QJSValue>(); QVERIFY(value1.isArray()); - QCOMPARE(value1.property(u"length"_qs).toInt(), 3); + QCOMPARE(value1.property(u"length"_s).toInt(), 3); QCOMPARE(value1.property(0).toInt(), 1); QCOMPARE(value1.property(1).toInt(), 2); QCOMPARE(value1.property(2).toInt(), 3); const QJSValue value2 = object->property("values2").value<QJSValue>(); QVERIFY(value2.isArray()); - QCOMPARE(value2.property(u"length"_qs).toInt(), 0); + QCOMPARE(value2.property(u"length"_s).toInt(), 0); } void tst_QmlCppCodegen::equalsUndefined() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/equalsUndefined.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/equalsUndefined.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -518,7 +520,7 @@ void tst_QmlCppCodegen::equalsUndefined() void tst_QmlCppCodegen::conversions() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/conversions.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/conversions.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/conversions.qml:42: TypeError: Type error"); @@ -544,17 +546,17 @@ void tst_QmlCppCodegen::conversions() QCOMPARE(object->property("cmpEqInt").toInt(), 17); - QCOMPARE(object->property("undefinedType").toString(), u"undefined"_qs); - QCOMPARE(object->property("booleanType").toString(), u"boolean"_qs); - QCOMPARE(object->property("numberType").toString(), u"number"_qs); - QCOMPARE(object->property("stringType").toString(), u"string"_qs); - QCOMPARE(object->property("objectType").toString(), u"object"_qs); - QCOMPARE(object->property("symbolType").toString(), u"symbol"_qs); + QCOMPARE(object->property("undefinedType").toString(), u"undefined"_s); + QCOMPARE(object->property("booleanType").toString(), u"boolean"_s); + QCOMPARE(object->property("numberType").toString(), u"number"_s); + QCOMPARE(object->property("stringType").toString(), u"string"_s); + QCOMPARE(object->property("objectType").toString(), u"object"_s); + QCOMPARE(object->property("symbolType").toString(), u"symbol"_s); QJSManagedValue obj = engine.toManagedValue(object->property("anObject")); - QCOMPARE(obj.property(u"a"_qs).toInt(), 12); - QCOMPARE(obj.property(u"b"_qs).toInt(), 14); - QCOMPARE(obj.property(u"c"_qs).toString(), u"somestring"_qs); + QCOMPARE(obj.property(u"a"_s).toInt(), 12); + QCOMPARE(obj.property(u"b"_s).toInt(), 14); + QCOMPARE(obj.property(u"c"_s).toString(), u"somestring"_s); QVERIFY(object->property("aInObject").toBool()); QVERIFY(object->property("lengthInArray").toBool()); @@ -569,7 +571,7 @@ void tst_QmlCppCodegen::conversions() const QVariant stringPlusString = object->property("stringPlusString"); QCOMPARE(stringPlusString.typeId(), QMetaType::QString); - QCOMPARE(stringPlusString.toString(), u"1220"_qs); + QCOMPARE(stringPlusString.toString(), u"1220"_s); const QVariant stringMinusString = object->property("stringMinusString"); QCOMPARE(stringMinusString.typeId(), QMetaType::Double); @@ -584,7 +586,7 @@ void tst_QmlCppCodegen::conversions() QCOMPARE(stringDivString.toDouble(), 0.6); QCOMPARE(object->property("uglyString").toString(), - u"with\nnewlinewith\"quotwith\\slashes"_qs); + u"with\nnewlinewith\"quotwith\\slashes"_s); QCOMPARE(qvariant_cast<QObject *>(object->property("nullObject1")), nullptr); QCOMPARE(qvariant_cast<QObject *>(object->property("nullObject2")), object.data()); @@ -650,19 +652,19 @@ void tst_QmlCppCodegen::interestingFiles_data() QTest::addColumn<QString>("file"); QTest::addColumn<bool>("isValid"); - QTest::addRow("conversions2") << u"conversions2.qml"_qs << true; - QTest::addRow("TestCase") << u"TestCase.qml"_qs << true; - QTest::addRow("layouts") << u"layouts.qml"_qs << true; - QTest::addRow("interactive") << u"interactive.qml"_qs << true; - QTest::addRow("Panel") << u"Panel.qml"_qs << true; - QTest::addRow("ProgressBar") << u"ProgressBar/ProgressBar.ui.qml"_qs << true; - QTest::addRow("Root") << u"ProgressBar/Root.qml"_qs << true; - QTest::addRow("noscope") << u"noscope.qml"_qs << true; - QTest::addRow("dynamicscene") << u"dynamicscene.qml"_qs << true; - QTest::addRow("curlygrouped") << u"curlygrouped.qml"_qs << true; - QTest::addRow("cycleHead") << u"cycleHead.qml"_qs << false; - QTest::addRow("deadStoreLoop") << u"deadStoreLoop.qml"_qs << true; - QTest::addRow("moveRegVoid") << u"moveRegVoid.qml"_qs << true; + QTest::addRow("conversions2") << u"conversions2.qml"_s << true; + QTest::addRow("TestCase") << u"TestCase.qml"_s << true; + QTest::addRow("layouts") << u"layouts.qml"_s << true; + QTest::addRow("interactive") << u"interactive.qml"_s << true; + QTest::addRow("Panel") << u"Panel.qml"_s << true; + QTest::addRow("ProgressBar") << u"ProgressBar/ProgressBar.ui.qml"_s << true; + QTest::addRow("Root") << u"ProgressBar/Root.qml"_s << true; + QTest::addRow("noscope") << u"noscope.qml"_s << true; + QTest::addRow("dynamicscene") << u"dynamicscene.qml"_s << true; + QTest::addRow("curlygrouped") << u"curlygrouped.qml"_s << true; + QTest::addRow("cycleHead") << u"cycleHead.qml"_s << false; + QTest::addRow("deadStoreLoop") << u"deadStoreLoop.qml"_s << true; + QTest::addRow("moveRegVoid") << u"moveRegVoid.qml"_s << true; } void tst_QmlCppCodegen::interestingFiles() @@ -671,7 +673,7 @@ void tst_QmlCppCodegen::interestingFiles() QFETCH(bool, isValid); QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/%1"_qs.arg(file))); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/%1"_s.arg(file))); if (isValid) { QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); @@ -684,7 +686,7 @@ void tst_QmlCppCodegen::interestingFiles() void tst_QmlCppCodegen::extendedTypes() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/extendedTypes.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/extendedTypes.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "6 QSizeF(10, 20) 30"); @@ -694,7 +696,7 @@ void tst_QmlCppCodegen::extendedTypes() QCOMPARE(object->property("a").toInt(), 6); QCOMPARE(qvariant_cast<QSizeF>(object->property("b")), QSizeF(10, 20)); QCOMPARE(object->property("c").toInt(), 30); - QCOMPARE(object->property("d").toString(), u"QSizeF(10, 20)"_qs); + QCOMPARE(object->property("d").toString(), u"QSizeF(10, 20)"_s); QCOMPARE(object->property("e").toInt(), 2); } @@ -702,14 +704,14 @@ void tst_QmlCppCodegen::extendedTypes() void tst_QmlCppCodegen::construct() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/construct.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/construct.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QJSManagedValue v = engine.toManagedValue(object->property("foo")); QVERIFY(v.isError()); - QCOMPARE(v.toString(), u"Error: bar"_qs); + QCOMPARE(v.toString(), u"Error: bar"_s); QCOMPARE(object->property("aaa").toInt(), 12); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/construct.qml:9: Error: ouch"); @@ -725,10 +727,10 @@ void tst_QmlCppCodegen::contextParam() QQmlEngine engine; QVariantMap m; - m.insert(u"foo"_qs, 10); - engine.rootContext()->setContextProperty(u"contextParam"_qs, m); + m.insert(u"foo"_s, 10); + engine.rootContext()->setContextProperty(u"contextParam"_s, m); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/contextParam.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/contextParam.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -739,7 +741,7 @@ void tst_QmlCppCodegen::contextParam() void tst_QmlCppCodegen::attachedType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/text.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/text.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -756,7 +758,7 @@ void tst_QmlCppCodegen::attachedType() void tst_QmlCppCodegen::componentReturnType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/componentReturnType.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/componentReturnType.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -767,7 +769,7 @@ void tst_QmlCppCodegen::componentReturnType() void tst_QmlCppCodegen::onAssignment() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/pressAndHoldButton.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/pressAndHoldButton.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -801,7 +803,7 @@ void tst_QmlCppCodegen::failures() void tst_QmlCppCodegen::enumScope() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumScope.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumScope.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QCOMPARE(object->property("flow").toInt(), 1); @@ -810,7 +812,7 @@ void tst_QmlCppCodegen::enumScope() void tst_QmlCppCodegen::unusedAttached() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unusedAttached.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unusedAttached.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -828,7 +830,7 @@ void tst_QmlCppCodegen::unusedAttached() void tst_QmlCppCodegen::attachedBaseEnum() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/attachedBaseEnum.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/attachedBaseEnum.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -844,7 +846,7 @@ void tst_QmlCppCodegen::attachedBaseEnum() void tst_QmlCppCodegen::nullAccess() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nullAccess.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nullAccess.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, @@ -865,7 +867,7 @@ void tst_QmlCppCodegen::nullAccess() void tst_QmlCppCodegen::interceptor() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/interceptor.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/interceptor.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -886,7 +888,7 @@ void tst_QmlCppCodegen::interceptor() void tst_QmlCppCodegen::nonNotifyable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nonNotifyable.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nonNotifyable.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -900,32 +902,32 @@ void tst_QmlCppCodegen::nonNotifyable() void tst_QmlCppCodegen::importsFromImportPath() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/importsFromImportPath.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/importsFromImportPath.qml"_s)); // We might propagate the import path, eventually, but for now instantiating is not important. // If the compiler accepts the file, it's probably fine. QVERIFY(component.isError()); QCOMPARE(component.errorString(), - u"qrc:/TestTypes/importsFromImportPath.qml:1 module \"Module\" is not installed\n"_qs); + u"qrc:/TestTypes/importsFromImportPath.qml:1 module \"Module\" is not installed\n"_s); } void tst_QmlCppCodegen::aliasLookup() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/aliasLookup.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/aliasLookup.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QVariant t = object->property("t"); QCOMPARE(t.metaType(), QMetaType::fromType<QString>()); - QCOMPARE(t.toString(), u"12"_qs); + QCOMPARE(t.toString(), u"12"_s); } void tst_QmlCppCodegen::outOfBoundsArray() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/outOfBounds.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/outOfBounds.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "oob undefined"); @@ -938,8 +940,8 @@ void tst_QmlCppCodegen::outOfBoundsArray() void tst_QmlCppCodegen::compositeSingleton() { QQmlEngine engine; - engine.addImportPath(u":/TestTypes/imports/"_qs); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositesingleton.qml"_qs)); + engine.addImportPath(u":/TestTypes/imports/"_s); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositesingleton.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> o(component.create()); QCOMPARE(o->property("x").toDouble(), 4.5); @@ -950,7 +952,7 @@ void tst_QmlCppCodegen::compositeSingleton() void tst_QmlCppCodegen::lotsOfRegisters() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/page.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/page.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -986,7 +988,7 @@ void tst_QmlCppCodegen::lotsOfRegisters() void tst_QmlCppCodegen::inPlaceDecrement() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/dialog.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/dialog.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1012,7 +1014,7 @@ void tst_QmlCppCodegen::inPlaceDecrement() void tst_QmlCppCodegen::shifts() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/shifts.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/shifts.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1027,25 +1029,25 @@ void tst_QmlCppCodegen::shifts() void tst_QmlCppCodegen::valueTypeProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/valueTypeProperty.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/valueTypeProperty.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QFont font = qvariant_cast<QFont>(object->property("font")); QCOMPARE(object->property("foo").toString(), font.family()); - font.setFamily(u"Bar"_qs); + font.setFamily(u"Bar"_s); object->setProperty("font", QVariant::fromValue(font)); - QCOMPARE(object->property("foo").toString(), u"Bar"_qs); + QCOMPARE(object->property("foo").toString(), u"Bar"_s); } void tst_QmlCppCodegen::propertyOfParent() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/RootWithoutId.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/RootWithoutId.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); - QObject *child = qmlContext(object.data())->objectForName(u"item"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"item"_s); bool expected = false; @@ -1070,7 +1072,7 @@ void tst_QmlCppCodegen::propertyOfParent() void tst_QmlCppCodegen::accessModelMethodFromOutSide() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/AccessModelMethodsFromOutside.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/AccessModelMethodsFromOutside.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "3"); @@ -1078,15 +1080,15 @@ void tst_QmlCppCodegen::accessModelMethodFromOutSide() QScopedPointer<QObject> object(component.create()); QCOMPARE(object->property("cost1").toDouble(), 3); - QCOMPARE(object->property("name1").toString(), u"Orange"_qs); + QCOMPARE(object->property("name1").toString(), u"Orange"_s); QCOMPARE(object->property("cost2").toDouble(), 1.95); - QCOMPARE(object->property("name2").toString(), u"Banana"_qs); + QCOMPARE(object->property("name2").toString(), u"Banana"_s); } void tst_QmlCppCodegen::functionArguments() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Dummy.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Dummy.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -1106,23 +1108,23 @@ void tst_QmlCppCodegen::functionArguments() Q_ARG(double, d), Q_ARG(int, e)); QCOMPARE(result, 42); - QString astr = u"foo"_qs; - QString bstr = u"bar"_qs; + QString astr = u"foo"_s; + QString bstr = u"bar"_s; QString concatenated; metaObject->invokeMethod( object.data(), "concat", Q_RETURN_ARG(QString, concatenated), Q_ARG(QString, astr), Q_ARG(QString, bstr)); - QCOMPARE(concatenated, u"foobar"_qs); + QCOMPARE(concatenated, u"foobar"_s); } void tst_QmlCppCodegen::bindingExpression() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/BindingExpression.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/BindingExpression.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); - QObject *child = qmlContext(object.data())->objectForName(u"child"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"child"_s); double width = 200; double y = 10; @@ -1133,7 +1135,7 @@ void tst_QmlCppCodegen::bindingExpression() const double childY = y + (width - 100) / 2; QCOMPARE(child->property("y").toDouble(), childY); - QCOMPARE(object->property("mass"), childY > 100 ? u"heavy"_qs : u"light"_qs); + QCOMPARE(object->property("mass"), childY > 100 ? u"heavy"_s : u"light"_s); QCOMPARE(object->property("test_division").toDouble(), width / 1000 + 50); QCOMPARE(object->property("test_ternary").toDouble(), 2.2); @@ -1160,28 +1162,28 @@ void tst_QmlCppCodegen::bindingExpression() void tst_QmlCppCodegen::voidFunction() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/voidfunction.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/voidfunction.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QVERIFY(object->objectName().isEmpty()); object->metaObject()->invokeMethod(object.data(), "doesNotReturnValue"); - QCOMPARE(object->objectName(), u"barbar"_qs); + QCOMPARE(object->objectName(), u"barbar"_s); } void tst_QmlCppCodegen::overriddenProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/childobject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/childobject.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->objectName(), u"kraut"_qs); + QCOMPARE(object->objectName(), u"kraut"_s); QCOMPARE(object->property("doneThing").toInt(), 5); QCOMPARE(object->property("usingFinal").toInt(), 5); auto checkAssignment = [&]() { - const QString newName = u"worscht"_qs; + const QString newName = u"worscht"_s; QMetaObject::invokeMethod(object.data(), "setChildObjectName", Q_ARG(QString, newName)); QCOMPARE(object->objectName(), newName); }; @@ -1189,9 +1191,9 @@ void tst_QmlCppCodegen::overriddenProperty() ObjectWithMethod *benign = new ObjectWithMethod(object.data()); benign->theThing = 10; - benign->setObjectName(u"cabbage"_qs); + benign->setObjectName(u"cabbage"_s); object->setProperty("child", QVariant::fromValue(benign)); - QCOMPARE(object->objectName(), u"cabbage"_qs); + QCOMPARE(object->objectName(), u"cabbage"_s); checkAssignment(); QCOMPARE(object->property("doneThing").toInt(), 10); QCOMPARE(object->property("usingFinal").toInt(), 10); @@ -1202,7 +1204,7 @@ void tst_QmlCppCodegen::overriddenProperty() "The override won't be used."); object->setProperty("child", QVariant::fromValue(evil)); - QCOMPARE(object->objectName(), u"borschtsch"_qs); + QCOMPARE(object->objectName(), u"borschtsch"_s); checkAssignment(); QCOMPARE(object->property("doneThing").toInt(), 7); @@ -1212,7 +1214,7 @@ void tst_QmlCppCodegen::overriddenProperty() void tst_QmlCppCodegen::listLength() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/listlength.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/listlength.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1222,7 +1224,7 @@ void tst_QmlCppCodegen::listLength() void tst_QmlCppCodegen::parentProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/parentProp.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/parentProp.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1233,9 +1235,9 @@ void tst_QmlCppCodegen::parentProperty() object->setProperty("implicitWidth", QVariant::fromValue(14)); QCOMPARE(object->property("i").toInt(), 26); - QObject *child = qmlContext(object.data())->objectForName(u"child"_qs); - QObject *sibling = qmlContext(object.data())->objectForName(u"sibling"_qs); - QObject *evil = qmlContext(object.data())->objectForName(u"evil"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"child"_s); + QObject *sibling = qmlContext(object.data())->objectForName(u"sibling"_s); + QObject *evil = qmlContext(object.data())->objectForName(u"evil"_s); child->setProperty("parent", QVariant::fromValue(sibling)); @@ -1252,7 +1254,7 @@ void tst_QmlCppCodegen::parentProperty() QCOMPARE(object->property("i").toInt(), 886); { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/specificParent.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/specificParent.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1265,7 +1267,7 @@ void tst_QmlCppCodegen::parentProperty() void tst_QmlCppCodegen::registerElimination() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/registerelimination.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/registerelimination.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1283,16 +1285,16 @@ void tst_QmlCppCodegen::registerElimination() void tst_QmlCppCodegen::asCast() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/asCast.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/asCast.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> root(component.create()); QVERIFY(!root.isNull()); QQmlContext *context = qmlContext(root.data()); - const QObject *object = context->objectForName(u"object"_qs); - const QObject *item = context->objectForName(u"item"_qs); - const QObject *rectangle = context->objectForName(u"rectangle"_qs); - const QObject *dummy = context->objectForName(u"dummy"_qs); + const QObject *object = context->objectForName(u"object"_s); + const QObject *item = context->objectForName(u"item"_s); + const QObject *rectangle = context->objectForName(u"rectangle"_s); + const QObject *dummy = context->objectForName(u"dummy"_s); QCOMPARE(qvariant_cast<QObject *>(root->property("objectAsObject")), object); QCOMPARE(qvariant_cast<QObject *>(root->property("objectAsItem")), nullptr); @@ -1318,7 +1320,7 @@ void tst_QmlCppCodegen::asCast() void tst_QmlCppCodegen::noQQmlData() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/noQQmlData.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/noQQmlData.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/noQQmlData.qml:7: TypeError: " @@ -1334,9 +1336,9 @@ void tst_QmlCppCodegen::noQQmlData() Person *host1 = new Person(party); party->setHost(host1); - QCOMPARE(party->property("n").toString(), u"Bart in da house!"_qs); - host1->setName(u"Marge"_qs); - QCOMPARE(party->property("n").toString(), u"Marge in da house!"_qs); + QCOMPARE(party->property("n").toString(), u"Bart in da house!"_s); + host1->setName(u"Marge"_s); + QCOMPARE(party->property("n").toString(), u"Marge in da house!"_s); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/noQQmlData.qml:7: TypeError: " "Cannot read property 'name' of null"); @@ -1347,26 +1349,26 @@ void tst_QmlCppCodegen::noQQmlData() // Lookups are initialized now, and we introduce an object without QQmlData Person *host2 = new Person(party); party->setHost(host2); - QCOMPARE(party->property("n").toString(), u"Bart in da house!"_qs); - host2->setName(u"Homer"_qs); - QCOMPARE(party->property("n").toString(), u"Homer in da house!"_qs); + QCOMPARE(party->property("n").toString(), u"Bart in da house!"_s); + host2->setName(u"Homer"_s); + QCOMPARE(party->property("n").toString(), u"Homer in da house!"_s); QMetaObject::invokeMethod(party, "burn"); engine.collectGarbage(); // Does not crash - party->setProperty("inDaHouse", u" burns!"_qs); + party->setProperty("inDaHouse", u" burns!"_s); // Mr Burns may or may not burn, depending on whether we use lookups. // If using lookups, the binding is aborted when we find the isQueuedForDeletion flag. // If reading the property directly, we don't have to care about it. - QVERIFY(party->property("n").toString().startsWith(u"Mr Burns"_qs)); + QVERIFY(party->property("n").toString().startsWith(u"Mr Burns"_s)); } void tst_QmlCppCodegen::scopeObjectDestruction() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/fileDialog.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/fileDialog.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1413,21 +1415,21 @@ static void checkColorProperties(QQmlComponent *component) void tst_QmlCppCodegen::colorAsVariant() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorAsVariant.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorAsVariant.qml"_s)); checkColorProperties(&component); } void tst_QmlCppCodegen::bindToValueType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/bindToValueType.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/bindToValueType.qml"_s)); checkColorProperties(&component); } void tst_QmlCppCodegen::undefinedResets() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/undefinedResets.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/undefinedResets.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1436,34 +1438,34 @@ void tst_QmlCppCodegen::undefinedResets() Person *person = qobject_cast<Person *>(rootObject.data()); QVERIFY(person); QCOMPARE(person->shoeSize(), 0); - QCOMPARE(person->name(), u"Marge"_qs); + QCOMPARE(person->name(), u"Marge"_s); person->setShoeSize(11); QCOMPARE(person->shoeSize(), 11); - QCOMPARE(person->name(), u"Bart"_qs); + QCOMPARE(person->name(), u"Bart"_s); person->setShoeSize(10); QCOMPARE(person->shoeSize(), 10); - QCOMPARE(person->name(), u"Marge"_qs); + QCOMPARE(person->name(), u"Marge"_s); } void tst_QmlCppCodegen::innerObjectNonShadowable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/ownProperty.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/ownProperty.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); QVERIFY(rootObject); - QCOMPARE(rootObject->objectName(), u"foo"_qs); + QCOMPARE(rootObject->objectName(), u"foo"_s); } void tst_QmlCppCodegen::ownPropertiesNonShadowable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/overriddenMember.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/overriddenMember.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1477,7 +1479,7 @@ void tst_QmlCppCodegen::ownPropertiesNonShadowable() void tst_QmlCppCodegen::modulePrefix() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/modulePrefix.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/modulePrefix.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1491,7 +1493,7 @@ void tst_QmlCppCodegen::modulePrefix() void tst_QmlCppCodegen::colorString() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorString.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorString.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1505,22 +1507,22 @@ void tst_QmlCppCodegen::colorString() void tst_QmlCppCodegen::urlString() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/urlString.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/urlString.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); QVERIFY(rootObject); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("c")), QUrl(u"http://dddddd.com"_qs)); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("d")), QUrl(u"http://aaaaaa.com"_qs)); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("e")), QUrl(u"http://a112233.de"_qs)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("c")), QUrl(u"http://dddddd.com"_s)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("d")), QUrl(u"http://aaaaaa.com"_s)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("e")), QUrl(u"http://a112233.de"_s)); } void tst_QmlCppCodegen::callContextPropertyLookupResult() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/callContextPropertyLookupResult.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/callContextPropertyLookupResult.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1531,7 +1533,7 @@ void tst_QmlCppCodegen::callContextPropertyLookupResult() void tst_QmlCppCodegen::deadShoeSize() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/deadShoeSize.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/deadShoeSize.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/deadShoeSize.qml:5: Error: ouch"); QScopedPointer<QObject> o(c.create()); @@ -1542,7 +1544,7 @@ void tst_QmlCppCodegen::deadShoeSize() void tst_QmlCppCodegen::listIndices() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/listIndices.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/listIndices.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1557,7 +1559,7 @@ void tst_QmlCppCodegen::listIndices() void tst_QmlCppCodegen::jsMathObject() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/jsMathObject.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/jsMathObject.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1613,7 +1615,7 @@ void tst_QmlCppCodegen::intEnumCompare() { QQmlEngine engine; { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/intEnumCompare.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/intEnumCompare.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1625,7 +1627,7 @@ void tst_QmlCppCodegen::intEnumCompare() { // We cannot use Qt.red in QML because it's lower case. - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumInvalid.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumInvalid.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1637,7 +1639,7 @@ void tst_QmlCppCodegen::intEnumCompare() void tst_QmlCppCodegen::attachedSelf() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/SelectionRectangle.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/SelectionRectangle.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1650,7 +1652,7 @@ void tst_QmlCppCodegen::attachedSelf() void tst_QmlCppCodegen::functionReturningVoid() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionReturningVoid.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionReturningVoid.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1667,7 +1669,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() { QQmlEngine engine; { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themergood.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themergood.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1675,7 +1677,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() } { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themerbad.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themerbad.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1686,7 +1688,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() void tst_QmlCppCodegen::flushBeforeCapture() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/noBindingLoop.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/noBindingLoop.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1699,45 +1701,45 @@ void tst_QmlCppCodegen::flushBeforeCapture() void tst_QmlCppCodegen::unknownAttached() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/unknownAttached.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/unknownAttached.qml"_s)); QVERIFY(c.isError()); } void tst_QmlCppCodegen::variantlist() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/variantlist.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/variantlist.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); const QVariantList things = qvariant_cast<QVariantList>(o->property("things")); QCOMPARE(things.length(), 2); - QCOMPARE(things[0].toString(), u"thing"_qs); + QCOMPARE(things[0].toString(), u"thing"_s); QCOMPARE(things[1].toInt(), 30); } void tst_QmlCppCodegen::popContextAfterRet() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/popContextAfterRet.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/popContextAfterRet.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); QCOMPARE(o->objectName(), QString()); o->setProperty("stackViewDepth", 1); - QCOMPARE(o->objectName(), u"backgroundImage"_qs); + QCOMPARE(o->objectName(), u"backgroundImage"_s); o->setProperty("stackViewDepth", 2); - QCOMPARE(o->objectName(), u"backgroundBlur"_qs); + QCOMPARE(o->objectName(), u"backgroundBlur"_s); o->setProperty("stackViewDepth", 1); - QCOMPARE(o->objectName(), u"backgroundImage"_qs); + QCOMPARE(o->objectName(), u"backgroundImage"_s); } void tst_QmlCppCodegen::revisions() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/revisions.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/revisions.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1749,7 +1751,7 @@ void tst_QmlCppCodegen::revisions() void tst_QmlCppCodegen::invisibleBase() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleBase.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleBase.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1759,21 +1761,21 @@ void tst_QmlCppCodegen::invisibleBase() void tst_QmlCppCodegen::notEqualsInt() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/notEqualsInt.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/notEqualsInt.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); - QObject *t = qmlContext(o.data())->objectForName(u"t"_qs); + QObject *t = qmlContext(o.data())->objectForName(u"t"_s); QVERIFY(t); - QCOMPARE(t->property("text").toString(), u"Foo"_qs); + QCOMPARE(t->property("text").toString(), u"Foo"_s); QMetaObject::invokeMethod(o.data(), "foo"); - QCOMPARE(t->property("text").toString(), u"Bar"_qs); + QCOMPARE(t->property("text").toString(), u"Bar"_s); } void tst_QmlCppCodegen::infinities() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/infinities.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/infinities.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1795,7 +1797,7 @@ void tst_QmlCppCodegen::infinities() void tst_QmlCppCodegen::blockComments() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/blockComments.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/blockComments.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1805,7 +1807,7 @@ void tst_QmlCppCodegen::blockComments() void tst_QmlCppCodegen::functionLookup() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionLookup.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionLookup.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1821,7 +1823,7 @@ void tst_QmlCppCodegen::functionLookup() void tst_QmlCppCodegen::objectInVar() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/objectInVar.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/objectInVar.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1839,7 +1841,7 @@ void tst_QmlCppCodegen::objectInVar() void tst_QmlCppCodegen::functionTakingVar() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/functionTakingVar.qml"_qs); + const QUrl document(u"qrc:/TestTypes/functionTakingVar.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1859,7 +1861,7 @@ void tst_QmlCppCodegen::functionTakingVar() void tst_QmlCppCodegen::testIsnan() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/isnan.qml"_qs); + const QUrl document(u"qrc:/TestTypes/isnan.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1880,7 +1882,7 @@ void tst_QmlCppCodegen::testIsnan() void tst_QmlCppCodegen::fallbackLookups() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/fallbacklookups.qml"_qs); + const QUrl document(u"qrc:/TestTypes/fallbacklookups.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1913,7 +1915,7 @@ void tst_QmlCppCodegen::fallbackLookups() void tst_QmlCppCodegen::typedArray() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/typedArray.qml"_qs); + const QUrl document(u"qrc:/TestTypes/typedArray.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1945,9 +1947,9 @@ void tst_QmlCppCodegen::prefixedType() // We need to add an import path here because we cannot namespace the implicit import. // The implicit import is what we use for all the other tests, even if we explicitly // import TestTypes. That is because the TestTypes module is in a subdirectory "data". - engine.addImportPath(u":/"_qs); + engine.addImportPath(u":/"_s); - const QUrl document(u"qrc:/TestTypes/prefixedMetaType.qml"_qs); + const QUrl document(u"qrc:/TestTypes/prefixedMetaType.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1976,15 +1978,15 @@ void tst_QmlCppCodegen::evadingAmbiguity() // We need to add an import path here because we cannot namespace the implicit import. // The implicit import is what we use for all the other tests, even if we explicitly // import TestTypes. That is because the TestTypes module is in a subdirectory "data". - engine.addImportPath(u":/"_qs); + engine.addImportPath(u":/"_s); - QQmlComponent c1(&engine, QUrl(u"qrc:/TestTypes/ambiguous1/Ambiguous.qml"_qs)); + QQmlComponent c1(&engine, QUrl(u"qrc:/TestTypes/ambiguous1/Ambiguous.qml"_s)); QVERIFY2(c1.isReady(), qPrintable(c1.errorString())); QScopedPointer<QObject> o1(c1.create()); QCOMPARE(o1->objectName(), QStringLiteral("Ambiguous")); QCOMPARE(o1->property("i").toString(), QStringLiteral("Ambiguous1")); - QQmlComponent c2(&engine, QUrl(u"qrc:/TestTypes/ambiguous2/Ambiguous.qml"_qs)); + QQmlComponent c2(&engine, QUrl(u"qrc:/TestTypes/ambiguous2/Ambiguous.qml"_s)); QVERIFY2(c2.isReady(), qPrintable(c2.errorString())); QScopedPointer<QObject> o2(c2.create()); QCOMPARE(o2->objectName(), QStringLiteral("Ambiguous")); @@ -1994,7 +1996,7 @@ void tst_QmlCppCodegen::evadingAmbiguity() void tst_QmlCppCodegen::fromBoolValue() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/fromBoolValue.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/fromBoolValue.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QCOMPARE(o->property("a").toBool(), true); @@ -2009,7 +2011,7 @@ void tst_QmlCppCodegen::fromBoolValue() QCOMPARE(o->property("width").toInt(), 100); QCOMPARE(o->property("b").toBool(), false); - o->setProperty("state", QVariant::fromValue(u"foo"_qs)); + o->setProperty("state", QVariant::fromValue(u"foo"_s)); QCOMPARE(o->property("width").toInt(), 0); QCOMPARE(o->property("b").toBool(), false); } @@ -2017,7 +2019,7 @@ void tst_QmlCppCodegen::fromBoolValue() void tst_QmlCppCodegen::invisibleTypes() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleTypes.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleTypes.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -2068,20 +2070,20 @@ void tst_QmlCppCodegen::invalidPropertyType() qmlRegisterType<MyCppType>("App", 1, 0, "MyCppType"); QQmlEngine engine; - QQmlComponent okComponent(&engine, QUrl(u"qrc:/TestTypes/OkType.qml"_qs)); + QQmlComponent okComponent(&engine, QUrl(u"qrc:/TestTypes/OkType.qml"_s)); QVERIFY2(okComponent.isReady(), qPrintable(okComponent.errorString())); QScopedPointer<QObject> picker(okComponent.create()); QVERIFY2(!picker.isNull(), qPrintable(okComponent.errorString())); - QObject *inner = qmlContext(picker.data())->objectForName(u"inner"_qs); + QObject *inner = qmlContext(picker.data())->objectForName(u"inner"_s); QVERIFY(inner); MyCppType *myCppType = qobject_cast<MyCppType *>(inner); QVERIFY(myCppType); QVERIFY(!myCppType->useListDelegate()); - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/BadType.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/BadType.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.createWithInitialProperties( - QVariantMap {{u"picker"_qs, QVariant::fromValue(picker.data())}})); + QVariantMap {{u"picker"_s, QVariant::fromValue(picker.data())}})); QVERIFY2(!o.isNull(), qPrintable(c.errorString())); QVERIFY(!myCppType->useListDelegate()); @@ -2102,7 +2104,7 @@ void tst_QmlCppCodegen::runInterpreted() QProcess process; process.setProgram(QCoreApplication::applicationFilePath()); process.setEnvironment(QProcess::systemEnvironment() - + QStringList(u"QV4_FORCE_INTERPRETER=1"_qs)); + + QStringList(u"QV4_FORCE_INTERPRETER=1"_s)); process.start(); QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); diff --git a/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp b/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp index 1212cd3c82..11f4425f61 100644 --- a/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp +++ b/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp @@ -31,6 +31,8 @@ #include <QString> #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + class TestQmlimportscanner: public QQmlDataTest { Q_OBJECT @@ -127,9 +129,9 @@ void TestQmlimportscanner::modules() void TestQmlimportscanner::qmldirPreference() { // ### - QStringList with {u"-importPath"_qs, testFile("With")}; - QStringList withOut {u"-importPath"_qs, testFile("WithOut")}; - QStringList genericArgs {u"-qmlFiles"_qs, testFile("qmldirpref.qml"), u"-importPath"_qs, + QStringList with {u"-importPath"_s, testFile("With")}; + QStringList withOut {u"-importPath"_s, testFile("WithOut")}; + QStringList genericArgs {u"-qmlFiles"_s, testFile("qmldirpref.qml"), u"-importPath"_s, QLibraryInfo::path(QLibraryInfo::QmlImportsPath)}; diff --git a/tests/auto/qml/qmllint/lintplugin.cpp b/tests/auto/qml/qmllint/lintplugin.cpp index 9fe0789f41..91f3f41749 100644 --- a/tests/auto/qml/qmllint/lintplugin.cpp +++ b/tests/auto/qml/qmllint/lintplugin.cpp @@ -28,6 +28,8 @@ #include "lintplugin.h" +using namespace Qt::StringLiterals; + class ElementTest : public QQmlSA::ElementPass { public: @@ -43,13 +45,13 @@ public: void run(const QQmlSA::Element &element) override { - auto property = element->property(u"radius"_qs); - if (!property.isValid() || element->property(u"radius"_qs).typeName() != u"double") { + auto property = element->property(u"radius"_s); + if (!property.isValid() || element->property(u"radius"_s).typeName() != u"double") { emitWarning(u"Failed to verify radius property", element->sourceLocation()); return; } - auto bindings = element->propertyBindings(u"radius"_qs); + auto bindings = element->propertyBindings(u"radius"_s); if (bindings.isEmpty() || bindings.constFirst().numberValue() != 5) { emitWarning(u"Failed to verify radius property binding", element->sourceLocation()); return; diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 492ec95350..4fc5357177 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -236,7 +236,7 @@ void TestQmllint::testUnqualified_data() 33 } // builtin property }, {}, - { { Message { u"root."_qs, 9, 16 } }, { Message { u"root."_qs, 13, 33 } } } + { { Message { u"root."_s, 9, 16 } }, { Message { u"root."_s, 13, 33 } } } }; // access injected name from signal QTest::newRow("SignalHandler") @@ -264,7 +264,7 @@ void TestQmllint::testUnqualified_data() Message { QStringLiteral("Unqualified access"), 6, 25 }, }, {}, - { { Message { u"<id>."_qs, 6, 25 } } } }; + { { Message { u"<id>."_s, 6, 25 } } } }; QTest::newRow("crashConnections") << QStringLiteral("crashConnections.qml") @@ -1215,7 +1215,7 @@ void TestQmllint::compilerWarnings() auto options = QQmlJSLogger::options(); if (enableCompilerWarnings) - options[u"compiler"_qs].setLevel(u"warning"_qs); + options[u"compiler"_s].setLevel(u"warning"_s); runTest(filename, result, {}, {}, {}, UseDefaultImports, &options); } @@ -1242,7 +1242,7 @@ void TestQmllint::controlsSanity() QJsonArray warnings; auto options = QQmlJSLogger::options(); - options[u"controls-sanity"_qs].setLevel(u"warning"_qs); + options[u"controls-sanity"_s].setLevel(u"warning"_s); runTest(filename, result, {}, {}, {}, UseDefaultImports, &options); } @@ -1354,7 +1354,7 @@ void TestQmllint::callQmllint(const QString &fileToLint, bool shouldSucceed, QJs if (warnings) { QVERIFY2(jsonOutput.size() == 1, QJsonDocument(jsonOutput).toJson()); - *warnings = jsonOutput.at(0)[u"warnings"_qs].toArray(); + *warnings = jsonOutput.at(0)[u"warnings"_s].toArray(); } QCOMPARE(success, shouldSucceed); @@ -1377,15 +1377,15 @@ void TestQmllint::callQmllint(const QString &fileToLint, bool shouldSucceed, QJs callQmllint(QFileInfo(file).absoluteFilePath(), true, nullptr, importPaths, qmldirFiles, resources, defaultImports, options, false); - const QString fixedPath = testFile(info.baseName() + u".fixed.qml"_qs); + const QString fixedPath = testFile(info.baseName() + u".fixed.qml"_s); if (QFileInfo(fixedPath).exists()) { QFile fixedFile(fixedPath); fixedFile.open(QFile::ReadOnly); QString fixedFileContents = QString::fromUtf8(fixedFile.readAll()); #ifdef Q_OS_WIN - fixedCode = fixedCode.replace(u"\r\n"_qs, u"\n"_qs); - fixedFileContents = fixedFileContents.replace(u"\r\n"_qs, u"\n"_qs); + fixedCode = fixedCode.replace(u"\r\n"_s, u"\n"_s); + fixedFileContents = fixedFileContents.replace(u"\r\n"_s, u"\n"_s); #endif QCOMPARE(fixedCode, fixedFileContents); @@ -1493,7 +1493,7 @@ void TestQmllint::searchWarnings(const QJsonArray &warnings, const QString &subs #ifdef Q_OS_WIN // Replacements can contain native line endings // but we need them to be uniform in order for them to conform to our test data - replacement = replacement.replace(u"\r\n"_qs, u"\n"_qs); + replacement = replacement.replace(u"\r\n"_s, u"\n"_s); #endif if (replacement.contains(substring)) { @@ -1582,7 +1582,7 @@ void TestQmllint::attachedPropertyReuse() { auto options = QQmlJSLogger::options(); - options[u"multiple-attached-objects"_qs].setLevel(u"warning"_qs); + options[u"multiple-attached-objects"_s].setLevel(u"warning"_s); runTest("attachedPropNotReused.qml", Result { { Message { QStringLiteral("Using attached type QQuickKeyNavigationAttached " "already initialized in a parent " @@ -1607,7 +1607,7 @@ void TestQmllint::missingBuiltinsNoCrash() QVERIFY2(!success, QJsonDocument(jsonOutput).toJson()); QVERIFY2(jsonOutput.size() == 1, QJsonDocument(jsonOutput).toJson()); - warnings = jsonOutput.at(0)[u"warnings"_qs].toArray(); + warnings = jsonOutput.at(0)[u"warnings"_s].toArray(); checkResult(warnings, Result { { Message { QStringLiteral("Failed to find the following builtins: " @@ -1636,20 +1636,20 @@ void TestQmllint::testPlugin() for (const QQmlJSLinter::Plugin &plugin : m_linter.plugins()) { if (plugin.name() == "testPlugin") { pluginFound = true; - QCOMPARE(plugin.author(), u"Qt"_qs); - QCOMPARE(plugin.description(), u"A test plugin for tst_qmllint"_qs); - QCOMPARE(plugin.version(), u"1.0"_qs); + QCOMPARE(plugin.author(), u"Qt"_s); + QCOMPARE(plugin.description(), u"A test plugin for tst_qmllint"_s); + QCOMPARE(plugin.version(), u"1.0"_s); break; } } QVERIFY(pluginFound); - runTest("elementpass_pluginTest.qml", Result { { Message { u"ElementTest OK"_qs, 4, 5 } } }); - runTest("propertypass_pluginTest.qml", Result { { Message { u"OK"_qs } } }); + runTest("elementpass_pluginTest.qml", Result { { Message { u"ElementTest OK"_s, 4, 5 } } }); + runTest("propertypass_pluginTest.qml", Result { { Message { u"OK"_s } } }); runTest("controlsWithQuick_pluginTest.qml", - Result { { Message { u"QtQuick.Controls, QtQuick and QtQuick.Window present"_qs } } }); + Result { { Message { u"QtQuick.Controls, QtQuick and QtQuick.Window present"_s } } }); runTest("controlsWithoutQuick_pluginTest.qml", - Result { { Message { u"QtQuick.Controls and NO QtQuick present"_qs } } }); + Result { { Message { u"QtQuick.Controls and NO QtQuick present"_s } } }); // Verify that none of the passes do anything when they're not supposed to runTest("nothing_pluginTest.qml", Result::clean()); } @@ -1667,50 +1667,50 @@ void TestQmllint::quickPlugin() runTest("pluginQuick_anchors.qml", Result{ { Message{ - u"Cannot specify left, right, and horizontalCenter anchors at the same time."_qs }, + u"Cannot specify left, right, and horizontalCenter anchors at the same time."_s }, Message { - u"Cannot specify top, bottom, and verticalCenter anchors at the same time."_qs }, + u"Cannot specify top, bottom, and verticalCenter anchors at the same time."_s }, Message{ - u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_qs }, + u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_s }, Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 5, 35 }, Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 8, 33 } } }); runTest("pluginQuick_layoutChildren.qml", Result { { Message { - u"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead."_qs }, + u"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead."_s }, Message { - u"Detected x on an item that is managed by a layout. This is undefined behavior; use Layout.leftMargin or Layout.rightMargin instead."_qs }, + u"Detected x on an item that is managed by a layout. This is undefined behavior; use Layout.leftMargin or Layout.rightMargin instead."_s }, Message { - u"Detected y on an item that is managed by a layout. This is undefined behavior; use Layout.topMargin or Layout.bottomMargin instead."_qs }, + u"Detected y on an item that is managed by a layout. This is undefined behavior; use Layout.topMargin or Layout.bottomMargin instead."_s }, Message { - u"Detected height on an item that is managed by a layout. This is undefined behavior; use implictHeight or Layout.preferredHeight instead."_qs }, + u"Detected height on an item that is managed by a layout. This is undefined behavior; use implictHeight or Layout.preferredHeight instead."_s }, Message { - u"Detected width on an item that is managed by a layout. This is undefined behavior; use implicitWidth or Layout.preferredWidth instead."_qs }, + u"Detected width on an item that is managed by a layout. This is undefined behavior; use implicitWidth or Layout.preferredWidth instead."_s }, Message { - u"Cannot specify anchors for items inside Grid. Grid will not function."_qs }, + u"Cannot specify anchors for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify x for items inside Grid. Grid will not function."_qs }, + u"Cannot specify x for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify y for items inside Grid. Grid will not function."_qs }, + u"Cannot specify y for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify anchors for items inside Flow. Flow will not function."_qs }, + u"Cannot specify anchors for items inside Flow. Flow will not function."_s }, Message { - u"Cannot specify x for items inside Flow. Flow will not function."_qs }, + u"Cannot specify x for items inside Flow. Flow will not function."_s }, Message { - u"Cannot specify y for items inside Flow. Flow will not function."_qs } } }); + u"Cannot specify y for items inside Flow. Flow will not function."_s } } }); runTest("pluginQuick_attached.qml", Result { - { Message { u"ToolTip must be attached to an Item"_qs }, - Message { u"SplitView attached property only works with Items"_qs }, - Message { u"ScrollIndicator must be attached to a Flickable"_qs }, - Message { u"ScrollBar must be attached to a Flickable or ScrollView"_qs }, - Message { u"Accessible must be attached to an Item"_qs }, - Message { u"EnterKey attached property only works with Items"_qs }, + { Message { u"ToolTip must be attached to an Item"_s }, + Message { u"SplitView attached property only works with Items"_s }, + Message { u"ScrollIndicator must be attached to a Flickable"_s }, + Message { u"ScrollBar must be attached to a Flickable or ScrollView"_s }, + Message { u"Accessible must be attached to an Item"_s }, + Message { u"EnterKey attached property only works with Items"_s }, Message { - u"LayoutDirection attached property only works with Items and Windows"_qs }, - Message { u"Layout must be attached to Item elements"_qs }, - Message { u"StackView attached property only works with Items"_qs } } }); + u"LayoutDirection attached property only works with Items and Windows"_s }, + Message { u"Layout must be attached to Item elements"_s }, + Message { u"StackView attached property only works with Items"_s } } }); } #endif diff --git a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp index d0ea6c4c9f..322211b44d 100644 --- a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp +++ b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp @@ -28,6 +28,8 @@ #include "typewithproperties.h" +using namespace Qt::StringLiterals; + double TypeWithProperties::a() const { return m_a; @@ -72,7 +74,7 @@ void TypeWithProperties::setD(int d_) { if (m_d != d_) { m_d = d_; - Q_EMIT dSignal(u"d changed"_qs, d_); + Q_EMIT dSignal(u"d changed"_s, d_); } } void TypeWithProperties::setJsValue(const QJSValue &value) diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index 955911e52a..7ea496fd17 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -112,6 +112,8 @@ #define PREPEND_NAMESPACE(name) ::QmltcTest::name // silent contract that the namespace is QmltcTest +using namespace Qt::StringLiterals; + tst_qmltc::tst_qmltc() { #if defined(QMLTC_TESTS_DISABLE_CACHE) && QMLTC_TESTS_DISABLE_CACHE @@ -187,7 +189,7 @@ void tst_qmltc::initTestCase() QQmlComponent component(&e); for (const auto &url : urls) { component.loadUrl(url); - QVERIFY2(!component.isError(), qPrintable(u"Bad QML file. "_qs + component.errorString())); + QVERIFY2(!component.isError(), qPrintable(u"Bad QML file. "_s + component.errorString())); } } @@ -362,16 +364,16 @@ void tst_qmltc::properties() QCOMPARE(created.doubleP(), 0.5); QCOMPARE(created.intP(), 42); QCOMPARE(created.realP(), 2.32); - QCOMPARE(created.stringP(), u"hello, world"_qs); - QCOMPARE(created.urlP(), u"https://www.qt.io/"_qs); + QCOMPARE(created.stringP(), u"hello, world"_s); + QCOMPARE(created.urlP(), u"https://www.qt.io/"_s); QCOMPARE(created.varP(), 42.42); QCOMPARE(created.boolP(), true); QCOMPARE(created.boolP(), true); - QCOMPARE(created.colorP(), QColor(u"blue"_qs)); + QCOMPARE(created.colorP(), QColor(u"blue"_s)); - QCOMPARE(created.readonlyStringP(), u"foobar"_qs); + QCOMPARE(created.readonlyStringP(), u"foobar"_s); // object bindinds: const auto objectCtx = e.contextForObject(&created); @@ -380,12 +382,12 @@ void tst_qmltc::properties() { QQuickText *child0 = qobject_cast<QQuickText *>(listQtObj.at(0)); QVERIFY(child0); - QCOMPARE(child0->text(), u"child0"_qs); + QCOMPARE(child0->text(), u"child0"_s); QCOMPARE(objectCtx->objectForName("listQtObjP_child_0"), child0); QObject *child1 = listQtObj.at(1); QVERIFY(child1); - QCOMPARE(child1->property("what").toString(), u"child1"_qs); + QCOMPARE(child1->property("what").toString(), u"child1"_s); QQuickItem *child2 = qobject_cast<QQuickItem *>(listQtObj.at(2)); QVERIFY(child2); @@ -417,17 +419,17 @@ void tst_qmltc::properties() QScopedPointer<QObject> beforeDelegateObject(beforeDelegate->create()); QVERIFY(beforeDelegateObject); QVERIFY(qobject_cast<QQuickText *>(beforeDelegateObject.get())); - QCOMPARE(beforeDelegateObject->property("text").toString(), u"beforeDelegate"_qs); + QCOMPARE(beforeDelegateObject->property("text").toString(), u"beforeDelegate"_s); QScopedPointer<QObject> delegateObject(delegate->create()); QVERIFY(delegateObject); QVERIFY(qobject_cast<QQuickText *>(delegateObject.get())); - QCOMPARE(delegateObject->property("text").toString(), u"delegate"_qs); + QCOMPARE(delegateObject->property("text").toString(), u"delegate"_s); QScopedPointer<QObject> afterDelegateObject(afterDelegate->create()); QVERIFY(afterDelegateObject); QVERIFY(qobject_cast<QQuickText *>(afterDelegateObject.get())); - QCOMPARE(afterDelegateObject->property("text").toString(), u"afterDelegate"_qs); + QCOMPARE(afterDelegateObject->property("text").toString(), u"afterDelegate"_s); } QQmlComponent *explicitComp = qobject_cast<QQmlComponent *>(created.explicitCompP()); @@ -435,11 +437,11 @@ void tst_qmltc::properties() QScopedPointer<QObject> explicitCompObject(explicitComp->create()); QVERIFY(explicitCompObject); QVERIFY(qobject_cast<QQuickText *>(explicitCompObject.get())); - QCOMPARE(explicitCompObject->property("text").toString(), u"not a delegate"_qs); + QCOMPARE(explicitCompObject->property("text").toString(), u"not a delegate"_s); QObject *sentinelForComponent = created.sentinelForComponent(); QVERIFY(sentinelForComponent); - QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_qs); + QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_s); } void tst_qmltc::ids() @@ -474,15 +476,15 @@ void tst_qmltc::ids() return object->objectName(); }; - QCOMPARE(objectNameById("rectangle"), u"rectangle"_qs); - QCOMPARE(objectNameById("row"), u"row"_qs); - QCOMPARE(objectNameById("textInRectangle"), u"textInRectangle"_qs); - QCOMPARE(objectNameById("itemInList"), u"itemInList"_qs); - QCOMPARE(objectNameById("objectInList"), u"objectInList"_qs); - QCOMPARE(objectNameById("item"), u"item"_qs); - QCOMPARE(objectNameById("gridView"), u"gridView"_qs); - QCOMPARE(objectNameById("tableView"), u"tableView"_qs); - QCOMPARE(objectNameById("sentinel"), u"sentinel"_qs); + QCOMPARE(objectNameById("rectangle"), u"rectangle"_s); + QCOMPARE(objectNameById("row"), u"row"_s); + QCOMPARE(objectNameById("textInRectangle"), u"textInRectangle"_s); + QCOMPARE(objectNameById("itemInList"), u"itemInList"_s); + QCOMPARE(objectNameById("objectInList"), u"objectInList"_s); + QCOMPARE(objectNameById("item"), u"item"_s); + QCOMPARE(objectNameById("gridView"), u"gridView"_s); + QCOMPARE(objectNameById("tableView"), u"tableView"_s); + QCOMPARE(objectNameById("sentinel"), u"sentinel"_s); const auto verifyComponent = [&](QQmlComponent *component, const QString &componentId, const QString &objectId) { @@ -499,22 +501,22 @@ void tst_qmltc::ids() }; auto explicitComponent = qobject_cast<QQmlComponent *>(created.explicitCompProperty()); - verifyComponent(explicitComponent, u"explicitComponent"_qs, u"explicitText"_qs); + verifyComponent(explicitComponent, u"explicitComponent"_s, u"explicitText"_s); QQmlListReference children(&created, "data"); QCOMPARE(children.size(), 2); QQuickTableView *table = qobject_cast<QQuickTableView *>(children.at(1)); QVERIFY(table); - QCOMPARE(ctx->objectForName(u"tableView"_qs), table); - QCOMPARE(table->objectName(), u"tableView"_qs); + QCOMPARE(ctx->objectForName(u"tableView"_s), table); + QCOMPARE(table->objectName(), u"tableView"_s); auto before = qvariant_cast<QQmlComponent *>(table->property("before")); - verifyComponent(before, u"beforeDelegate"_qs, u"beforeDelegateText"_qs); + verifyComponent(before, u"beforeDelegate"_s, u"beforeDelegateText"_s); auto after = qvariant_cast<QQmlComponent *>(table->property("after")); - verifyComponent(after, u"afterDelegate"_qs, u"afterDelegateText"_qs); + verifyComponent(after, u"afterDelegate"_s, u"afterDelegateText"_s); auto delegate = table->delegate(); - verifyComponent(delegate, /* implicit component */ QString(), u"delegateRect"_qs); + verifyComponent(delegate, /* implicit component */ QString(), u"delegateRect"_s); // TableView is really special when you add Component to a default // property. see QQuickFlickablePrivate::data_append @@ -527,15 +529,15 @@ void tst_qmltc::ids() if (!comp) continue; // this is bad, but there doesn't seem to be any better choice - if (ctx->objectForName(u"beforeDelegateDefaultProperty"_qs) == comp) + if (ctx->objectForName(u"beforeDelegateDefaultProperty"_s) == comp) beforeChild = comp; - else if (ctx->objectForName(u"afterDelegateDefaultProperty"_qs) == comp) + else if (ctx->objectForName(u"afterDelegateDefaultProperty"_s) == comp) afterChild = comp; } // we just used ctx->objectForName() to find these components, so // there's no point in checking the same condition in verifyComponent() - verifyComponent(beforeChild, QString(), u"beforeDelegateDefaultPropertyText"_qs); - verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_qs); + verifyComponent(beforeChild, QString(), u"beforeDelegateDefaultPropertyText"_s); + verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_s); } } @@ -543,7 +545,7 @@ void tst_qmltc::importNamespace() { QQmlEngine e; PREPEND_NAMESPACE(importNamespace) created(&e); // compilation of this type shouldn't crash - QCOMPARE(created.text(), u"hello, world"_qs); + QCOMPARE(created.text(), u"hello, world"_s); } void tst_qmltc::componentTypes() @@ -556,7 +558,7 @@ void tst_qmltc::componentTypes() QScopedPointer<QObject> enclosed(created.create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } { @@ -564,18 +566,18 @@ void tst_qmltc::componentTypes() PREPEND_NAMESPACE(componentTypes) created(&e); QQmlContext *ctx = e.contextForObject(&created); - QObject *normal = ctx->objectForName(u"normal"_qs); + QObject *normal = ctx->objectForName(u"normal"_s); QVERIFY(normal); - QCOMPARE(normal->property("text").toString(), u"indirect component"_qs); + QCOMPARE(normal->property("text").toString(), u"indirect component"_s); - QVERIFY(ctx->objectForName(u"accessibleNormal"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_qs)); - QVERIFY(ctx->objectForName(u"accessible"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessible"_qs)); - QVERIFY(ctx->objectForName(u"accessibleDelegate"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_qs)); + QVERIFY(ctx->objectForName(u"accessibleNormal"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_s)); + QVERIFY(ctx->objectForName(u"accessible"_s)); + QVERIFY(!ctx->objectForName(u"inaccessible"_s)); + QVERIFY(ctx->objectForName(u"accessibleDelegate"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_s)); - QCOMPARE(created.p2()->property("text").toString(), u"foo"_qs); + QCOMPARE(created.p2()->property("text").toString(), u"foo"_s); QVERIFY(created.p3()->property("text").toString().isEmpty()); // ComponentType still subclasses QQmlComponent, so create() works: @@ -583,16 +585,16 @@ void tst_qmltc::componentTypes() QVERIFY(normalComponent); QScopedPointer<QObject> enclosed(normalComponent->create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); QQmlListReference children(&created, "data"); QCOMPARE(children.size(), 4); - QCOMPARE(ctx->objectForName(u"normal"_qs), children.at(0)); - QCOMPARE(ctx->objectForName(u"accessibleNormal"_qs), children.at(1)); - QCOMPARE(ctx->objectForName(u"accessible"_qs), created.p2()); + QCOMPARE(ctx->objectForName(u"normal"_s), children.at(0)); + QCOMPARE(ctx->objectForName(u"accessibleNormal"_s), children.at(1)); + QCOMPARE(ctx->objectForName(u"accessible"_s), created.p2()); QQuickTableView *table = qobject_cast<QQuickTableView *>(children.at(3)); QVERIFY(table); - QCOMPARE(ctx->objectForName(u"accessibleDelegate"_qs), table->delegate()); + QCOMPARE(ctx->objectForName(u"accessibleDelegate"_s), table->delegate()); } } @@ -622,7 +624,7 @@ void tst_qmltc::deferredProperties() { QQmlEngine e; PREPEND_NAMESPACE(deferredProperties_group) created(&e); - QCOMPARE(created.getGroup()->getStr(), u"foobar"_qs); + QCOMPARE(created.getGroup()->getStr(), u"foobar"_s); QCOMPARE(created.getGroup()->getDeferred(), 0); // Note: we can't easily evaluate a deferred binding for a // `group.deferred` here, so just accept the fact the the value is not @@ -647,7 +649,7 @@ void tst_qmltc::deferredProperties() // `group` binding is not deferred as per current behavior outside of // PropertyChanges and friends. we defer `group.deferred` binding though - QCOMPARE(created.getGroup()->getStr(), u"still immediate"_qs); + QCOMPARE(created.getGroup()->getStr(), u"still immediate"_s); QCOMPARE(created.getGroup()->getDeferred(), 0); QVERIFY(!qmlAttachedPropertiesObject<DeferredAttached>(&created, false)); @@ -1034,11 +1036,11 @@ void tst_qmltc::complexAliases() QCOMPARE(created.aliasToPrivatePalette(), QQuickItemPrivate::get(theRect)->palette()); QSignalSpy paletteChangedSpy(&created, &PREPEND_NAMESPACE(complexAliases)::aliasToPrivatePaletteChanged); QQuickPalette *newPalette = new QQuickPalette(&created); - newPalette->fromQPalette(QPalette(QColor(u"cyan"_qs))); - QCOMPARE(newPalette->button(), QColor(u"cyan"_qs)); + newPalette->fromQPalette(QPalette(QColor(u"cyan"_s))); + QCOMPARE(newPalette->button(), QColor(u"cyan"_s)); created.setAliasToPrivatePalette(newPalette); QCOMPARE(paletteChangedSpy.count(), 1); - QCOMPARE(QQuickItemPrivate::get(theRect)->palette()->button(), QColor(u"cyan"_qs)); + QCOMPARE(QQuickItemPrivate::get(theRect)->palette()->button(), QColor(u"cyan"_s)); QCOMPARE(created.aliasToPrivatePalette(), QQuickItemPrivate::get(theRect)->palette()); // aliasToAnchors: @@ -1340,7 +1342,7 @@ void tst_qmltc::groupedProperty_qquicktext() QCOMPARE(anchors->bottomMargin(), qreal(42)); QFont font = created.font(); - QCOMPARE(font.family(), u"Helvetica"_qs); + QCOMPARE(font.family(), u"Helvetica"_s); QCOMPARE(font.pointSize(), 4); QQmlListReference ref(&created, "data"); @@ -1850,13 +1852,13 @@ void tst_qmltc::privateProperties() { QQmlEngine e; PREPEND_NAMESPACE(privatePropertySubclass) created(&e); - QCOMPARE(created.dummy(), u"bar"_qs); - QCOMPARE(created.strAlias(), u"foobar"_qs); + QCOMPARE(created.dummy(), u"bar"_s); + QCOMPARE(created.strAlias(), u"foobar"_s); QCOMPARE(created.smthAlias(), 42); auto privateCreated = static_cast<PrivatePropertyTypePrivate *>(QObjectPrivate::get(&created)); QVERIFY(privateCreated); - QCOMPARE(privateCreated->foo(), u"Smth is: 42"_qs); + QCOMPARE(privateCreated->foo(), u"Smth is: 42"_s); ValueTypeGroup vt = privateCreated->vt(); QCOMPARE(vt.count(), 11); @@ -1890,7 +1892,7 @@ void tst_qmltc::calqlatrBits() // sanity QVERIFY(anim); QCOMPARE(anim->target(), textItem); - QCOMPARE(anim->property(), u"scale"_qs); + QCOMPARE(anim->property(), u"scale"_s); QCOMPARE(anim->duration(), 50); QCOMPARE(anim->from(), 1); QCOMPARE(anim->to(), 0.5); @@ -1947,7 +1949,7 @@ void tst_qmltc::trickyPropertyChangeAndSignalHandlers() QCOMPARE(created.cChangedCount3(), 42); three->setD(10); QCOMPARE(created.dChangedCount3(), 10); - QCOMPARE(created.dChangedStr3(), u"d changed"_qs); + QCOMPARE(created.dChangedStr3(), u"d changed"_s); four->setC(1.5); QCOMPARE(created.cChangedCount4(), 2); // cChangedCount4 is int, so 0.5 is truncated four->setD(84); @@ -1956,7 +1958,7 @@ void tst_qmltc::trickyPropertyChangeAndSignalHandlers() // this test, it would mean that we get proper dChanged*4 values intead of // `undefined` junk QCOMPARE(created.dChangedCount4(), 42); - QCOMPARE(created.dChangedStr4(), u"d changed!"_qs); + QCOMPARE(created.dChangedStr4(), u"d changed!"_s); created.changeProperties1(); QCOMPARE(created.aChangedCount1(), 2); diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp index 09c77ce37a..50871eb5b2 100644 --- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp +++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp @@ -42,6 +42,8 @@ #include <functional> +using namespace Qt::StringLiterals; + class tst_qmltc_qprocess : public QQmlDataTest { Q_OBJECT @@ -55,7 +57,7 @@ class tst_qmltc_qprocess : public QQmlDataTest QString runQmltc(const QString &inputFile, bool shouldSucceed, const QStringList &extraArgs = {}); - QString modifiedPath(const QString &path) { return path + u".orig"_qs; } + QString modifiedPath(const QString &path) { return path + u".orig"_s; } public: tst_qmltc_qprocess() : QQmlDataTest(QT_QMLTEST_DATADIR) { } @@ -79,20 +81,20 @@ private slots: void tst_qmltc_qprocess::initTestCase() { QQmlDataTest::initTestCase(); - m_qmltcPath = QLibraryInfo::path(QLibraryInfo::BinariesPath) + u"/qmltc"_qs; + m_qmltcPath = QLibraryInfo::path(QLibraryInfo::BinariesPath) + u"/qmltc"_s; #ifdef Q_OS_WIN - m_qmltcPath += u".exe"_qs; + m_qmltcPath += u".exe"_s; #endif if (!QFileInfo(m_qmltcPath).exists()) { - const QString message = u"qmltc executable not found (looked for %0)"_qs.arg(m_qmltcPath); + const QString message = u"qmltc executable not found (looked for %0)"_s.arg(m_qmltcPath); QFAIL(qPrintable(message)); } - m_tmpPath = QDir::tempPath() + u"/tst_qmltc_qprocess_artifacts"_qs; + m_tmpPath = QDir::tempPath() + u"/tst_qmltc_qprocess_artifacts"_s; QVERIFY(QDir(m_tmpPath).removeRecursively()); // in case it's already there QVERIFY(QDir().mkpath(m_tmpPath)); - m_resources = QStringLiteral(TST_QMLTC_QPROCESS_RESOURCES).split(u"_::_"_qs); + m_resources = QStringLiteral(TST_QMLTC_QPROCESS_RESOURCES).split(u"_::_"_s); } void tst_qmltc_qprocess::cleanupTestCase() @@ -108,9 +110,9 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, args << (QFileInfo(inputFile).isAbsolute() ? inputFile : testFile(inputFile)); for (const QString &resource : m_resources) - args << u"--resource"_qs << resource; - args << u"--header"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".h"_qs); - args << u"--impl"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".cpp"_qs); + args << u"--resource"_s << resource; + args << u"--header"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".h"_s); + args << u"--impl"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".cpp"_s); args << extraArgs; QString errors; @@ -150,7 +152,7 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, bool shouldSuccee void tst_qmltc_qprocess::sanity() { - const auto output = runQmltc(u"dummy.qml"_qs, true); + const auto output = runQmltc(u"dummy.qml"_s, true); QVERIFY2(output.isEmpty(), qPrintable(output)); } @@ -163,8 +165,8 @@ void tst_qmltc_qprocess::noBuiltins() QVERIFY(file.rename(original)); }; - for (QString builtin : { u"builtins.qmltypes"_qs, u"jsroot.qmltypes"_qs }) { - const auto path = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/"_qs + builtin; + for (QString builtin : { u"builtins.qmltypes"_s, u"jsroot.qmltypes"_s }) { + const auto path = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/"_s + builtin; QScopeGuard scope(std::bind(renameBack, path)); QFile file(path); @@ -172,8 +174,8 @@ void tst_qmltc_qprocess::noBuiltins() QVERIFY(file.rename(modifiedPath(path))); // test that qmltc exits gracefully - const auto errors = runQmltc(u"dummy.qml"_qs, false); - QVERIFY(errors.contains(u"Failed to find the following builtins: %1"_qs.arg(builtin))); + const auto errors = runQmltc(u"dummy.qml"_s, false); + QVERIFY(errors.contains(u"Failed to find the following builtins: %1"_s.arg(builtin))); } } @@ -185,34 +187,34 @@ void tst_qmltc_qprocess::noQtQml() QVERIFY(QDir().rename(current, original)); }; - const auto modulePath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/QtQml"_qs; + const auto modulePath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/QtQml"_s; QScopeGuard scope(std::bind(renameBack, modulePath)); QVERIFY(QDir(modulePath).exists()); QVERIFY(QDir().rename(modulePath, modifiedPath(modulePath))); // test that qmltc exits gracefully - const auto errors = runQmltc(u"dummy.qml"_qs, false); - QVERIFY(errors.contains(u"Failed to import QtQml. Are your import paths set up properly?"_qs)); + const auto errors = runQmltc(u"dummy.qml"_s, false); + QVERIFY(errors.contains(u"Failed to import QtQml. Are your import paths set up properly?"_s)); } void tst_qmltc_qprocess::inlineComponent() { - const auto errors = runQmltc(u"inlineComponent.qml"_qs, false); + const auto errors = runQmltc(u"inlineComponent.qml"_s, false); QEXPECT_FAIL("", "qmltc does not support inline components at the moment", Continue); - QVERIFY(!errors.contains(u"Inline components are not supported"_qs)); + QVERIFY(!errors.contains(u"Inline components are not supported"_s)); } void tst_qmltc_qprocess::singleton() { - const auto errors = runQmltc(u"SingletonThing.qml"_qs, false); + const auto errors = runQmltc(u"SingletonThing.qml"_s, false); QEXPECT_FAIL("", "qmltc does not support singletons at the moment", Continue); - QVERIFY(!errors.contains(u"Singleton types are not supported"_qs)); + QVERIFY(!errors.contains(u"Singleton types are not supported"_s)); } void tst_qmltc_qprocess::warningsAsErrors() { - const auto errors = runQmltc(u"erroneousFile.qml"_qs, false); - QVERIFY2(errors.contains(u"Error:"_qs), qPrintable(errors)); // Note: not a warning! + const auto errors = runQmltc(u"erroneousFile.qml"_s, false); + QVERIFY2(errors.contains(u"Error:"_s), qPrintable(errors)); // Note: not a warning! } QTEST_MAIN(tst_qmltc_qprocess) diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index b760c34a53..68b80f8b53 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -47,6 +47,8 @@ #include <algorithm> +using namespace Qt::StringLiterals; + class WithQJSValue : public QObject { Q_OBJECT @@ -1096,7 +1098,7 @@ void tst_qqmlcomponent::initJSValueProp() QQmlComponent component(&engine); component.setData("import ComponentTest\nWithQJSValue {}", QUrl()); QVERIFY2(component.isReady(), qPrintable(component.errorString())); - QScopedPointer<QObject> o(component.createWithInitialProperties({{ u"v"_qs, 5}})); + QScopedPointer<QObject> o(component.createWithInitialProperties({{ u"v"_s, 5}})); QVERIFY(!o.isNull()); WithQJSValue *withQJSValue = qobject_cast<WithQJSValue *>(o.data()); QVERIFY(withQJSValue); @@ -1141,7 +1143,7 @@ void tst_qqmlcomponent::componentTypes() QVERIFY(oComponent); QScopedPointer<QObject> enclosed(oComponent->create()); QVERIFY(!enclosed.isNull()); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } { @@ -1153,20 +1155,20 @@ void tst_qqmlcomponent::componentTypes() QQmlContext *ctx = engine.contextForObject(o.get()); - QObject *normal = ctx->objectForName(u"normal"_qs); + QObject *normal = ctx->objectForName(u"normal"_s); QVERIFY(normal); - QCOMPARE(normal->property("text").toString(), u"indirect component"_qs); + QCOMPARE(normal->property("text").toString(), u"indirect component"_s); // check (and thus "document" in code) various ways of how ids work - QVERIFY(ctx->objectForName(u"accessibleNormal"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_qs)); - QVERIFY(ctx->objectForName(u"accessible"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessible"_qs)); - QVERIFY(ctx->objectForName(u"accessibleDelegate"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_qs)); + QVERIFY(ctx->objectForName(u"accessibleNormal"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_s)); + QVERIFY(ctx->objectForName(u"accessible"_s)); + QVERIFY(!ctx->objectForName(u"inaccessible"_s)); + QVERIFY(ctx->objectForName(u"accessibleDelegate"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_s)); QCOMPARE(qvariant_cast<QObject *>(o->property("p2"))->property("text").toString(), - u"foo"_qs); + u"foo"_s); auto p3Object = qvariant_cast<QObject *>(o->property("p3")); QVERIFY(p3Object); QVERIFY(p3Object->property("text").toString().isEmpty()); @@ -1175,7 +1177,7 @@ void tst_qqmlcomponent::componentTypes() QVERIFY(normalComponent); QScopedPointer<QObject> enclosed(normalComponent->create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 2ff9a28ee0..153b2b3c85 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -68,6 +68,8 @@ QML. This does not include static QML language issues. Static QML language issues are covered in qmllanguage */ +using namespace Qt::StringLiterals; + class tst_qqmlecmascript : public QQmlDataTest { Q_OBJECT @@ -7738,7 +7740,7 @@ void tst_qqmlecmascript::qpropertyBindingReplacement() QQmlComponent c(&engine, testFileUrl("qpropertyBindingReplacement.qml")); QScopedPointer<QObject> root(c.create()); QVERIFY(root); - QCOMPARE(root->objectName(), u"overwritten"_qs); + QCOMPARE(root->objectName(), u"overwritten"_s); } void tst_qqmlecmascript::deleteRootObjectInCreation() diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp index d6d56c52e0..66025ad361 100644 --- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp +++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp @@ -49,6 +49,8 @@ #include <QtQml/private/qqmljslexer_p.h> #include <QtQml/private/qqmljsparser_p.h> +using namespace Qt::StringLiterals; + class tst_qqmljsscope : public QQmlDataTest { Q_OBJECT @@ -141,7 +143,7 @@ void tst_qqmljsscope::initTestCase() QDirIterator it(dataDirectory(), QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while (it.hasNext()) { const QString url = it.next(); - if (!url.endsWith(u".qml"_qs)) // not interesting + if (!url.endsWith(u".qml"_s)) // not interesting continue; const QFileInfo fi(url); QVERIFY(fi.exists()); @@ -152,36 +154,36 @@ void tst_qqmljsscope::initTestCase() void tst_qqmljsscope::orderedBindings() { - QQmlJSScope::ConstPtr root = run(u"orderedBindings.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"orderedBindings.qml"_s); QVERIFY(root); - auto [pBindingsBegin, pBindingsEnd] = root->ownPropertyBindings(u"p"_qs); + auto [pBindingsBegin, pBindingsEnd] = root->ownPropertyBindings(u"p"_s); QVERIFY(std::distance(pBindingsBegin, pBindingsEnd) == 2); // check that the bindings are properly ordered QCOMPARE(pBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object); QCOMPARE(std::next(pBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Interceptor); - auto [itemsBindingsBegin, itemsBindingsEnd] = root->ownPropertyBindings(u"items"_qs); + auto [itemsBindingsBegin, itemsBindingsEnd] = root->ownPropertyBindings(u"items"_s); QVERIFY(std::distance(itemsBindingsBegin, itemsBindingsEnd) == 2); QCOMPARE(itemsBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object); QCOMPARE(std::next(itemsBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Object); - QCOMPARE(itemsBindingsBegin->objectType()->baseTypeName(), u"Item"_qs); - QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_qs); + QCOMPARE(itemsBindingsBegin->objectType()->baseTypeName(), u"Item"_s); + QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_s); } void tst_qqmljsscope::signalCreationDifferences() { - QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_s); QVERIFY(root); - QVERIFY(root->hasOwnProperty(u"myProperty"_qs)); - QVERIFY(root->hasOwnProperty(u"conflictingProperty"_qs)); - QCOMPARE(root->ownMethods(u"mySignal"_qs).size(), 1); + QVERIFY(root->hasOwnProperty(u"myProperty"_s)); + QVERIFY(root->hasOwnProperty(u"conflictingProperty"_s)); + QCOMPARE(root->ownMethods(u"mySignal"_s).size(), 1); - const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_qs); + const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_s); QCOMPARE(conflicting.size(), 2); QCOMPARE(conflicting[0].methodType(), QQmlJSMetaMethod::Signal); QCOMPARE(conflicting[1].methodType(), QQmlJSMetaMethod::Signal); @@ -191,7 +193,7 @@ void tst_qqmljsscope::signalCreationDifferences() explicitMethod = &conflicting[1]; else explicitMethod = &conflicting[0]; - QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_qs, u"c"_qs })); + QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_s, u"c"_s })); } void tst_qqmljsscope::allTypesAvailable() @@ -202,40 +204,40 @@ void tst_qqmljsscope::allTypesAvailable() }; QQmlJSImporter importer { importPaths, /* resource file mapper */ nullptr }; - const auto types = importer.importModule(u"QtQml"_qs); - QVERIFY(types.contains(u"$internal$.QObject"_qs)); - QVERIFY(types.contains(u"QtObject"_qs)); - QCOMPARE(types[u"$internal$.QObject"_qs].scope, types[u"QtObject"_qs].scope); + const auto types = importer.importModule(u"QtQml"_s); + QVERIFY(types.contains(u"$internal$.QObject"_s)); + QVERIFY(types.contains(u"QtObject"_s)); + QCOMPARE(types[u"$internal$.QObject"_s].scope, types[u"QtObject"_s].scope); } void tst_qqmljsscope::shadowing() { - QQmlJSScope::ConstPtr root = run(u"shadowing.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"shadowing.qml"_s); QVERIFY(root); QVERIFY(root->baseType()); // Check whether properties are properly shadowed const auto properties = root->properties(); - QVERIFY(properties.contains(u"property_not_shadowed"_qs)); - QVERIFY(properties.contains(u"property_shadowed"_qs)); + QVERIFY(properties.contains(u"property_not_shadowed"_s)); + QVERIFY(properties.contains(u"property_shadowed"_s)); - QCOMPARE(properties[u"property_not_shadowed"_qs].typeName(), u"QString"_qs); - QCOMPARE(properties[u"property_shadowed"_qs].typeName(), u"int"_qs); + QCOMPARE(properties[u"property_not_shadowed"_s].typeName(), u"QString"_s); + QCOMPARE(properties[u"property_shadowed"_s].typeName(), u"int"_s); // Check whether methods are properly shadowed const auto methods = root->methods(); - QCOMPARE(methods.count(u"method_not_shadowed"_qs), 1); - QCOMPARE(methods.count(u"method_shadowed"_qs), 1); + QCOMPARE(methods.count(u"method_not_shadowed"_s), 1); + QCOMPARE(methods.count(u"method_shadowed"_s), 1); - QCOMPARE(methods[u"method_not_shadowed"_qs].parameterNames().size(), 1); - QCOMPARE(methods[u"method_shadowed"_qs].parameterNames().size(), 0); + QCOMPARE(methods[u"method_not_shadowed"_s].parameterNames().size(), 1); + QCOMPARE(methods[u"method_shadowed"_s].parameterNames().size(), 0); } #ifdef LABS_QML_MODELS_PRESENT void tst_qqmljsscope::componentWrappedObjects() { - QQmlJSScope::ConstPtr root = run(u"componentWrappedObjects.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"componentWrappedObjects.qml"_s); QVERIFY(root); auto children = root->childScopes(); @@ -247,15 +249,15 @@ void tst_qqmljsscope::componentWrappedObjects() && type->isWrappedInImplicitComponent() == isWrapped; }; - QVERIFY(isGoodType(children[0], u"nonWrapped1"_qs, false)); - QVERIFY(isGoodType(children[1], u"nonWrapped2"_qs, false)); - QVERIFY(isGoodType(children[2], u"nonWrapped3"_qs, false)); - QVERIFY(isGoodType(children[3], u"wrapped"_qs, true)); + QVERIFY(isGoodType(children[0], u"nonWrapped1"_s, false)); + QVERIFY(isGoodType(children[1], u"nonWrapped2"_s, false)); + QVERIFY(isGoodType(children[2], u"nonWrapped3"_s, false)); + QVERIFY(isGoodType(children[3], u"wrapped"_s, true)); } void tst_qqmljsscope::labsQmlModelsSanity() { - QQmlJSScope::ConstPtr root = run(u"labsQmlModelsSanity.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"labsQmlModelsSanity.qml"_s); QVERIFY(root); auto children = root->childScopes(); QCOMPARE(children.size(), 1); @@ -266,26 +268,26 @@ void tst_qqmljsscope::labsQmlModelsSanity() // the QmlModels dependency is lost, we don't "see" that DelegateChooser // inherits QQmlComponent - and so has no properties from it, hence, we can // test exactly that: - QVERIFY(children[0]->hasProperty(u"progress"_qs)); - QVERIFY(children[0]->hasProperty(u"status"_qs)); - QVERIFY(children[0]->hasProperty(u"url"_qs)); + QVERIFY(children[0]->hasProperty(u"progress"_s)); + QVERIFY(children[0]->hasProperty(u"status"_s)); + QVERIFY(children[0]->hasProperty(u"url"_s)); } #endif void tst_qqmljsscope::unknownCppBase() { - QQmlJSScope::ConstPtr root = run(u"unknownCppBaseAssigningToVar.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"unknownCppBaseAssigningToVar.qml"_s); QVERIFY(root); // we should not crash here, then it is a success } void tst_qqmljsscope::groupedProperties() { - QQmlJSScope::ConstPtr root = run(u"groupProperties.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupProperties.qml"_s); QVERIFY(root); - QVERIFY(root->hasProperty(u"anchors"_qs)); - const auto anchorBindings = root->propertyBindings(u"anchors"_qs); + QVERIFY(root->hasProperty(u"anchors"_s)); + const auto anchorBindings = root->propertyBindings(u"anchors"_s); QVERIFY(!anchorBindings.isEmpty()); QCOMPARE(anchorBindings.size(), 2); // from type itself and from the base type @@ -306,29 +308,29 @@ void tst_qqmljsscope::groupedProperties() QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfType; getBindingsWithinGroup(&bindingsOfType, 0); QCOMPARE(bindingsOfType.size(), 2); - QCOMPARE(value(bindingsOfType, u"left"_qs).bindingType(), QQmlJSMetaPropertyBinding::Script); - QCOMPARE(value(bindingsOfType, u"leftMargin"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"left"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); + QCOMPARE(value(bindingsOfType, u"leftMargin"_s).bindingType(), QQmlJSMetaPropertyBinding::NumberLiteral); QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfBaseType; getBindingsWithinGroup(&bindingsOfBaseType, 1); QCOMPARE(bindingsOfBaseType.size(), 1); - QCOMPARE(value(bindingsOfBaseType, u"top"_qs).bindingType(), QQmlJSMetaPropertyBinding::Script); + QCOMPARE(value(bindingsOfBaseType, u"top"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); } void tst_qqmljsscope::descriptiveNameOfNull() { QQmlJSRegisterContent nullContent; - QCOMPARE(nullContent.descriptiveName(), u"(invalid type)"_qs); + QCOMPARE(nullContent.descriptiveName(), u"(invalid type)"_s); QQmlJSScope::Ptr stored = QQmlJSScope::create(); - stored->setInternalName(u"bar"_qs); + stored->setInternalName(u"bar"_s); QQmlJSMetaProperty property; - property.setPropertyName(u"foo"_qs); - property.setTypeName(u"baz"_qs); + property.setPropertyName(u"foo"_s); + property.setTypeName(u"baz"_s); QQmlJSRegisterContent unscoped = QQmlJSRegisterContent::create( stored, property, QQmlJSRegisterContent::ScopeProperty, QQmlJSScope::ConstPtr()); - QCOMPARE(unscoped.descriptiveName(), u"bar of (invalid type)::foo with type baz"_qs); + QCOMPARE(unscoped.descriptiveName(), u"bar of (invalid type)::foo with type baz"_s); } void tst_qqmljsscope::groupedPropertiesConsistency() @@ -336,7 +338,7 @@ void tst_qqmljsscope::groupedPropertiesConsistency() { QQmlEngine engine; QQmlComponent component(&engine); - component.loadUrl(testFileUrl(u"groupPropertiesConsistency.qml"_qs)); + component.loadUrl(testFileUrl(u"groupPropertiesConsistency.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> root(component.create()); QVERIFY2(root, qPrintable(component.errorString())); @@ -345,10 +347,10 @@ void tst_qqmljsscope::groupedPropertiesConsistency() } { - QQmlJSScope::ConstPtr root = run(u"groupPropertiesConsistency.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupPropertiesConsistency.qml"_s); QVERIFY(root); - const auto fontBindings = root->propertyBindings(u"font"_qs); + const auto fontBindings = root->propertyBindings(u"font"_s); QCOMPARE(fontBindings.size(), 2); // The binding order in QQmlJSScope case is "reversed": first come @@ -360,10 +362,10 @@ void tst_qqmljsscope::groupedPropertiesConsistency() void tst_qqmljsscope::groupedPropertySyntax() { - QQmlJSScope::ConstPtr root = run(u"groupPropertySyntax.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupPropertySyntax.qml"_s); QVERIFY(root); - const auto fontBindings = root->propertyBindings(u"font"_qs); + const auto fontBindings = root->propertyBindings(u"font"_s); QCOMPARE(fontBindings.size(), 1); // The binding order in QQmlJSScope case is "reversed": first come @@ -379,17 +381,17 @@ void tst_qqmljsscope::groupedPropertySyntax() return bindings.value(key, QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation {})); }; - QCOMPARE(value(subbindings, u"pixelSize"_qs).bindingType(), + QCOMPARE(value(subbindings, u"pixelSize"_s).bindingType(), QQmlJSMetaPropertyBinding::NumberLiteral); - QCOMPARE(value(subbindings, u"bold"_qs).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); + QCOMPARE(value(subbindings, u"bold"_s).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); } void tst_qqmljsscope::attachedProperties() { - QQmlJSScope::ConstPtr root = run(u"attachedProperties.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"attachedProperties.qml"_s); QVERIFY(root); - const auto keysBindings = root->propertyBindings(u"Keys"_qs); + const auto keysBindings = root->propertyBindings(u"Keys"_s); QVERIFY(!keysBindings.isEmpty()); QCOMPARE(keysBindings.size(), 2); // from type itself and from the base type @@ -410,15 +412,15 @@ void tst_qqmljsscope::attachedProperties() QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfType; getBindingsWithinAttached(&bindingsOfType, 0); QCOMPARE(bindingsOfType.size(), 2); - QCOMPARE(value(bindingsOfType, u"enabled"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"enabled"_s).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); - QCOMPARE(value(bindingsOfType, u"forwardTo"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"forwardTo"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfBaseType; getBindingsWithinAttached(&bindingsOfBaseType, 1); QCOMPARE(bindingsOfBaseType.size(), 1); - QCOMPARE(value(bindingsOfBaseType, u"priority"_qs).bindingType(), + QCOMPARE(value(bindingsOfBaseType, u"priority"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); } @@ -436,14 +438,14 @@ void tst_qqmljsscope::scriptIndices() { QQmlEngine engine; QQmlComponent component(&engine); - component.loadUrl(testFileUrl(u"functionAndBindingIndices.qml"_qs)); + component.loadUrl(testFileUrl(u"functionAndBindingIndices.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> root(component.create()); QVERIFY2(root, qPrintable(component.errorString())); } QmlIR::Document document(false); // we need QmlIR information here - QQmlJSScope::ConstPtr root = run(u"functionAndBindingIndices.qml"_qs, &document); + QQmlJSScope::ConstPtr root = run(u"functionAndBindingIndices.qml"_s, &document); QVERIFY(root); QVERIFY(document.javaScriptCompilationUnit.unitData()); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 3aad47c4aa..e844cd3d63 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -64,6 +64,8 @@ #include <unistd.h> #endif +using namespace Qt::StringLiterals; + DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) static inline bool isCaseSensitiveFileSystem(const QString &path) { @@ -2692,10 +2694,10 @@ void tst_qqmllanguage::defaultPropertyWithInitializer_data() QTest::addColumn<QUrl>("file"); QTest::addColumn<QString>("objectName"); - QTest::newRow("base") << testFileUrl("DefaultPropertyWithInitializer.qml") << u"default"_qs; - QTest::newRow("user") << testFileUrl("DefaultPropertyWithInitializerUser.qml") << u"changed"_qs; - QTest::newRow("list base") << testFileUrl("DefaultPropertyWithListInitializer.qml") << u"1"_qs; - QTest::newRow("list user") << testFileUrl("DefaultPropertyWithListInitializerUser.qml") << u"2"_qs; + QTest::newRow("base") << testFileUrl("DefaultPropertyWithInitializer.qml") << u"default"_s; + QTest::newRow("user") << testFileUrl("DefaultPropertyWithInitializerUser.qml") << u"changed"_s; + QTest::newRow("list base") << testFileUrl("DefaultPropertyWithListInitializer.qml") << u"1"_s; + QTest::newRow("list user") << testFileUrl("DefaultPropertyWithListInitializerUser.qml") << u"2"_s; } void tst_qqmllanguage::defaultPropertyWithInitializer() diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 09949dd610..830b7228f7 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -41,6 +41,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QVariantHash>) @@ -1777,7 +1779,7 @@ void tst_qqmllistmodel::objectDestroyed() std::unique_ptr<QObject> obj = std::make_unique<QObject>(); connect(obj.get(), &QObject::destroyed, [&]() { obj.release(); }); - engine.rootContext()->setContextProperty(u"contextObject"_qs, obj.get()); + engine.rootContext()->setContextProperty(u"contextObject"_s, obj.get()); engine.setObjectOwnership(obj.get(), QJSEngine::JavaScriptOwnership); delete component.create(); @@ -1785,7 +1787,7 @@ void tst_qqmllistmodel::objectDestroyed() engine.collectGarbage(); QTest::qSleep(250); QVERIFY(obj); - engine.evaluate(u"model.clear();"_qs); + engine.evaluate(u"model.clear();"_s); engine.collectGarbage(); QTRY_VERIFY(!obj); } @@ -1803,7 +1805,7 @@ void tst_qqmllistmodel::destroyObject() QUrl()); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> element(new QObject); - engine.rootContext()->setContextProperty(u"contextObject"_qs, element.data()); + engine.rootContext()->setContextProperty(u"contextObject"_s, element.data()); QScopedPointer<QObject> o(component.create()); QVERIFY(!o.isNull()); diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 497478b095..7bcfc6c3ac 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -39,6 +39,8 @@ #include <private/qqmlanybinding_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + class tst_qqmlmetatype : public QQmlDataTest { Q_OBJECT @@ -380,7 +382,7 @@ void tst_qqmlmetatype::interceptorAPI() QVERIFY(interceptor->interceptedWrite); QQmlProperty objectName(obj.get(), "objectName"); - QProperty<QString> hello(u"Hello, World!"_qs); + QProperty<QString> hello(u"Hello, World!"_s); QQmlAnyBinding binding; binding = Qt::makePropertyBinding(hello); interceptor->interceptedBindable = false; diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 402a68afae..e2cd13e18f 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -48,6 +48,8 @@ #include "qobject.h" #include <QtQml/QQmlPropertyMap> +using namespace Qt::StringLiterals; + #include <QDebug> class MyQmlObject : public QObject { @@ -2356,18 +2358,18 @@ void tst_qqmlproperty::dontRemoveQPropertyBinding() QVERIFY(object.bindableObjectName().hasBinding()); // A write with DontRemoveBinding preserves the binding - QQmlPropertyPrivate::write(objectName, u"goodbye"_qs, QQmlPropertyData::DontRemoveBinding); + QQmlPropertyPrivate::write(objectName, u"goodbye"_s, QQmlPropertyData::DontRemoveBinding); QVERIFY(object.bindableObjectName().hasBinding()); // but changes the value - QCOMPARE(object.objectName(), u"goodbye"_qs); + QCOMPARE(object.objectName(), u"goodbye"_s); // subsequent binding evaluations change the value again - name = u"hello, again"_qs; + name = u"hello, again"_s; QCOMPARE(object.objectName(), name.value()); // The binding is only preserved by the write which had DontRemoveBinding set // any further write will remove the binding - QQmlPropertyPrivate::write(objectName, u"goodbye"_qs, QQmlPropertyData::WriteFlags{}); - QCOMPARE(object.objectName(), u"goodbye"_qs); + QQmlPropertyPrivate::write(objectName, u"goodbye"_s, QQmlPropertyData::WriteFlags{}); + QCOMPARE(object.objectName(), u"goodbye"_s); QVERIFY(!object.bindableObjectName().hasBinding()); } @@ -2401,7 +2403,7 @@ void tst_qqmlproperty::compatResolveUrls() QProcess process; process.setProgram(QCoreApplication::applicationFilePath()); process.setEnvironment(QProcess::systemEnvironment() - + QStringList(u"QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT=1"_qs)); + + QStringList(u"QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT=1"_s)); process.setArguments({QStringLiteral("compatResolveUrls")}); process.start(); QVERIFY(process.waitForFinished()); diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 944a7c8762..4194272153 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -35,6 +35,8 @@ #include <QSignalSpy> #include <QDebug> +using namespace Qt::StringLiterals; + class tst_QQmlPropertyMap : public QQmlDataTest { Q_OBJECT @@ -604,10 +606,10 @@ public: Map(QObject *parent = nullptr) : QQmlPropertyMap(this, parent) { - insert( "a", u"yayayaya"_qs ); - insert( "b", u"yayayayb"_qs); - insert( "c", u"yayayayc"_qs); - insert( "d", u"yayayayd"_qs); + insert( "a", u"yayayaya"_s ); + insert( "b", u"yayayayb"_s); + insert( "c", u"yayayayc"_s); + insert( "d", u"yayayayd"_s); freeze(); } @@ -623,18 +625,18 @@ void tst_QQmlPropertyMap::cachedSignals() QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(!o.isNull()); - QCOMPARE(o->property("text").toString(), u"yayayayc"_qs); - foo.setProperty("c", u"something"_qs); - QCOMPARE(o->property("text").toString(), u"something"_qs); - foo.insert("c", u"other"_qs); - QCOMPARE(o->property("text").toString(), u"other"_qs); + QCOMPARE(o->property("text").toString(), u"yayayayc"_s); + foo.setProperty("c", u"something"_s); + QCOMPARE(o->property("text").toString(), u"something"_s); + foo.insert("c", u"other"_s); + QCOMPARE(o->property("text").toString(), u"other"_s); QTest::ignoreMessage( QtWarningMsg, - qPrintable(url.toString() + u":4:5: Unable to assign [undefined] to QString"_qs)); + qPrintable(url.toString() + u":4:5: Unable to assign [undefined] to QString"_s)); foo.clear("c"); - QCOMPARE(o->property("text").toString(), u"other"_qs); - foo.insert("c", u"final"_qs); - QCOMPARE(o->property("text").toString(), u"final"_qs); + QCOMPARE(o->property("text").toString(), u"other"_s); + foo.insert("c", u"final"_s); + QCOMPARE(o->property("text").toString(), u"final"_s); } class NastyMap: public QQmlPropertyMap diff --git a/tests/auto/qmldom/domitem/tst_qmldomitem.h b/tests/auto/qmldom/domitem/tst_qmldomitem.h index f28e4ff6b5..8539617bb0 100644 --- a/tests/auto/qmldom/domitem/tst_qmldomitem.h +++ b/tests/auto/qmldom/domitem/tst_qmldomitem.h @@ -53,6 +53,7 @@ #include <memory> QT_BEGIN_NAMESPACE + namespace QQmlJS { namespace Dom { @@ -543,10 +544,12 @@ private slots: QVERIFY(obj1); { + using namespace Qt::StringLiterals; + QList<DomItem> rect = - obj1.lookup(u"Rectangle"_qs, LookupType::Type, LookupOption::Normal); + obj1.lookup(u"Rectangle"_s, LookupType::Type, LookupOption::Normal); QList<DomItem> rect2 = - obj1.lookup(u"Rectangle"_qs, LookupType::Symbol, LookupOption::Normal); + obj1.lookup(u"Rectangle"_s, LookupType::Symbol, LookupOption::Normal); QVERIFY(rect.length() == 1); QVERIFY(rect2.length() == 1); QCOMPARE(rect.first().internalKind(), DomType::Export); @@ -555,7 +558,7 @@ private slots: QCOMPARE(rect3.internalKind(), DomType::QmlObject); QList<DomItem> rects; obj1.resolve( - Path::Current(PathCurrent::Lookup).field(Fields::type).key(u"Rectangle"_qs), + Path::Current(PathCurrent::Lookup).field(Fields::type).key(u"Rectangle"_s), [&rects](Path, DomItem &el) { rects.append(el); return true; @@ -580,6 +583,8 @@ private slots: #ifdef Q_OS_ANDROID QSKIP("Test uncompatible with Android (QTBUG-100171)"); #endif + using namespace Qt::StringLiterals; + QString testFile1 = baseDir + QLatin1String("/TestImports.qml"); DomItem env = DomEnvironment::create( QStringList(), @@ -601,22 +606,22 @@ private slots: importedModules.append(importPtr->uri); } } - QCOMPARE(importedModules.at(0).moduleUri(), u"QtQuick"_qs); - QCOMPARE(importedModules.at(0).directoryString(), u""_qs); - QCOMPARE(importedModules.at(1).directoryString(), u"../.."_qs); - QCOMPARE(importedModules.at(1).localPath(), u"../.."_qs); + QCOMPARE(importedModules.at(0).moduleUri(), u"QtQuick"_s); + QCOMPARE(importedModules.at(0).directoryString(), u""_s); + QCOMPARE(importedModules.at(1).directoryString(), u"../.."_s); + QCOMPARE(importedModules.at(1).localPath(), u"../.."_s); QCOMPARE(importedModules.at(1).absoluteLocalPath(), QString()); - QCOMPARE(importedModules.at(1).absoluteLocalPath(u"/bla/bla"_qs), u"/bla/bla/../.."); - QCOMPARE(importedModules.at(2).directoryString(), u"../dommerging"_qs); - QCOMPARE(importedModules.at(2).localPath(), u"../dommerging"_qs); + QCOMPARE(importedModules.at(1).absoluteLocalPath(u"/bla/bla"_s), u"/bla/bla/../.."); + QCOMPARE(importedModules.at(2).directoryString(), u"../dommerging"_s); + QCOMPARE(importedModules.at(2).localPath(), u"../dommerging"_s); QCOMPARE(importedModules.at(2).absoluteLocalPath(), QString()); - QCOMPARE(importedModules.at(2).absoluteLocalPath(u"/bla/bla"_qs), + QCOMPARE(importedModules.at(2).absoluteLocalPath(u"/bla/bla"_s), u"/bla/bla/../dommerging"); - QCOMPARE(importedModules.at(3).directoryString(), u"C:/some/path"_qs); - QCOMPARE(importedModules.at(3).localPath(), u"C:/some/path"_qs); - QCOMPARE(importedModules.at(4).directoryString(), u"http://bla.com/"_qs); - QCOMPARE(importedModules.at(4).directoryUrl().toString(), u"http://bla.com/"_qs); - QCOMPARE(importedModules.at(5).absoluteLocalPath(), u"/absolute/path"_qs); + QCOMPARE(importedModules.at(3).directoryString(), u"C:/some/path"_s); + QCOMPARE(importedModules.at(3).localPath(), u"C:/some/path"_s); + QCOMPARE(importedModules.at(4).directoryString(), u"http://bla.com/"_s); + QCOMPARE(importedModules.at(4).directoryUrl().toString(), u"http://bla.com/"_s); + QCOMPARE(importedModules.at(5).absoluteLocalPath(), u"/absolute/path"_s); QVERIFY(QmlUri::fromDirectoryString("QtQuick") != importedModules.at(0)); QCOMPARE(QmlUri::fromUriString("QtQuick"), importedModules.at(0)); } @@ -674,6 +679,8 @@ private slots: static void checkAliases(DomItem &qmlObj) { + using namespace Qt::StringLiterals; + if (const QmlObject *qmlObjPtr = qmlObj.as<QmlObject>()) { auto pDefs = qmlObjPtr->propertyDefs(); auto i = pDefs.constBegin(); @@ -688,34 +695,34 @@ private slots: switch (propName.last(1).at(0).unicode()) { case u'i': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedProperty); - QCOMPARE(rAlias.typeName, u"int"_qs); + QCOMPARE(rAlias.typeName, u"int"_s); QVERIFY(rAlias.accessedPath.isEmpty()); QCOMPARE(rAlias.localPropertyDef.internalKind(), DomType::PropertyDefinition); break; case u'r': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedProperty); - QCOMPARE(rAlias.typeName, u"real"_qs); + QCOMPARE(rAlias.typeName, u"real"_s); QVERIFY(rAlias.accessedPath.isEmpty()); QCOMPARE(rAlias.localPropertyDef.internalKind(), DomType::PropertyDefinition); break; case u'I': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"Item"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"Item"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(!rAlias.localPropertyDef); break; case u'q': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"QtObject"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"QtObject"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(!rAlias.localPropertyDef); break; case u'Q': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"QtObject"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"QtObject"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(rAlias.localPropertyDef); break; default: @@ -751,8 +758,10 @@ private slots: } void testAliasResolve() { + using namespace Qt::StringLiterals; + QFETCH(QString, inFile); - QString testFile1 = baseDir + u"/"_qs + inFile; + QString testFile1 = baseDir + u"/"_s + inFile; DomItem env = DomEnvironment::create( QStringList(), QQmlJS::Dom::DomEnvironment::Option::SingleThreaded diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 8f2ba0021c..499e418395 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -50,6 +50,8 @@ #include <QQmlComponent> +using namespace Qt::StringLiterals; + #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -126,7 +128,7 @@ void tst_QQuickAccessible::cleanup() for (int i = 0; i < list.count(); ++i) { auto object = list.at(i)->object(); QString objectInfo = object ? QDebug::toString(object) - : u"[deleted object]"_qs; + : u"[deleted object]"_s; qWarning().noquote() << " " << (i + 1) << objectInfo << "Event: '" << qAccessibleEventString(list.at(i)->type()) << "' Child: " << list.at(i)->child(); diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index 020097b9ef..3ac4aecd5a 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -39,6 +39,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QFont> +using namespace Qt::StringLiterals; + class tst_qquickapplication : public QQmlDataTest { Q_OBJECT @@ -75,7 +77,7 @@ void tst_qquickapplication::cleanup() void tst_qquickapplication::active() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData(u"import QtQuick 2.0; " "Item { " @@ -85,7 +87,7 @@ void tst_qquickapplication::active() " target: %1; " " function onActiveChanged(active) { active2 = %1.active; }" " } " - "}"_qs.arg(app) + "}"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); @@ -131,7 +133,7 @@ void tst_qquickapplication::active() void tst_qquickapplication::state() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData(u"import QtQuick 2.0; " "Item { " @@ -142,7 +144,7 @@ void tst_qquickapplication::state() " function onStateChanged(state) { state2 = %1.state; }" " } " " Component.onCompleted: state2 = %1.state; " - "}"_qs.arg(app) + "}"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); @@ -206,10 +208,10 @@ void tst_qquickapplication::state() void tst_qquickapplication::layoutDirection() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData( - u"import QtQuick 2.0; Item { property bool layoutDirection: %1.layoutDirection }"_qs + u"import QtQuick 2.0; Item { property bool layoutDirection: %1.layoutDirection }"_s .arg(app) .toUtf8(), QUrl::fromLocalFile("")); @@ -233,10 +235,10 @@ void tst_qquickapplication::layoutDirection() void tst_qquickapplication::font() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData( - u"import QtQuick 2.0; Item { property font defaultFont: %1.font }"_qs.arg(app) + u"import QtQuick 2.0; Item { property font defaultFont: %1.font }"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp index b7a7010a57..9c3598b186 100644 --- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp @@ -41,6 +41,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/viewtestutils_p.h> +using namespace Qt::StringLiterals; + template <typename T> static T evaluate(QObject *scope, const QString &expression) { QQmlExpression expr(qmlContext(scope), scope, expression); @@ -1338,7 +1340,7 @@ void tst_QQuickDropArea::signalOrder() const QList<QVariant> eventOrder = item->property("eventOrder").toList(); QCOMPARE(eventOrder, - QList<QVariant>({ u"entered1"_qs, u"exited1"_qs, u"entered2"_qs, u"exited2"_qs })); + QList<QVariant>({ u"entered1"_s, u"exited1"_s, u"entered2"_s, u"exited2"_s })); } QTEST_MAIN(tst_QQuickDropArea) diff --git a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp index b5b6212be5..6f2a299c80 100644 --- a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp @@ -50,6 +50,7 @@ //using namespace QQuickVisualTestUtils; using namespace QQuickControlsTestUtils; +using namespace Qt::StringLiterals; class tst_QQuickDrawer : public QQmlDataTest { @@ -547,7 +548,7 @@ void tst_QQuickDrawer::header() void tst_QQuickDrawer::dragHandlerInteraction() { - QQuickControlsApplicationHelper helper(this, u"dragHandlerInteraction.qml"_qs); + QQuickControlsApplicationHelper helper(this, u"dragHandlerInteraction.qml"_s); QVERIFY2(helper.ready, helper.failureMessage()); auto window = helper.appWindow;; diff --git a/tests/auto/quickcontrols2/sanity/tst_sanity.cpp b/tests/auto/quickcontrols2/sanity/tst_sanity.cpp index 6c85bf42ed..fa1d0ecd83 100644 --- a/tests/auto/quickcontrols2/sanity/tst_sanity.cpp +++ b/tests/auto/quickcontrols2/sanity/tst_sanity.cpp @@ -44,6 +44,7 @@ using namespace QQuickVisualTestUtils; using namespace QQuickControlsTestUtils; +using namespace Qt::StringLiterals; class tst_Sanity : public QObject { @@ -76,11 +77,11 @@ tst_Sanity::tst_Sanity() // Mainly because a lot of false positives are generated because we are linting files from // different modules directly without their generated qmldirs. for (const QString &key : m_options.keys()) - m_options[key].setLevel(u"disable"_qs); + m_options[key].setLevel(u"disable"_s); - m_options[u"deferred-property-id"_qs].setLevel(u"warning"_qs); - m_options[u"controls-sanity"_qs].setLevel(u"warning"_qs); - m_options[u"multiple-attached-objects"_qs].setLevel(u"warning"_qs); + m_options[u"deferred-property-id"_s].setLevel(u"warning"_s); + m_options[u"controls-sanity"_s].setLevel(u"warning"_s); + m_options[u"multiple-attached-objects"_s].setLevel(u"warning"_s); } void tst_Sanity::initTestCase() diff --git a/tests/benchmarks/qml/javascript/tst_javascript.cpp b/tests/benchmarks/qml/javascript/tst_javascript.cpp index 7eda96b77f..6a3eb3d29d 100644 --- a/tests/benchmarks/qml/javascript/tst_javascript.cpp +++ b/tests/benchmarks/qml/javascript/tst_javascript.cpp @@ -34,6 +34,8 @@ #include "testtypes.h" +using namespace Qt::StringLiterals; + class tst_javascript : public QObject { Q_OBJECT @@ -52,7 +54,7 @@ private: void tst_javascript::run_data() { QTest::addColumn<QString>("file"); - QDirIterator listing(SRCDIR "/data", QStringList{u"*.qml"_qs}, + QDirIterator listing(SRCDIR "/data", QStringList{u"*.qml"_s}, QDir::Files | QDir::NoDotAndDotDot); while (listing.hasNext()) { auto info = listing.nextFileInfo(); |