diff options
author | Robert Griebl <robert.griebl@qt.io> | 2023-12-20 23:29:01 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2024-01-08 22:12:23 +0100 |
commit | d82261fd1cce14a63902033e9b1305f0312af856 (patch) | |
tree | 26600b8bd23a9d6d69e41ccd959fd8fe3df18cbb /tests | |
parent | 94abcf0a5b20aea8faa51068d7d243d3b83840a6 (diff) |
Modernize string literals
Replace all our custom qSL/qL1S/qL1C macros with standard C++ and
QString unicode string literals.
Change-Id: I9e0b69fb46525421f408f260518a69b8f8125d99
Pick-to: 6.7
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/application/tst_application.cpp | 8 | ||||
-rw-r--r-- | tests/auto/applicationinfo/tst_applicationinfo.cpp | 137 | ||||
-rw-r--r-- | tests/auto/applicationinstaller/tst_applicationinstaller.cpp | 118 | ||||
-rw-r--r-- | tests/auto/configuration/tst_configuration.cpp | 298 | ||||
-rw-r--r-- | tests/auto/controller-tool/tst_controller-tool.cpp | 132 | ||||
-rw-r--r-- | tests/auto/error-checking.h | 2 | ||||
-rw-r--r-- | tests/auto/installationreport/tst_installationreport.cpp | 10 | ||||
-rw-r--r-- | tests/auto/main/tst_main.cpp | 70 | ||||
-rw-r--r-- | tests/auto/packagecreator/tst_packagecreator.cpp | 28 | ||||
-rw-r--r-- | tests/auto/packageextractor/tst_packageextractor.cpp | 40 | ||||
-rw-r--r-- | tests/auto/packager-tool/tst_packager-tool.cpp | 62 | ||||
-rw-r--r-- | tests/auto/runtime/tst_runtime.cpp | 8 | ||||
-rw-r--r-- | tests/auto/signature/tst_signature.cpp | 28 | ||||
-rw-r--r-- | tests/auto/systemreader/tst_systemreader.cpp | 8 | ||||
-rw-r--r-- | tests/auto/yaml/tst_yaml.cpp | 134 |
15 files changed, 556 insertions, 527 deletions
diff --git a/tests/auto/application/tst_application.cpp b/tests/auto/application/tst_application.cpp index 336f743a..299758bb 100644 --- a/tests/auto/application/tst_application.cpp +++ b/tests/auto/application/tst_application.cpp @@ -13,6 +13,8 @@ #include "package.h" #include "abstractruntime.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class TestRuntime : public AbstractRuntime @@ -54,7 +56,7 @@ public: : AbstractRuntimeManager(id, parent) { } - static QString defaultIdentifier() { return qSL("foo"); } + static QString defaultIdentifier() { return u"foo"_s; } bool inProcess() const override { @@ -82,12 +84,12 @@ private slots: // the application no longer holds a reference to it void tst_Application::runtimeDestroyed() { - auto pi = PackageInfo::fromManifest(qL1S(":/info.yaml")); + auto pi = PackageInfo::fromManifest(u":/info.yaml"_s); auto pkg = new Package(pi); auto ai = new ApplicationInfo(pi); auto app = new Application(ai, pkg); - auto runtimeManager = new TestRuntimeManager(qSL("foo"), qApp); + auto runtimeManager = new TestRuntimeManager(u"foo"_s, qApp); auto runtime = runtimeManager->create(nullptr, app); app->setCurrentRuntime(runtime); diff --git a/tests/auto/applicationinfo/tst_applicationinfo.cpp b/tests/auto/applicationinfo/tst_applicationinfo.cpp index 25ab28b1..8c6e7192 100644 --- a/tests/auto/applicationinfo/tst_applicationinfo.cpp +++ b/tests/auto/applicationinfo/tst_applicationinfo.cpp @@ -16,6 +16,9 @@ #include "yamlpackagescanner.h" #include "exception.h" +using namespace Qt::StringLiterals; + + QT_USE_NAMESPACE_AM class tst_ApplicationInfo : public QObject @@ -37,11 +40,11 @@ class TestPackageLoader { public: TestPackageLoader(const char *name) - : m_dataDir(qL1S(":/data")) + : m_dataDir(u":/data"_s) { try { static YamlPackageScanner scanner; - QString path = QString::fromLatin1(name) % qL1S("/info.yaml"); + QString path = QString::fromLatin1(name) % u"/info.yaml"_s; m_pi = scanner.scan(m_dataDir.absoluteFilePath(path)); if (m_pi) { @@ -114,86 +117,86 @@ void tst_ApplicationInfo::full() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("full")); - QCOMPARE(pl.info()->icon(), qL1S("full.png")); - QCOMPARE(pl.info()->version(), qL1S("v1")); - QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } }; + QCOMPARE(pl.info()->id(), u"full"_s); + QCOMPARE(pl.info()->icon(), u"full.png"_s); + QCOMPARE(pl.info()->version(), u"v1"_s); + QMap<QString, QString> names { { u"en"_s, u"pkg.name.en"_s }, { u"de"_s, u"pkg.name.de"_s } }; QCOMPARE(pl.info()->names(), names); - QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } }; + QMap<QString, QString> descs { { u"en"_s, u"pkg.desc.en"_s }, { u"de"_s, u"pkg.desc.de"_s } }; QCOMPARE(pl.info()->descriptions(), descs); - QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") }; + QStringList cats { u"pkg.cat.1"_s, u"pkg.cat.2"_s }; QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 2); QCOMPARE(pl.info()->intents().size(), 2); const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("full.app.1")); - QCOMPARE(ai->icon(), qSL("app1.png")); - QMap<QString, QString> app1names { { qL1S("en"), qL1S("app1.name.en") }, { qL1S("de"), qL1S("app1.name.de") } }; + QCOMPARE(ai->id(), u"full.app.1"_s); + QCOMPARE(ai->icon(), u"app1.png"_s); + QMap<QString, QString> app1names { { u"en"_s, u"app1.name.en"_s }, { u"de"_s, u"app1.name.de"_s } }; QCOMPARE(ai->names(), app1names); - QMap<QString, QString> app1descs { { qL1S("en"), qL1S("app1.desc.en") }, { qL1S("de"), qL1S("app1.desc.de") } }; + QMap<QString, QString> app1descs { { u"en"_s, u"app1.desc.en"_s }, { u"de"_s, u"app1.desc.de"_s } }; QCOMPARE(ai->descriptions(), app1descs); - QStringList app1cats { qL1S("app1.cat.1"), qL1S("app1.cat.2") }; + QStringList app1cats { u"app1.cat.1"_s, u"app1.cat.2"_s }; QCOMPARE(ai->categories(), app1cats); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app1.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 5); QCOMPARE(ai->supportsApplicationInterface(), true); - QCOMPARE(ai->capabilities(), QStringList { qSL("app1.cap") }); - QVariantMap app1ogl { { qSL("desktopProfile"), qSL("core") }, { qSL("esMajorVersion"), 3 }, { qSL("esMinorVersion"), 2 }}; + QCOMPARE(ai->capabilities(), QStringList { u"app1.cap"_s }); + QVariantMap app1ogl { { u"desktopProfile"_s, u"core"_s }, { u"esMajorVersion"_s, 3 }, { u"esMinorVersion"_s, 2 }}; QCOMPARE(ai->openGLConfiguration(), app1ogl); - QVariantMap app1prop { { qSL("custom.app1.key"), 42 } }; + QVariantMap app1prop { { u"custom.app1.key"_s, 42 } }; QCOMPARE(ai->applicationProperties(), app1prop); - QVariantMap app1dlt { { qSL("id"), qSL("app1.dlt.id") }, { qSL("description"), qSL("app1.dlt.desc") } }; + QVariantMap app1dlt { { u"id"_s, u"app1.dlt.id"_s }, { u"description"_s, u"app1.dlt.desc"_s } }; QCOMPARE(ai->dltConfiguration(), app1dlt); ai = pl.info()->applications().constLast(); - QCOMPARE(ai->id(), qSL("full.app.2")); - QCOMPARE(ai->icon(), qSL("app2.png")); - QMap<QString, QString> app2names { { qL1S("en"), qL1S("app2.name.en") }, { qL1S("de"), qL1S("app2.name.de") } }; + QCOMPARE(ai->id(), u"full.app.2"_s); + QCOMPARE(ai->icon(), u"app2.png"_s); + QMap<QString, QString> app2names { { u"en"_s, u"app2.name.en"_s }, { u"de"_s, u"app2.name.de"_s } }; QCOMPARE(ai->names(), app2names); - QMap<QString, QString> app2descs { { qL1S("en"), qL1S("app2.desc.en") }, { qL1S("de"), qL1S("app2.desc.de") } }; + QMap<QString, QString> app2descs { { u"en"_s, u"app2.desc.en"_s }, { u"de"_s, u"app2.desc.de"_s } }; QCOMPARE(ai->descriptions(), app2descs); - QStringList app2cats { qL1S("app2.cat.1"), qL1S("app2.cat.2") }; + QStringList app2cats { u"app2.cat.1"_s, u"app2.cat.2"_s }; QCOMPARE(ai->categories(), app2cats); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe")); - QCOMPARE(ai->runtimeName(), qSL("native")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app2.exe"_s); + QCOMPARE(ai->runtimeName(), u"native"_s); QCOMPARE(ai->runtimeParameters().size(), 2); IntentInfo *ii = pl.info()->intents().constFirst(); - QCOMPARE(ii->id(), qSL("full.int.1")); - QCOMPARE(ii->icon(), qSL("int1.png")); - QMap<QString, QString> int1names { { qL1S("en"), qL1S("int1.name.en") }, { qL1S("de"), qL1S("int1.name.de") } }; + QCOMPARE(ii->id(), u"full.int.1"_s); + QCOMPARE(ii->icon(), u"int1.png"_s); + QMap<QString, QString> int1names { { u"en"_s, u"int1.name.en"_s }, { u"de"_s, u"int1.name.de"_s } }; QCOMPARE(ii->names(), int1names); - QMap<QString, QString> int1descs { { qL1S("en"), qL1S("int1.desc.en") }, { qL1S("de"), qL1S("int1.desc.de") } }; + QMap<QString, QString> int1descs { { u"en"_s, u"int1.desc.en"_s }, { u"de"_s, u"int1.desc.de"_s } }; QCOMPARE(ii->descriptions(), int1descs); - QStringList int1cats { qL1S("int1.cat.1"), qL1S("int1.cat.2") }; + QStringList int1cats { u"int1.cat.1"_s, u"int1.cat.2"_s }; QCOMPARE(ii->categories(), int1cats); QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constFirst()->id()); QCOMPARE(ii->visibility(), IntentInfo::Private); - QStringList req1caps { qSL("int1.cap.1"), qSL("int1.cap.2") }; + QStringList req1caps { u"int1.cap.1"_s, u"int1.cap.2"_s }; QCOMPARE(ii->requiredCapabilities(), req1caps); - QVariantMap param1match { { qSL("mimeType"), qSL("^image/.*\\.png$") } }; + QVariantMap param1match { { u"mimeType"_s, u"^image/.*\\.png$"_s } }; QCOMPARE(ii->parameterMatch(), param1match); ii = pl.info()->intents().constLast(); - QCOMPARE(ii->id(), qSL("full.int.2")); - QCOMPARE(ii->icon(), qSL("int2.png")); - QMap<QString, QString> int2names { { qL1S("en"), qL1S("int2.name.en") }, { qL1S("de"), qL1S("int2.name.de") } }; + QCOMPARE(ii->id(), u"full.int.2"_s); + QCOMPARE(ii->icon(), u"int2.png"_s); + QMap<QString, QString> int2names { { u"en"_s, u"int2.name.en"_s }, { u"de"_s, u"int2.name.de"_s } }; QCOMPARE(ii->names(), int2names); - QMap<QString, QString> int2descs { { qL1S("en"), qL1S("int2.desc.en") }, { qL1S("de"), qL1S("int2.desc.de") } }; + QMap<QString, QString> int2descs { { u"en"_s, u"int2.desc.en"_s }, { u"de"_s, u"int2.desc.de"_s } }; QCOMPARE(ii->descriptions(), int2descs); - QStringList int2cats { qL1S("int2.cat.1"), qL1S("int2.cat.2") }; + QStringList int2cats { u"int2.cat.1"_s, u"int2.cat.2"_s }; QCOMPARE(ii->categories(), int2cats); QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constLast()->id()); QCOMPARE(ii->visibility(), IntentInfo::Public); - QStringList req2caps { qSL("int2.cap.1"), qSL("int2.cap.2") }; + QStringList req2caps { u"int2.cap.1"_s, u"int2.cap.2"_s }; QCOMPARE(ii->requiredCapabilities(), req2caps); - QVariantMap param2match { { qSL("test"), qSL("foo") } }; + QVariantMap param2match { { u"test"_s, u"foo"_s } }; QCOMPARE(ii->parameterMatch(), param2match); // now the QML interface @@ -248,7 +251,7 @@ void tst_ApplicationInfo::minimal() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("minimal")); + QCOMPARE(pl.info()->id(), u"minimal"_s); QCOMPARE(pl.info()->icon(), QString { }); QCOMPARE(pl.info()->version(), QString { }); QMap<QString, QString> emptyMap; @@ -260,13 +263,13 @@ void tst_ApplicationInfo::minimal() const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("minimal.app")); + QCOMPARE(ai->id(), u"minimal.app"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("minimal.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"minimal.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 0); } @@ -276,43 +279,43 @@ void tst_ApplicationInfo::inherit() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("inherit")); - QCOMPARE(pl.info()->icon(), qL1S("pkg.png")); + QCOMPARE(pl.info()->id(), u"inherit"_s); + QCOMPARE(pl.info()->icon(), u"pkg.png"_s); QCOMPARE(pl.info()->version(), QString { }); - QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } }; + QMap<QString, QString> names { { u"en"_s, u"pkg.name.en"_s }, { u"de"_s, u"pkg.name.de"_s } }; QCOMPARE(pl.info()->names(), names); - QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } }; + QMap<QString, QString> descs { { u"en"_s, u"pkg.desc.en"_s }, { u"de"_s, u"pkg.desc.de"_s } }; QCOMPARE(pl.info()->descriptions(), descs); - QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") }; + QStringList cats { u"pkg.cat.1"_s, u"pkg.cat.2"_s }; QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 2); QCOMPARE(pl.info()->intents().size(), 2); const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("inherit.app.1")); + QCOMPARE(ai->id(), u"inherit.app.1"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app1.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 0); ai = pl.info()->applications().constLast(); - QCOMPARE(ai->id(), qSL("inherit.app.2")); + QCOMPARE(ai->id(), u"inherit.app.2"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe")); - QCOMPARE(ai->runtimeName(), qSL("native")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app2.exe"_s); + QCOMPARE(ai->runtimeName(), u"native"_s); QCOMPARE(ai->runtimeParameters().size(), 0); IntentInfo *ii = pl.info()->intents().constFirst(); - QCOMPARE(ii->id(), qSL("inherit.int.1")); + QCOMPARE(ii->id(), u"inherit.int.1"_s); QCOMPARE(ii->icon(), pl.info()->icon()); QCOMPARE(ii->names(), pl.info()->names()); QCOMPARE(ii->descriptions(), pl.info()->descriptions()); @@ -321,7 +324,7 @@ void tst_ApplicationInfo::inherit() ii = pl.info()->intents().constLast(); - QCOMPARE(ii->id(), qSL("inherit.int.2")); + QCOMPARE(ii->id(), u"inherit.int.2"_s); QCOMPARE(ii->icon(), pl.info()->icon()); QCOMPARE(ii->names(), pl.info()->names()); QCOMPARE(ii->descriptions(), pl.info()->descriptions()); @@ -364,12 +367,12 @@ void tst_ApplicationInfo::legacy() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("legacy")); - QCOMPARE(pl.info()->icon(), qL1S("icon.png")); - QCOMPARE(pl.info()->version(), qL1S("v1")); - QMap<QString, QString> names { { qL1S("en"), qL1S("legacy.en") }, { qL1S("de"), qL1S("legacy.de") } }; + QCOMPARE(pl.info()->id(), u"legacy"_s); + QCOMPARE(pl.info()->icon(), u"icon.png"_s); + QCOMPARE(pl.info()->version(), u"v1"_s); + QMap<QString, QString> names { { u"en"_s, u"legacy.en"_s }, { u"de"_s, u"legacy.de"_s } }; QCOMPARE(pl.info()->names(), names); - QStringList cats { qL1S("bar"), qL1S("foo") }; + QStringList cats { u"bar"_s, u"foo"_s }; QVERIFY(pl.info()->descriptions().isEmpty()); QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 1); @@ -382,14 +385,14 @@ void tst_ApplicationInfo::legacy() QCOMPARE(ai->names(), pl.info()->names()); QVERIFY(ai->descriptions().isEmpty()); QCOMPARE(ai->categories(), pl.info()->categories()); - QStringList mimes { qL1S("text/plain"), qL1S("x-scheme-handler/mailto") }; + QStringList mimes { u"text/plain"_s, u"x-scheme-handler/mailto"_s }; QCOMPARE(ai->supportedMimeTypes(), mimes); - QStringList caps { qL1S("cameraAccess"), qL1S("locationAccess") }; + QStringList caps { u"cameraAccess"_s, u"locationAccess"_s }; QCOMPARE(ai->capabilities(), caps); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("legacy.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"legacy.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 1); - QCOMPARE(ai->runtimeParameters().value(qSL("loadDummyData")).toBool(), true); + QCOMPARE(ai->runtimeParameters().value(u"loadDummyData"_s).toBool(), true); } void tst_ApplicationInfo::validApplicationId_data() diff --git a/tests/auto/applicationinstaller/tst_applicationinstaller.cpp b/tests/auto/applicationinstaller/tst_applicationinstaller.cpp index 0dd8df74..b1016ee2 100644 --- a/tests/auto/applicationinstaller/tst_applicationinstaller.cpp +++ b/tests/auto/applicationinstaller/tst_applicationinstaller.cpp @@ -22,6 +22,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static bool startedSudoServer = false; @@ -121,8 +123,8 @@ private: { QString base; switch (pathLocation) { - case Internal0: base = qSL("internal"); break; - case Documents0: base = qSL("documents"); break; + case Internal0: base = u"internal"_s; break; + case Documents0: base = u"documents"_s; break; default: break; } @@ -135,10 +137,10 @@ private: else if (base.isEmpty()) base = workDir.absoluteFilePath(sub); else - base = workDir.absoluteFilePath(base + qL1C('/') + sub); + base = workDir.absoluteFilePath(base + u'/' + sub); if (QDir(base).exists()) - return base + qL1C('/'); + return base + u'/'; else return base; } @@ -199,12 +201,12 @@ tst_PackageManager::~tst_PackageManager() void tst_PackageManager::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); bool verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); if (!verbose) - QLoggingCategory::setFilterRules(qSL("am.installer.debug=false")); + QLoggingCategory::setFilterRules(u"am.installer.debug=false"_s); qInfo() << "Verbose mode is" << (verbose ? "on" : "off") << "(change by (un)setting $AM_VERBOSE_TEST)"; spyTimeout *= timeoutFactor(); @@ -218,7 +220,7 @@ void tst_PackageManager::initTestCase() QVERIFY(m_workDir.isValid()); // make sure we have a valid hardware-id - m_hardwareId = qSL("foobar"); + m_hardwareId = u"foobar"_s; for (int i = 0; i < PathLocationCount; ++i) QVERIFY(QDir().mkdir(pathTo(PathLocation(i)))); @@ -245,17 +247,17 @@ void tst_PackageManager::initTestCase() const QVariantMap iloc = m_pm->installationLocation(); QCOMPARE(iloc.size(), 3); - QCOMPARE(iloc.value(qSL("path")).toString(), pathTo(Internal0)); - QVERIFY(iloc.value(qSL("deviceSize")).toLongLong() > 0); - QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() > 0); - QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() < iloc.value(qSL("deviceSize")).toLongLong()); + QCOMPARE(iloc.value(u"path"_s).toString(), pathTo(Internal0)); + QVERIFY(iloc.value(u"deviceSize"_s).toLongLong() > 0); + QVERIFY(iloc.value(u"deviceFree"_s).toLongLong() > 0); + QVERIFY(iloc.value(u"deviceFree"_s).toLongLong() < iloc.value(u"deviceSize"_s).toLongLong()); const QVariantMap dloc = m_pm->documentLocation(); QCOMPARE(dloc.size(), 3); - QCOMPARE(dloc.value(qSL("path")).toString(), pathTo(Documents0)); - QVERIFY(dloc.value(qSL("deviceSize")).toLongLong() > 0); - QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() > 0); - QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() < dloc.value(qSL("deviceSize")).toLongLong()); + QCOMPARE(dloc.value(u"path"_s).toString(), pathTo(Documents0)); + QVERIFY(dloc.value(u"deviceSize"_s).toLongLong() > 0); + QVERIFY(dloc.value(u"deviceFree"_s).toLongLong() > 0); + QVERIFY(dloc.value(u"deviceFree"_s).toLongLong() < dloc.value(u"deviceSize"_s).toLongLong()); m_startedSpy = new QSignalSpy(m_pm, &PackageManager::taskStarted); m_requestingInstallationAcknowledgeSpy = new QSignalSpy(m_pm, &PackageManager::taskRequestingInstallationAcknowledge); @@ -266,9 +268,9 @@ void tst_PackageManager::initTestCase() // crypto stuff - we need to load the root CA and developer CA certificates - QFile devcaFile(qL1S(AM_TESTDATA_DIR "certificates/devca.crt")); - QFile storecaFile(qL1S(AM_TESTDATA_DIR "certificates/store.crt")); - QFile caFile(qL1S(AM_TESTDATA_DIR "certificates/ca.crt")); + QFile devcaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/devca.crt")); + QFile storecaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/store.crt")); + QFile caFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/ca.crt")); QVERIFY2(devcaFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); QVERIFY2(storecaFile.open(QIODevice::ReadOnly), qPrintable(storecaFile.errorString())); QVERIFY2(caFile.open(QIODevice::ReadOnly), qPrintable(caFile.errorString())); @@ -285,7 +287,7 @@ void tst_PackageManager::initTestCase() // make sure we have a valid runtime available. The important part is // that we have a runtime called "native" - the functionality does not matter. - RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("native"))); + RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(u"native"_s)); } void tst_PackageManager::cleanupTestCase() @@ -330,16 +332,16 @@ void tst_PackageManager::packageInstallation_data() QVariantMap nomd { }; // no meta-data QVariantMap extramd = QVariantMap { - { qSL("extra"), QVariantMap { - { qSL("array"), QVariantList { 1, 2 } }, - { qSL("foo"), qSL("bar") }, - { qSL("foo2"),qSL("bar2") }, - { qSL("key"), qSL("value") } } }, - { qSL("extraSigned"), QVariantMap { - { qSL("sfoo"), qSL("sbar") }, - { qSL("sfoo2"), qSL("sbar2") }, - { qSL("signed-key"), qSL("signed-value") }, - { qSL("signed-object"), QVariantMap { { qSL("k1"), qSL("v1") }, { qSL("k2"), qSL("v2") } } } + { u"extra"_s, QVariantMap { + { u"array"_s, QVariantList { 1, 2 } }, + { u"foo"_s, u"bar"_s }, + { u"foo2"_s,u"bar2"_s }, + { u"key"_s, u"value"_s } } }, + { u"extraSigned"_s, QVariantMap { + { u"sfoo"_s, u"sbar"_s }, + { u"sfoo2"_s, u"sbar2"_s }, + { u"signed-key"_s, u"signed-value"_s }, + { u"signed-object"_s, QVariantMap { { u"k1"_s, u"v1"_s }, { u"k2"_s, u"v2"_s } } } } } }; @@ -410,8 +412,8 @@ void tst_PackageManager::packageInstallation() QFETCH(QVariantMap, extraMetaData); QFETCH(QString, errorString); - QString installationDir = m_pm->installationLocation().value(qSL("path")).toString(); - QString documentDir = m_pm->documentLocation().value(qSL("path")).toString(); + QString installationDir = m_pm->installationLocation().value(u"path"_s).toString(); + QString documentDir = m_pm->documentLocation().value(u"path"_s).toString(); AllowInstallations allow(storeSigned ? AllowInstallations::RequireStoreSigned : (devSigned ? AllowInstallations::RequireDevSigned @@ -426,7 +428,7 @@ void tst_PackageManager::packageInstallation() // install (or update) the package - QUrl url = QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/") + QUrl url = QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/") + (pass == 1 ? packageName : updatePackageName)); QString taskId = m_pm->startPackageInstallation(url); QVERIFY(!taskId.isEmpty()); @@ -455,24 +457,24 @@ void tst_PackageManager::packageInstallation() //QDirIterator it(m_workDir.path(), QDirIterator::Subdirectories); //while (it.hasNext()) { qDebug() << it.next(); } - QVERIFY(QFile::exists(installationDir + qSL("/com.pelagicore.test/.installation-report.yaml"))); - QVERIFY(QDir(documentDir + qSL("/com.pelagicore.test")).exists()); + QVERIFY(QFile::exists(installationDir + u"/com.pelagicore.test/.installation-report.yaml"_s)); + QVERIFY(QDir(documentDir + u"/com.pelagicore.test"_s).exists()); - QString fileCheckPath = installationDir + qSL("/com.pelagicore.test"); + QString fileCheckPath = installationDir + u"/com.pelagicore.test"_s; // now check the installed files QStringList files = QDir(fileCheckPath).entryList(QDir::AllEntries | QDir::NoDotAndDotDot); #if defined(Q_OS_WIN) // files starting with . are not considered hidden on Windows - files = files.filter(QRegularExpression(qSL("^[^.].*"))); + files = files.filter(QRegularExpression(u"^[^.].*"_s)); #endif files.sort(); - QVERIFY2(files == QStringList({ qSL("icon.png"), qSL("info.yaml"), qSL("test"), QString::fromUtf8("t\xc3\xa4st") }), - qPrintable(files.join(qSL(", ")))); + QVERIFY2(files == QStringList({ u"icon.png"_s, u"info.yaml"_s, u"test"_s, QString::fromUtf8("t\xc3\xa4st") }), + qPrintable(files.join(u", "_s))); - QFile f(fileCheckPath + qSL("/test")); + QFile f(fileCheckPath + u"/test"_s); QVERIFY(f.open(QFile::ReadOnly)); QCOMPARE(f.readAll(), QByteArray(pass == 1 ? "test\n" : "test update\n")); f.close(); @@ -481,28 +483,28 @@ void tst_PackageManager::packageInstallation() QCOMPARE(m_requestingInstallationAcknowledgeSpy->count(), 1); QVariantMap extra = m_requestingInstallationAcknowledgeSpy->first()[2].toMap(); QVariantMap extraSigned = m_requestingInstallationAcknowledgeSpy->first()[3].toMap(); - if (extraMetaData.value(qSL("extra")).toMap() != extra) { + if (extraMetaData.value(u"extra"_s).toMap() != extra) { qDebug() << "Actual: " << extra; - qDebug() << "Expected: " << extraMetaData.value(qSL("extra")).toMap(); + qDebug() << "Expected: " << extraMetaData.value(u"extra"_s).toMap(); QVERIFY(extraMetaData == extra); } - if (extraMetaData.value(qSL("extraSigned")).toMap() != extraSigned) { + if (extraMetaData.value(u"extraSigned"_s).toMap() != extraSigned) { qDebug() << "Actual: " << extraSigned; - qDebug() << "Expected: " << extraMetaData.value(qSL("extraSigned")).toMap(); + qDebug() << "Expected: " << extraMetaData.value(u"extraSigned"_s).toMap(); QVERIFY(extraMetaData == extraSigned); } // check if the meta-data was saved to the installation report correctly - QVERIFY2(m_pm->installedPackageExtraMetaData(qSL("com.pelagicore.test")) == extra, + QVERIFY2(m_pm->installedPackageExtraMetaData(u"com.pelagicore.test"_s) == extra, "Extra meta-data was not correctly saved to installation report"); - QVERIFY2(m_pm->installedPackageExtraSignedMetaData(qSL("com.pelagicore.test")) == extraSigned, + QVERIFY2(m_pm->installedPackageExtraSignedMetaData(u"com.pelagicore.test"_s) == extraSigned, "Extra signed meta-data was not correctly saved to installation report"); } if (pass == lastPass && expectedSuccess) { // remove package again clearSignalSpies(); - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(!taskId.isEmpty()); // check signals @@ -514,8 +516,8 @@ void tst_PackageManager::packageInstallation() // check that all files are gone for (PathLocation pl: { Internal0, Documents0 }) { - QStringList entries = QDir(pathTo(pl)).entryList({ qSL("com.pelagicore.test*") }); - QVERIFY2(entries.isEmpty(), qPrintable(pathTo(pl) + qSL(": ") + entries.join(qSL(", ")))); + QStringList entries = QDir(pathTo(pl)).entryList({ u"com.pelagicore.test*"_s }); + QVERIFY2(entries.isEmpty(), qPrintable(pathTo(pl) + u": "_s + entries.join(u", "_s))); } } @@ -558,7 +560,7 @@ void tst_PackageManager::simulateErrorConditions() if (testUpdate) { // the check will run when updating a package, so we need to install it first - taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!taskId.isEmpty()); m_pm->acknowledgePackageInstallation(taskId); QVERIFY(m_finishedSpy->wait(spyTimeout)); @@ -570,7 +572,7 @@ void tst_PackageManager::simulateErrorConditions() for (const auto &f : beforeStart) QVERIFY(f()); - taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); const auto afterStart = functions.values("after-start"); for (const auto &f : afterStart) @@ -588,7 +590,7 @@ void tst_PackageManager::simulateErrorConditions() QVERIFY(f()); if (testUpdate) { - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(m_finishedSpy->wait(spyTimeout)); QCOMPARE(m_finishedSpy->first()[0].toString(), taskId); @@ -612,7 +614,7 @@ void tst_PackageManager::cancelPackageInstallation() { QFETCH(bool, expectedResult); - QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!taskId.isEmpty()); if (isDataTag("before-started-signal")) { @@ -641,7 +643,7 @@ void tst_PackageManager::cancelPackageInstallation() } else { clearSignalSpies(); - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(!taskId.isEmpty()); QVERIFY(m_finishedSpy->wait(spyTimeout)); QCOMPARE(m_finishedSpy->first()[0].toString(), taskId); @@ -651,12 +653,12 @@ void tst_PackageManager::cancelPackageInstallation() void tst_PackageManager::parallelPackageInstallation() { - QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task1Id.isEmpty()); QVERIFY(m_blockingUntilInstallationAcknowledgeSpy->wait(spyTimeout)); QCOMPARE(m_blockingUntilInstallationAcknowledgeSpy->first()[0].toString(), task1Id); - QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg"))); + QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg"))); QVERIFY(!task2Id.isEmpty()); m_pm->acknowledgePackageInstallation(task2Id); QVERIFY(m_finishedSpy->wait(spyTimeout)); @@ -672,17 +674,17 @@ void tst_PackageManager::parallelPackageInstallation() void tst_PackageManager::doublePackageInstallation() { - QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task1Id.isEmpty()); QVERIFY(m_blockingUntilInstallationAcknowledgeSpy->wait(spyTimeout)); QCOMPARE(m_blockingUntilInstallationAcknowledgeSpy->first()[0].toString(), task1Id); - QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task2Id.isEmpty()); m_pm->acknowledgePackageInstallation(task2Id); QVERIFY(m_failedSpy->wait(spyTimeout)); QCOMPARE(m_failedSpy->first()[0].toString(), task2Id); - QCOMPARE(m_failedSpy->first()[2].toString(), qL1S("Cannot install the same package com.pelagicore.test multiple times in parallel")); + QCOMPARE(m_failedSpy->first()[2].toString(), u"Cannot install the same package com.pelagicore.test multiple times in parallel"); clearSignalSpies(); m_pm->cancelTask(task1Id); diff --git a/tests/auto/configuration/tst_configuration.cpp b/tests/auto/configuration/tst_configuration.cpp index 456cf086..f3e6cc15 100644 --- a/tests/auto/configuration/tst_configuration.cpp +++ b/tests/auto/configuration/tst_configuration.cpp @@ -8,6 +8,8 @@ #include <QtAppManCommon/exception.h> #include <QtAppManCommon/global.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Configuration : public QObject @@ -34,7 +36,7 @@ tst_Configuration::tst_Configuration() void tst_Configuration::defaultConfig() { Configuration c; - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -43,16 +45,16 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("")); + QCOMPARE(c.mainQmlFile(), u""_s); QCOMPARE(c.builtinAppsManifestDirs(), {}); - QCOMPARE(c.documentDir(), qSL("")); + QCOMPARE(c.documentDir(), u""_s); - QCOMPARE(c.installationDir(), qSL("")); + QCOMPARE(c.installationDir(), u""_s); QCOMPARE(c.disableInstaller(), false); QCOMPARE(c.disableIntents(), false); QCOMPARE(c.intentTimeoutForDisambiguation(), 10000); @@ -61,7 +63,7 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 20000); QCOMPARE(c.fullscreen(), false); - QCOMPARE(c.windowIcon(), qSL("")); + QCOMPARE(c.windowIcon(), u""_s); QCOMPARE(c.importPaths(), {}); QCOMPARE(c.pluginPaths(), {}); QCOMPARE(c.loadDummyData(), false); @@ -73,13 +75,13 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.forceSingleProcess(), false); QCOMPARE(c.forceMultiProcess(), false); QCOMPARE(c.loggingRules(), {}); - QCOMPARE(c.messagePattern(), qSL("")); + QCOMPARE(c.messagePattern(), u""_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("")); - QCOMPARE(c.iconThemeName(), qSL("")); + QCOMPARE(c.style(), u""_s); + QCOMPARE(c.iconThemeName(), u""_s); QCOMPARE(c.iconThemeSearchPaths(), {}); - QCOMPARE(c.dltId(), qSL("")); - QCOMPARE(c.dltDescription(), qSL("")); + QCOMPARE(c.dltId(), u""_s); + QCOMPARE(c.dltDescription(), u""_s); QCOMPARE(c.resources(), {}); QCOMPARE(c.openGLConfiguration(), QVariantMap {}); @@ -91,7 +93,7 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList {}); QCOMPARE(c.runtimeConfigurations(), QVariantMap {}); - QCOMPARE(c.dbusRegistration("iface1"), qSL("auto")); + QCOMPARE(c.dbusRegistration("iface1"), u"auto"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap {}); @@ -100,7 +102,7 @@ void tst_Configuration::defaultConfig() QString defaultWaylandSocketName = #if defined(Q_OS_LINUX) - qSL("qtam-wayland-"); + u"qtam-wayland-"_s; #else QString(); #endif @@ -118,8 +120,8 @@ void tst_Configuration::defaultConfig() void tst_Configuration::simpleConfig() { - Configuration c({ qSL(":/data/config1.yaml") }, qSL(":/build-config.yaml")); - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + Configuration c({ u":/data/config1.yaml"_s }, u":/build-config.yaml"_s); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -128,16 +130,16 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main.qml")); + QCOMPARE(c.mainQmlFile(), u"main.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), { qSL("builtin-dir") }); - QCOMPARE(c.documentDir(), qSL("doc-dir")); + QCOMPARE(c.builtinAppsManifestDirs(), { u"builtin-dir"_s }); + QCOMPARE(c.documentDir(), u"doc-dir"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir")); + QCOMPARE(c.installationDir(), u"installation-dir"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 1); @@ -146,9 +148,9 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 4); QCOMPARE(c.fullscreen(), true); - QCOMPARE(c.windowIcon(), qSL("icon.png")); - QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(qSL("ip1")), pwd.absoluteFilePath(qSL("ip2")) })); - QCOMPARE(c.pluginPaths(), QStringList({ qSL("pp1"), qSL("pp2") })); + QCOMPARE(c.windowIcon(), u"icon.png"_s); + QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(u"ip1"_s), pwd.absoluteFilePath(u"ip2"_s) })); + QCOMPARE(c.pluginPaths(), QStringList({ u"pp1"_s, u"pp2"_s })); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); QCOMPARE(c.developmentMode(), true); @@ -157,101 +159,101 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.allowUnknownUiClients(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("lr1"), qSL("lr2") })); - QCOMPARE(c.messagePattern(), qSL("msgPattern")); + QCOMPARE(c.loggingRules(), QStringList({ u"lr1"_s, u"lr2"_s })); + QCOMPARE(c.messagePattern(), u"msgPattern"_s); QCOMPARE(c.useAMConsoleLogger(), QVariant(true)); - QCOMPARE(c.style(), qSL("mystyle")); - QCOMPARE(c.iconThemeName(), qSL("mytheme")); - QCOMPARE(c.iconThemeSearchPaths(), QStringList({ qSL("itsp1"), qSL("itsp2") })); - QCOMPARE(c.dltId(), qSL("dltid")); - QCOMPARE(c.dltDescription(), qSL("dltdesc")); - QCOMPARE(c.dltLongMessageBehavior(), qSL("split")); - QCOMPARE(c.resources(), QStringList({ qSL("r1"), qSL("r2") })); + QCOMPARE(c.style(), u"mystyle"_s); + QCOMPARE(c.iconThemeName(), u"mytheme"_s); + QCOMPARE(c.iconThemeSearchPaths(), QStringList({ u"itsp1"_s, u"itsp2"_s })); + QCOMPARE(c.dltId(), u"dltid"_s); + QCOMPARE(c.dltDescription(), u"dltdesc"_s); + QCOMPARE(c.dltLongMessageBehavior(), u"split"_s); + QCOMPARE(c.resources(), QStringList({ u"r1"_s, u"r2"_s })); QCOMPARE(c.openGLConfiguration(), QVariantMap ({ - { qSL("desktopProfile"), qSL("compatibility") }, - { qSL("esMajorVersion"), 5 }, - { qSL("esMinorVersion"), 15 } + { u"desktopProfile"_s, u"compatibility"_s }, + { u"esMajorVersion"_s, 5 }, + { u"esMinorVersion"_s, 15 } })); QCOMPARE(c.installationLocations(), {}); QList<QPair<QString, QString>> containerSelectionConfiguration { - { qSL("*"), qSL("selectionFunction") } + { u"*"_s, u"selectionFunction"_s } }; QCOMPARE(c.containerSelectionConfiguration(), containerSelectionConfiguration); QCOMPARE(c.containerConfigurations(), QVariantMap ({ - { qSL("c-test"), QVariantMap { - { qSL("c-parameter"), qSL("c-value") } + { u"c-test"_s, QVariantMap { + { u"c-parameter"_s, u"c-value"_s } } } })); QCOMPARE(c.runtimeConfigurations(), QVariantMap ({ - { qSL("r-test"), QVariantMap { - { qSL("r-parameter"), qSL("r-value") } + { u"r-test"_s, QVariantMap { + { u"r-parameter"_s, u"r-value"_s } } } })); - QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList(qSL("a"))); + QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList(u"a"_s)); - QCOMPARE(c.dbusRegistration("iface1"), qSL("foobus")); + QCOMPARE(c.dbusRegistration("iface1"), u"foobus"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap ({ - { qSL("public"), QVariantMap { - { qSL("public-prop"), qSL("public-value") } + { u"public"_s, QVariantMap { + { u"public-prop"_s, u"public-value"_s } } }, - { qSL("protected"), QVariantMap { - { qSL("protected-prop"), qSL("protected-value") } + { u"protected"_s, QVariantMap { + { u"protected-prop"_s, u"protected-value"_s } } }, - { qSL("private"), QVariantMap { - { qSL("private-prop"), qSL("private-value") } + { u"private"_s, QVariantMap { + { u"private-prop"_s, u"private-value"_s } } } })); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0.5)); - QHash<std::pair<QString, QString>, int> rpc { { { qSL("*"), qSL("*")}, 5 } }; + QHash<std::pair<QString, QString>, int> rpc { { { u"*"_s, u"*"_s}, 5 } }; QCOMPARE(c.quickLaunchRuntimesPerContainer(), rpc); QCOMPARE(c.quickLaunchFailedStartLimit(), 42); QCOMPARE(c.quickLaunchFailedStartLimitIntervalSec(), 43); - QCOMPARE(c.waylandSocketName(), qSL("my-wlsock-42")); + QCOMPARE(c.waylandSocketName(), u"my-wlsock-42"_s); QCOMPARE(c.waylandExtraSockets(), QVariantList ({ QVariantMap { - { qSL("path"), qSL("path-es1") }, - { qSL("permissions"), 0440 }, - { qSL("userId"), 1 }, - { qSL("groupId"), 2 } + { u"path"_s, u"path-es1"_s }, + { u"permissions"_s, 0440 }, + { u"userId"_s, 1 }, + { u"groupId"_s, 2 } }, QVariantMap { - { qSL("path"), qSL("path-es2") }, - { qSL("permissions"), 0222 }, - { qSL("userId"), 3 }, - { qSL("groupId"), 4 } + { u"path"_s, u"path-es2"_s }, + { u"permissions"_s, 0222 }, + { u"userId"_s, 3 }, + { u"groupId"_s, 4 } } })); QCOMPARE(c.managerCrashAction(), QVariantMap ({ - { qSL("printBacktrace"), true }, - { qSL("printQmlStack"), true }, - { qSL("waitForGdbAttach"), true }, - { qSL("dumpCore"), true } + { u"printBacktrace"_s, true }, + { u"printQmlStack"_s, true }, + { u"waitForGdbAttach"_s, true }, + { u"dumpCore"_s, true } })); - QCOMPARE(c.caCertificates(), QStringList({ qSL("cert1"), qSL("cert2") })); + QCOMPARE(c.caCertificates(), QStringList({ u"cert1"_s, u"cert2"_s })); - QCOMPARE(c.pluginFilePaths("startup"), QStringList({ qSL("s1"), qSL("s2") })); - QCOMPARE(c.pluginFilePaths("container"), QStringList({ qSL("c1"), qSL("c2") })); + QCOMPARE(c.pluginFilePaths("startup"), QStringList({ u"s1"_s, u"s2"_s })); + QCOMPARE(c.pluginFilePaths("container"), QStringList({ u"c1"_s, u"c2"_s })); } void tst_Configuration::mergedConfig() { - Configuration c({ qSL(":/data/") }, qSL(":/build-config.yaml")); - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + Configuration c({ u":/data/"_s }, u":/build-config.yaml"_s); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -260,16 +262,16 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main2.qml")); + QCOMPARE(c.mainQmlFile(), u"main2.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ qSL("builtin-dir"), qSL("builtin-dir2") })); - QCOMPARE(c.documentDir(), qSL("doc-dir2")); + QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ u"builtin-dir"_s, u"builtin-dir2"_s })); + QCOMPARE(c.documentDir(), u"doc-dir2"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir2")); + QCOMPARE(c.installationDir(), u"installation-dir2"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 5); @@ -278,12 +280,12 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 8); QCOMPARE(c.fullscreen(), true); - QCOMPARE(c.windowIcon(), qSL("icon2.png")); + QCOMPARE(c.windowIcon(), u"icon2.png"_s); QCOMPARE(c.importPaths(), QStringList - ({ pwd.absoluteFilePath(qSL("ip1")), - pwd.absoluteFilePath(qSL("ip2")), - pwd.absoluteFilePath(qSL("ip3")) })); - QCOMPARE(c.pluginPaths(), QStringList({ qSL("pp1"), qSL("pp2"), qSL("pp3") })); + ({ pwd.absoluteFilePath(u"ip1"_s), + pwd.absoluteFilePath(u"ip2"_s), + pwd.absoluteFilePath(u"ip3"_s) })); + QCOMPARE(c.pluginPaths(), QStringList({ u"pp1"_s, u"pp2"_s, u"pp3"_s })); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); QCOMPARE(c.developmentMode(), true); @@ -292,117 +294,117 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.allowUnknownUiClients(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("lr1"), qSL("lr2"), qSL("lr3") })); - QCOMPARE(c.messagePattern(), qSL("msgPattern2")); + QCOMPARE(c.loggingRules(), QStringList({ u"lr1"_s, u"lr2"_s, u"lr3"_s })); + QCOMPARE(c.messagePattern(), u"msgPattern2"_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("mystyle2")); - QCOMPARE(c.iconThemeName(), qSL("mytheme2")); - QCOMPARE(c.iconThemeSearchPaths(), QStringList({ qSL("itsp1"), qSL("itsp2"), qSL("itsp3") })); - QCOMPARE(c.dltId(), qSL("dltid2")); - QCOMPARE(c.dltDescription(), qSL("dltdesc2")); - QCOMPARE(c.dltLongMessageBehavior(), qSL("truncate")); - QCOMPARE(c.resources(), QStringList({ qSL("r1"), qSL("r2"), qSL("r3") })); + QCOMPARE(c.style(), u"mystyle2"_s); + QCOMPARE(c.iconThemeName(), u"mytheme2"_s); + QCOMPARE(c.iconThemeSearchPaths(), QStringList({ u"itsp1"_s, u"itsp2"_s, u"itsp3"_s })); + QCOMPARE(c.dltId(), u"dltid2"_s); + QCOMPARE(c.dltDescription(), u"dltdesc2"_s); + QCOMPARE(c.dltLongMessageBehavior(), u"truncate"_s); + QCOMPARE(c.resources(), QStringList({ u"r1"_s, u"r2"_s, u"r3"_s })); QCOMPARE(c.openGLConfiguration(), QVariantMap ({ - { qSL("desktopProfile"), qSL("classic") }, - { qSL("esMajorVersion"), 1 }, - { qSL("esMinorVersion"), 0 }, + { u"desktopProfile"_s, u"classic"_s }, + { u"esMajorVersion"_s, 1 }, + { u"esMinorVersion"_s, 0 }, })); QCOMPARE(c.installationLocations(), {}); QList<QPair<QString, QString>> containerSelectionConfiguration { - { qSL("*"), qSL("selectionFunction") }, - { qSL("2"), qSL("second") } + { u"*"_s, u"selectionFunction"_s }, + { u"2"_s, u"second"_s } }; QCOMPARE(c.containerSelectionConfiguration(), containerSelectionConfiguration); QCOMPARE(c.containerConfigurations(), QVariantMap ({ - { qSL("c-test"), QVariantMap { - { qSL("c-parameter"), qSL("xc-value") }, + { u"c-test"_s, QVariantMap { + { u"c-parameter"_s, u"xc-value"_s }, } }, - { qSL("c-test2"), QVariantMap { - { qSL("c-parameter2"), qSL("c-value2") }, + { u"c-test2"_s, QVariantMap { + { u"c-parameter2"_s, u"c-value2"_s }, } } })); QCOMPARE(c.runtimeConfigurations(), QVariantMap ({ - { qSL("r-test"), QVariantMap { - { qSL("r-parameter"), qSL("xr-value") }, + { u"r-test"_s, QVariantMap { + { u"r-parameter"_s, u"xr-value"_s }, } }, - { qSL("r-test2"), QVariantMap { - { qSL("r-parameter2"), qSL("r-value2") }, + { u"r-test2"_s, QVariantMap { + { u"r-parameter2"_s, u"r-value2"_s }, } } })); - QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList({ qSL("a"), qSL("b"), qSL("c") })); + QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList({ u"a"_s, u"b"_s, u"c"_s })); - QCOMPARE(c.dbusRegistration("iface1"), qSL("foobus1")); - QCOMPARE(c.dbusRegistration("iface2"), qSL("foobus2")); + QCOMPARE(c.dbusRegistration("iface1"), u"foobus1"_s); + QCOMPARE(c.dbusRegistration("iface2"), u"foobus2"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap ({ - { qSL("public"), QVariantMap { - { qSL("public-prop"), qSL("xpublic-value") }, - { qSL("public-prop2"), qSL("public-value2") } + { u"public"_s, QVariantMap { + { u"public-prop"_s, u"xpublic-value"_s }, + { u"public-prop2"_s, u"public-value2"_s } } }, - { qSL("protected"), QVariantMap { - { qSL("protected-prop"), qSL("xprotected-value") }, - { qSL("protected-prop2"), qSL("protected-value2") } + { u"protected"_s, QVariantMap { + { u"protected-prop"_s, u"xprotected-value"_s }, + { u"protected-prop2"_s, u"protected-value2"_s } } }, - { qSL("private"), QVariantMap { - { qSL("private-prop"), qSL("xprivate-value") }, - { qSL("private-prop2"), qSL("private-value2") } + { u"private"_s, QVariantMap { + { u"private-prop"_s, u"xprivate-value"_s }, + { u"private-prop2"_s, u"private-value2"_s } } } })); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0.2)); QHash<std::pair<QString, QString>, int> rpc = { - { { qSL("*"), qSL("*") }, 5 }, - { { qSL("c-foo"), qSL("r-foo") }, 1 }, - { { qSL("c-foo"), qSL("r-bar") }, 2 }, - { { qSL("c-bar"), qSL("*") }, 4 }, + { { u"*"_s, u"*"_s }, 5 }, + { { u"c-foo"_s, u"r-foo"_s }, 1 }, + { { u"c-foo"_s, u"r-bar"_s }, 2 }, + { { u"c-bar"_s, u"*"_s }, 4 }, }; QCOMPARE(c.quickLaunchRuntimesPerContainer(), rpc); QCOMPARE(c.quickLaunchFailedStartLimit(), 44); QCOMPARE(c.quickLaunchFailedStartLimitIntervalSec(), 45); - QCOMPARE(c.waylandSocketName(), qSL("other-wlsock-0")); + QCOMPARE(c.waylandSocketName(), u"other-wlsock-0"_s); QCOMPARE(c.waylandExtraSockets(), QVariantList ({ QVariantMap { - { qSL("path"), qSL("path-es1") }, - { qSL("permissions"), 0440 }, - { qSL("userId"), 1 }, - { qSL("groupId"), 2 } + { u"path"_s, u"path-es1"_s }, + { u"permissions"_s, 0440 }, + { u"userId"_s, 1 }, + { u"groupId"_s, 2 } }, QVariantMap { - { qSL("path"), qSL("path-es2") }, - { qSL("permissions"), 0222 }, - { qSL("userId"), 3 }, - { qSL("groupId"), 4 } + { u"path"_s, u"path-es2"_s }, + { u"permissions"_s, 0222 }, + { u"userId"_s, 3 }, + { u"groupId"_s, 4 } }, QVariantMap { - { qSL("path"), qSL("path-es3") }, + { u"path"_s, u"path-es3"_s }, } })); QCOMPARE(c.managerCrashAction(), QVariantMap ({ - { qSL("printBacktrace"), true }, - { qSL("printQmlStack"), true }, - { qSL("waitForGdbAttach"), true }, - { qSL("dumpCore"), true } + { u"printBacktrace"_s, true }, + { u"printQmlStack"_s, true }, + { u"waitForGdbAttach"_s, true }, + { u"dumpCore"_s, true } })); - QCOMPARE(c.caCertificates(), QStringList({ qSL("cert1"), qSL("cert2"), qSL("cert3") })); + QCOMPARE(c.caCertificates(), QStringList({ u"cert1"_s, u"cert2"_s, u"cert3"_s })); - QCOMPARE(c.pluginFilePaths("container"), QStringList({ qSL("c1"), qSL("c2"), qSL("c3"), qSL("c4") })); - QCOMPARE(c.pluginFilePaths("startup"), QStringList({ qSL("s1"), qSL("s2"), qSL("s3") })); + QCOMPARE(c.pluginFilePaths("container"), QStringList({ u"c1"_s, u"c2"_s, u"c3"_s, u"c4"_s })); + QCOMPARE(c.pluginFilePaths("startup"), QStringList({ u"s1"_s, u"s2"_s, u"s3"_s })); } void tst_Configuration::commandLineConfig() @@ -449,16 +451,16 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.verbose(), true); QCOMPARE(c.slowAnimations(), true); QCOMPARE(c.noDltLogging(), true); - QCOMPARE(c.singleApp(), qSL("appname")); + QCOMPARE(c.singleApp(), u"appname"_s); QCOMPARE(c.qmlDebugging(), true); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main-cl.qml")); + QCOMPARE(c.mainQmlFile(), u"main-cl.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ qSL("builtin-dir-cl1"), qSL("builtin-dir-cl2") })); - QCOMPARE(c.documentDir(), qSL("document-dir-cl")); + QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ u"builtin-dir-cl1"_s, u"builtin-dir-cl2"_s })); + QCOMPARE(c.documentDir(), u"document-dir-cl"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir-cl")); + QCOMPARE(c.installationDir(), u"installation-dir-cl"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 10000); @@ -467,9 +469,9 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 20000); QCOMPARE(c.fullscreen(), false); - QCOMPARE(c.windowIcon(), qSL("")); - QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(qSL("ip-cl1")), - pwd.absoluteFilePath(qSL("ip-cl2")) })); + QCOMPARE(c.windowIcon(), u""_s); + QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(u"ip-cl1"_s), + pwd.absoluteFilePath(u"ip-cl2"_s) })); QCOMPARE(c.pluginPaths(), {}); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); @@ -477,14 +479,14 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.noUiWatchdog(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("cl-lr1"), qSL("cl-lr2") })); - QCOMPARE(c.messagePattern(), qSL("")); + QCOMPARE(c.loggingRules(), QStringList({ u"cl-lr1"_s, u"cl-lr2"_s })); + QCOMPARE(c.messagePattern(), u""_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("")); - QCOMPARE(c.iconThemeName(), qSL("")); + QCOMPARE(c.style(), u""_s); + QCOMPARE(c.iconThemeName(), u""_s); QCOMPARE(c.iconThemeSearchPaths(), {}); - QCOMPARE(c.dltId(), qSL("")); - QCOMPARE(c.dltDescription(), qSL("")); + QCOMPARE(c.dltId(), u""_s); + QCOMPARE(c.dltDescription(), u""_s); QCOMPARE(c.resources(), {}); QCOMPARE(c.openGLConfiguration(), QVariantMap {}); @@ -496,14 +498,14 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.runtimeConfigurations(), QVariantMap{}); QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList{}); - QCOMPARE(c.dbusRegistration("iface1"), qSL("system")); + QCOMPARE(c.dbusRegistration("iface1"), u"system"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap {}); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0)); QVERIFY(c.quickLaunchRuntimesPerContainer().isEmpty()); - QCOMPARE(c.waylandSocketName(), qSL("wlsock-1")); + QCOMPARE(c.waylandSocketName(), u"wlsock-1"_s); QCOMPARE(c.waylandExtraSockets(), {}); QCOMPARE(c.managerCrashAction(), QVariantMap {}); diff --git a/tests/auto/controller-tool/tst_controller-tool.cpp b/tests/auto/controller-tool/tst_controller-tool.cpp index 76c99d9f..0698fddb 100644 --- a/tests/auto/controller-tool/tst_controller-tool.cpp +++ b/tests/auto/controller-tool/tst_controller-tool.cpp @@ -22,6 +22,8 @@ #include "qtyaml.h" #include <QtAppManMain/configuration.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM using namespace QtYaml; @@ -93,7 +95,7 @@ public: m_ctrl.reset(new QProcess); m_spy.reset(new QSignalSpy(m_ctrl.get(), &QProcess::finished)); m_ctrl->setProgram(s_command); - QStringList args = { qSL("--instance-id"), qSL("controller-test-id") }; + QStringList args = { u"--instance-id"_s, u"controller-test-id"_s }; args.append(m_arguments); m_ctrl->setArguments(args); m_ctrl->start(); @@ -151,7 +153,7 @@ QString ControllerTool::s_command; tst_ControllerTool::tst_ControllerTool() : m_spyTimeout(5000 * timeoutFactor()) - , m_tmpDir(qSL("/tmp/am-test-controller-tool")) + , m_tmpDir(u"/tmp/am-test-controller-tool"_s) { } void tst_ControllerTool::initTestCase() @@ -160,7 +162,7 @@ void tst_ControllerTool::initTestCase() QSKIP("This test is only supported on Linux"); #endif - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); auto verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); @@ -176,10 +178,10 @@ void tst_ControllerTool::initTestCase() QStringList possibleLocations; possibleLocations.append(QLibraryInfo::path(QLibraryInfo::BinariesPath)); - possibleLocations.append(QCoreApplication::applicationDirPath() + qSL("/../../../bin")); + possibleLocations.append(QCoreApplication::applicationDirPath() + u"/../../../bin"_s); QString controllerPath; - const QString controllerName = qSL("/appman-controller"); + const QString controllerName = u"/appman-controller"_s; for (const QString &possibleLocation : possibleLocations) { QFileInfo fi(possibleLocation + controllerName); @@ -208,7 +210,7 @@ void tst_ControllerTool::initTestCase() if (m_tmpDir.exists()) m_tmpDir.removeRecursively(); - QVERIFY(m_tmpDir.mkpath(qSL("."))); + QVERIFY(m_tmpDir.mkpath(u"."_s)); } void tst_ControllerTool::cleanupTestCase() @@ -242,44 +244,44 @@ void tst_ControllerTool::usage() void tst_ControllerTool::instances() { - ControllerTool ctrl({ qSL("list-instances") }); + ControllerTool ctrl({ u"list-instances"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("\"controller-test-id\"") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"\"controller-test-id\""_s })); } void tst_ControllerTool::applications() { { - ControllerTool ctrl({ qSL("list-applications") }); + ControllerTool ctrl({ u"list-applications"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("green1"), qSL("green2") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"green1"_s, u"green2"_s })); } { - ControllerTool ctrl({ qSL("show-application"), qSL("green1") }); + ControllerTool ctrl({ u"show-application"_s, u"green1"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); QVariantMap expected({ - { qSL("applicationId"), qSL("green1") }, - { qSL("capabilities"), QVariantList { } }, - { qSL("categories"), QVariantList { } }, - { qSL("codeFilePath"), QFINDTESTDATA("builtin-apps/hello-world.green/main.qml") }, - { qSL("icon"), QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, - { qSL("isBlocked"), false }, - { qSL("isRemovable"), false }, - { qSL("isRunning"), false }, - { qSL("isShuttingDown"), false }, - { qSL("isStartingUp"), false }, - { qSL("isUpdating"), false }, - { qSL("lastExitCode"), 0 }, - { qSL("lastExitStatus"), 0 }, - { qSL("name"), qSL("Hello Green") }, - { qSL("runtimeName"), qSL("qml") }, - { qSL("runtimeParameters"), QVariantMap { } }, - { qSL("updateProgress"), 0 }, - { qSL("version"), qSL("1.2.3") }, + { u"applicationId"_s, u"green1"_s }, + { u"capabilities"_s, QVariantList { } }, + { u"categories"_s, QVariantList { } }, + { u"codeFilePath"_s, QFINDTESTDATA("builtin-apps/hello-world.green/main.qml") }, + { u"icon"_s, QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, + { u"isBlocked"_s, false }, + { u"isRemovable"_s, false }, + { u"isRunning"_s, false }, + { u"isShuttingDown"_s, false }, + { u"isStartingUp"_s, false }, + { u"isUpdating"_s, false }, + { u"lastExitCode"_s, 0 }, + { u"lastExitStatus"_s, 0 }, + { u"name"_s, u"Hello Green"_s }, + { u"runtimeName"_s, u"qml"_s }, + { u"runtimeParameters"_s, QVariantMap { } }, + { u"updateProgress"_s, 0 }, + { u"version"_s, u"1.2.3"_s }, }); QCOMPARE(vm, expected); } @@ -288,27 +290,27 @@ void tst_ControllerTool::applications() void tst_ControllerTool::packages() { { - ControllerTool ctrl({ qSL("list-packages") }); + ControllerTool ctrl({ u"list-packages"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("hello-world.green") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"hello-world.green"_s })); } { - ControllerTool ctrl({ qSL("show-package"), qSL("hello-world.green") }); + ControllerTool ctrl({ u"show-package"_s, u"hello-world.green"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); QVariantMap expected({ - { qSL("description"), qSL("Green description") }, - { qSL("icon"), QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, - { qSL("isBlocked"), false }, - { qSL("isRemovable"), false }, - { qSL("isUpdating"), false }, - { qSL("name"), qSL("Hello Green") }, - { qSL("packageId"), qSL("hello-world.green") }, - { qSL("updateProgress"), 0 }, - { qSL("version"), qSL("1.2.3") }, + { u"description"_s, u"Green description"_s }, + { u"icon"_s, QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, + { u"isBlocked"_s, false }, + { u"isRemovable"_s, false }, + { u"isUpdating"_s, false }, + { u"name"_s, u"Hello Green"_s }, + { u"packageId"_s, u"hello-world.green"_s }, + { u"updateProgress"_s, 0 }, + { u"version"_s, u"1.2.3"_s }, }); QCOMPARE(vm, expected); } @@ -317,45 +319,45 @@ void tst_ControllerTool::packages() void tst_ControllerTool::installationLocations() { { - ControllerTool ctrl({ qSL("list-installation-locations") }); + ControllerTool ctrl({ u"list-installation-locations"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("internal-0") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"internal-0"_s })); } { - ControllerTool ctrl({ qSL("show-installation-location"), qSL("internal-0") }); + ControllerTool ctrl({ u"show-installation-location"_s, u"internal-0"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); - QCOMPARE(vm.value(qSL("path")), qSL("/tmp/am-test-controller-tool/apps")); - QVERIFY(vm.value(qSL("deviceSize")).toULongLong() > 0); - QVERIFY(vm.value(qSL("deviceFree")).toULongLong() > 0); + QCOMPARE(vm.value(u"path"_s), u"/tmp/am-test-controller-tool/apps"_s); + QVERIFY(vm.value(u"deviceSize"_s).toULongLong() > 0); + QVERIFY(vm.value(u"deviceFree"_s).toULongLong() > 0); } } void tst_ControllerTool::installCancel() { - ControllerTool install({ qSL("install-package"), - qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); + ControllerTool install({ u"install-package"_s, + QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); QVERIFY2(install.start(), install.failure); - QTRY_VERIFY(PackageManager::instance()->isPackageInstallationActive(qSL("hello-world.red"))); + QTRY_VERIFY(PackageManager::instance()->isPackageInstallationActive(u"hello-world.red"_s)); QString taskId; { - ControllerTool ctrl({ qSL("list-installation-tasks") }); + ControllerTool ctrl({ u"list-installation-tasks"_s }); QVERIFY2(ctrl.call(), ctrl.failure); QCOMPARE(ctrl.stdOutList.size(), 1); taskId = ctrl.stdOutList.at(0); QVERIFY(!QUuid::fromString(taskId).isNull()); } { - ControllerTool ctrl({ qSL("cancel-installation-task"), taskId }); + ControllerTool ctrl({ u"cancel-installation-task"_s, taskId }); QVERIFY2(ctrl.call(), ctrl.failure); } { - ControllerTool ctrl({ qSL("list-installation-tasks") }); + ControllerTool ctrl({ u"list-installation-tasks"_s }); QVERIFY2(ctrl.call(), ctrl.failure); QCOMPARE(ctrl.stdOutList.size(), 0); } @@ -368,40 +370,40 @@ void tst_ControllerTool::installCancel() void tst_ControllerTool::installRemove() { { - ControllerTool ctrl({ qSL("install-package"), qSL("-a"), - qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); + ControllerTool ctrl({ u"install-package"_s, u"-a"_s, + QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); QVERIFY2(ctrl.call(), ctrl.failure); } { - ControllerTool ctrl({ qSL("remove-package"), qSL("hello-world.red") }); + ControllerTool ctrl({ u"remove-package"_s, u"hello-world.red"_s }); QVERIFY2(ctrl.call(), ctrl.failure); } } void tst_ControllerTool::startStop() { - const auto app = ApplicationManager::instance()->application(qSL("green1")); + const auto app = ApplicationManager::instance()->application(u"green1"_s); QVERIFY(app); { - ControllerTool ctrl({ qSL("start-application"), app->id() }); + ControllerTool ctrl({ u"start-application"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::Running); { - ControllerTool ctrl({ qSL("stop-application"), app->id() }); + ControllerTool ctrl({ u"stop-application"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::NotRunning); { // debug-application does not work in single-process mode bool sp = ApplicationManager::instance()->isSingleProcess(); - ControllerTool ctrl(sp ? QStringList { qSL("start-application"), app->id() } - : QStringList { qSL("debug-application"), qSL("FOO=BAR"), app->id() }); + ControllerTool ctrl(sp ? QStringList { u"start-application"_s, app->id() } + : QStringList { u"debug-application"_s, u"FOO=BAR"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::Running); { - ControllerTool ctrl({ qSL("stop-all-applications") }); + ControllerTool ctrl({ u"stop-all-applications"_s }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::NotRunning); @@ -412,15 +414,15 @@ void tst_ControllerTool::injectIntent() auto oldDevMode = PackageManager::instance()->developmentMode(); PackageManager::instance()->setDevelopmentMode(true); - ControllerTool ctrl({ qSL("inject-intent-request"), qSL("--requesting-application-id"), - qSL(":sysui:"), qSL("--application-id"), qSL(":sysui:"), qSL("inject-intent"), qSL("{ }"), }); + ControllerTool ctrl({ u"inject-intent-request"_s, u"--requesting-application-id"_s, + u":sysui:"_s, u"--application-id"_s, u":sysui:"_s, u"inject-intent"_s, u"{ }"_s, }); QVERIFY2(ctrl.call(), ctrl.failure); const auto json = QJsonDocument::fromJson(ctrl.stdOut); const auto vm = json.toVariant().toMap(); QVariantMap expected({ - { qSL("status"), qSL("ok") }, + { u"status"_s, u"ok"_s }, }); QCOMPARE(vm, expected); diff --git a/tests/auto/error-checking.h b/tests/auto/error-checking.h index 0e207b88..edae213e 100644 --- a/tests/auto/error-checking.h +++ b/tests/auto/error-checking.h @@ -9,7 +9,7 @@ // sadly this has to be a define for QVERIFY2() to work #define QT_AM_CHECK_ERRORSTRING(_actual_errstr, _expected_errstr) do { \ - if (_expected_errstr.startsWith(QLatin1String("~"))) { \ + if (_expected_errstr.startsWith(u"~")) { \ QRegularExpression re(_expected_errstr.mid(1)); \ QVERIFY2(re.match(_actual_errstr).hasMatch(), \ QByteArray("\n Got : ") + _actual_errstr.toLocal8Bit() + \ diff --git a/tests/auto/installationreport/tst_installationreport.cpp b/tests/auto/installationreport/tst_installationreport.cpp index 62f4c613..adf3403b 100644 --- a/tests/auto/installationreport/tst_installationreport.cpp +++ b/tests/auto/installationreport/tst_installationreport.cpp @@ -10,6 +10,8 @@ #include "exception.h" #include "installationreport.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_InstallationReport : public QObject @@ -28,9 +30,9 @@ tst_InstallationReport::tst_InstallationReport() void tst_InstallationReport::test() { - QStringList files { qSL("test"), qSL("more/test"), qSL("another/test/file") }; + QStringList files { u"test"_s, u"more/test"_s, u"another/test/file"_s }; - InstallationReport ir(qSL("com.pelagicore.test")); + InstallationReport ir(u"com.pelagicore.test"_s); QVERIFY(!ir.isValid()); ir.addFile(files.first()); QVERIFY(!ir.isValid()); @@ -43,7 +45,7 @@ void tst_InstallationReport::test() ir.setStoreSignature("$$store-sig$$"); QVERIFY(ir.isValid()); - QCOMPARE(ir.packageId(), qSL("com.pelagicore.test")); + QCOMPARE(ir.packageId(), u"com.pelagicore.test"_s); QCOMPARE(ir.files(), files); QCOMPARE(ir.diskSpaceUsed(), 42ULL); QCOMPARE(ir.digest().constData(), "##digest##"); @@ -64,7 +66,7 @@ void tst_InstallationReport::test() buffer.seek(0); QVERIFY(ir2.isValid()); - QCOMPARE(ir2.packageId(), qSL("com.pelagicore.test")); + QCOMPARE(ir2.packageId(), u"com.pelagicore.test"_s); QCOMPARE(ir2.files(), files); QCOMPARE(ir2.diskSpaceUsed(), 42ULL); QCOMPARE(ir2.digest().constData(), "##digest##"); diff --git a/tests/auto/main/tst_main.cpp b/tests/auto/main/tst_main.cpp index d1336ff7..be285c90 100644 --- a/tests/auto/main/tst_main.cpp +++ b/tests/auto/main/tst_main.cpp @@ -19,6 +19,8 @@ #include "utilities.h" #include <QtAppManMain/configuration.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM @@ -66,7 +68,7 @@ tst_Main::~tst_Main() void tst_Main::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); m_verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); @@ -92,12 +94,12 @@ void tst_Main::copyRecursively(const QString &sourcePath, const QString &destPat void tst_Main::cleanUpInstallationDir() { { - QDir testTmpDir(qSL("/tmp/am-test-main")); + QDir testTmpDir(u"/tmp/am-test-main"_s); if (testTmpDir.exists()) testTmpDir.removeRecursively(); } - QDir tmpDir(qSL("/tmp")); - tmpDir.mkdir(qSL("am-test-main")); + QDir tmpDir(u"/tmp"_s); + tmpDir.mkdir(u"am-test-main"_s); } void tst_Main::init() @@ -199,29 +201,29 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() QCOMPARE(intents->count(), 2); auto app1 = appMan->application(0); - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red")); - QCOMPARE(app1->id(), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Red"_s); + QCOMPARE(app1->id(), u"red1"_s); auto app2 = appMan->application(1); - QCOMPARE(app2->names().value(qSL("en")), qSL("Hello Red")); - QCOMPARE(app2->id(), qSL("red2")); + QCOMPARE(app2->names().value(u"en"_s), u"Hello Red"_s); + QCOMPARE(app2->id(), u"red2"_s); - auto intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + auto intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(intent1); - QCOMPARE(intent1->intentId(), qSL("red.intent1")); - QCOMPARE(intent1->applicationId(), qSL("red1")); - QCOMPARE(intent1->packageId(), qSL("hello-world.red")); - QVERIFY(intent1->categories().contains(qSL("one"))); - QVERIFY(intent1->categories().contains(qSL("launcher"))); + QCOMPARE(intent1->intentId(), u"red.intent1"_s); + QCOMPARE(intent1->applicationId(), u"red1"_s); + QCOMPARE(intent1->packageId(), u"hello-world.red"_s); + QVERIFY(intent1->categories().contains(u"one"_s)); + QVERIFY(intent1->categories().contains(u"launcher"_s)); - auto intent2 = intents->applicationIntent(qSL("red.intent2"), qSL("red2")); + auto intent2 = intents->applicationIntent(u"red.intent2"_s, u"red2"_s); QVERIFY(intent2); - QCOMPARE(intent2->intentId(), qSL("red.intent2")); - QCOMPARE(intent2->applicationId(), qSL("red2")); - QCOMPARE(intent2->packageId(), qSL("hello-world.red")); - QVERIFY(intent2->categories().contains(qSL("two"))); - QVERIFY(intent2->categories().contains(qSL("launcher"))); + QCOMPARE(intent2->intentId(), u"red.intent2"_s); + QCOMPARE(intent2->applicationId(), u"red2"_s); + QCOMPARE(intent2->packageId(), u"hello-world.red"_s); + QVERIFY(intent2->categories().contains(u"two"_s)); + QVERIFY(intent2->categories().contains(u"launcher"_s)); - installPackage(qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); + installPackage(QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); QCOMPARE(appMan->count(), 1); QCOMPARE(intents->count(), 0); @@ -231,11 +233,11 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() app1 = appMan->application(0); // but with different contents - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Updated Red")); - intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Updated Red"_s); + intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(!intent1); - removePackage(qSL("hello-world.red")); + removePackage(u"hello-world.red"_s); // After removal of the updated version all data in Application should be as before the // installation took place. @@ -243,13 +245,13 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() QCOMPARE(intents->count(), 2); app1 = appMan->application(0); - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red")); - intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Red"_s); + intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(intent1); - QCOMPARE(intent1->intentId(), qSL("red.intent1")); - intent2 = intents->applicationIntent(qSL("red.intent2"), qSL("red2")); + QCOMPARE(intent1->intentId(), u"red.intent1"_s); + intent2 = intents->applicationIntent(u"red.intent2"_s, u"red2"_s); QVERIFY(intent2); - QCOMPARE(intent2->intentId(), qSL("red.intent2")); + QCOMPARE(intent2->intentId(), u"red.intent2"_s); } /* @@ -263,7 +265,7 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() */ void tst_Main::updateForBuiltInAlreadyInstalled() { - copyRecursively(QFINDTESTDATA("dir-with-update-already-installed"), qSL("/tmp/am-test-main")); + copyRecursively(QFINDTESTDATA("dir-with-update-already-installed"), u"/tmp/am-test-main"_s); initMain(); @@ -271,7 +273,7 @@ void tst_Main::updateForBuiltInAlreadyInstalled() QCOMPARE(appMan->count(), 1); auto app = appMan->application(0); - QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red")); + QCOMPARE(app->names().value(u"en"_s), u"Hello Updated Red"_s); } /* @@ -283,7 +285,7 @@ void tst_Main::updateForBuiltInAlreadyInstalled() void tst_Main::loadDatabaseWithUpdatedBuiltInApp() { initMain(); - installPackage(qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); + installPackage(QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); destroyMain(); initMain(); @@ -292,7 +294,7 @@ void tst_Main::loadDatabaseWithUpdatedBuiltInApp() QCOMPARE(appMan->count(), 1); auto app = appMan->application(0); - QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red")); + QCOMPARE(app->names().value(u"en"_s), u"Hello Updated Red"_s); } void tst_Main::mainQmlFile_data() @@ -351,7 +353,7 @@ void tst_Main::startupTimer() initMain(); - StartupTimer::instance()->createReport(qSL("TEST")); + StartupTimer::instance()->createReport(u"TEST"_s); QFile f(fn); QVERIFY(f.open(QIODevice::ReadOnly)); diff --git a/tests/auto/packagecreator/tst_packagecreator.cpp b/tests/auto/packagecreator/tst_packagecreator.cpp index bc748ee0..fe9459fa 100644 --- a/tests/auto/packagecreator/tst_packagecreator.cpp +++ b/tests/auto/packagecreator/tst_packagecreator.cpp @@ -13,6 +13,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static int processTimeout = 3000; @@ -40,7 +42,7 @@ private: }; tst_PackageCreator::tst_PackageCreator() - : m_baseDir(qSL(AM_TESTDATA_DIR)) + : m_baseDir(QString::fromLatin1(AM_TESTDATA_DIR)) { } void tst_PackageCreator::initTestCase() @@ -49,14 +51,14 @@ void tst_PackageCreator::initTestCase() // check if tar command is available at all QProcess tar; - tar.start(qSL("tar"), { qSL("--version") }); + tar.start(u"tar"_s, { u"--version"_s }); m_tarAvailable = tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit); m_isCygwin = tar.readAllStandardOutput().contains("Cygwin"); - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); } @@ -66,8 +68,8 @@ void tst_PackageCreator::createAndVerify_data() QTest::addColumn<bool>("expectedSuccess"); QTest::addColumn<QString>("errorString"); - QTest::newRow("basic") << QStringList { qSL("testfile") } << true << ""; - QTest::newRow("no-such-file") << QStringList { qSL("tastfile") } << false << "~file not found: .*"; + QTest::newRow("basic") << QStringList { u"testfile"_s } << true << ""; + QTest::newRow("no-such-file") << QStringList { u"tastfile"_s } << false << "~file not found: .*"; } void tst_PackageCreator::createAndVerify() @@ -79,7 +81,7 @@ void tst_PackageCreator::createAndVerify() QTemporaryFile output; QVERIFY(output.open()); - InstallationReport report(qSL("com.pelagicore.test")); + InstallationReport report(u"com.pelagicore.test"_s); report.addFiles(files); PackageCreator creator(m_baseDir, &output, report); @@ -102,7 +104,7 @@ void tst_PackageCreator::createAndVerify() QSKIP("No tar command found in PATH - skipping the verification part of the test!"); QProcess tar; - tar.start(qSL("tar"), { qSL("-tzf"), escapeFilename(output.fileName()) }); + tar.start(u"tar"_s, { u"-tzf"_s, escapeFilename(output.fileName()) }); QVERIFY2(tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit) && @@ -110,12 +112,12 @@ void tst_PackageCreator::createAndVerify() QStringList expectedContents = files; expectedContents.sort(); - expectedContents.prepend(qSL("--PACKAGE-HEADER--")); - expectedContents.append(qSL("--PACKAGE-FOOTER--")); + expectedContents.prepend(u"--PACKAGE-HEADER--"_s); + expectedContents.append(u"--PACKAGE-FOOTER--"_s); - QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(qL1C('\n'), Qt::SkipEmptyParts); + QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(u'\n', Qt::SkipEmptyParts); #if defined(Q_OS_WIN) - actualContents.replaceInStrings(qSL("\r"), QString()); + actualContents.replaceInStrings(u"\r"_s, QString()); #endif QCOMPARE(actualContents, expectedContents); @@ -126,7 +128,7 @@ void tst_PackageCreator::createAndVerify() QVERIFY2(src.open(QFile::ReadOnly), qPrintable(src.errorString())); QByteArray data = src.readAll(); - tar.start(qSL("tar"), { qSL("-xzOf"), escapeFilename(output.fileName()), file }); + tar.start(u"tar"_s, { u"-xzOf"_s, escapeFilename(output.fileName()), file }); QVERIFY2(tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit) && @@ -142,7 +144,7 @@ QString tst_PackageCreator::escapeFilename(const QString &name) return name; } else { QString s = QFileInfo(name).absoluteFilePath(); - QString t = qSL("/cygdrive/"); + QString t = u"/cygdrive/"_s; t.append(s.at(0)); return t + s.mid(2); } diff --git a/tests/auto/packageextractor/tst_packageextractor.cpp b/tests/auto/packageextractor/tst_packageextractor.cpp index 43d1fd75..e9f21b90 100644 --- a/tests/auto/packageextractor/tst_packageextractor.cpp +++ b/tests/auto/packageextractor/tst_packageextractor.cpp @@ -24,6 +24,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_PackageExtractor : public QObject @@ -56,7 +58,7 @@ tst_PackageExtractor::tst_PackageExtractor() void tst_PackageExtractor::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); } @@ -87,31 +89,31 @@ void tst_PackageExtractor::extractAndVerify_data() QTest::newRow("normal") << "packages/test.appkg" << true << "" << QStringList { - qSL("info.yaml"), - qSL("icon.png"), - qSL("test"), + u"info.yaml"_s, + u"icon.png"_s, + u"test"_s, m_taest } << QMap<QString, QByteArray> { - { qSL("test"), "test\n" }, + { u"test"_s, "test\n" }, { m_taest, "test with umlaut\n" } } << noSizes; QTest::newRow("big") << "packages/bigtest.appkg" << true << "" << QStringList { - qSL("info.yaml"), - qSL("icon.png"), - qSL("test"), + u"info.yaml"_s, + u"icon.png"_s, + u"test"_s, m_taest, - qSL("bigtest") } + u"bigtest"_s } << QMap<QString, QByteArray> { - { qSL("test"), "test\n" }, + { u"test"_s, "test\n" }, { m_taest, "test with umlaut\n" } } << QMap<QString, qint64> { // { "info.yaml", 213 }, // this is different on Windows: \n vs. \r\n - { qSL("icon.png"), 1157 }, - { qSL("bigtest"), 5*1024*1024 }, - { qSL("test"), 5 }, + { u"icon.png"_s, 1157 }, + { u"bigtest"_s, 5*1024*1024 }, + { u"test"_s, 5 }, { m_taest, 17 } }; QTest::newRow("invalid-url") << "packages/no-such-file.appkg" @@ -141,7 +143,7 @@ void tst_PackageExtractor::extractAndVerify() QFETCH(ByteArrayMap, content); QFETCH(IntMap, sizes); - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR) + path), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR) + path), m_extractDir->path()); bool result = extractor.extract(); if (expectedSuccess) { @@ -179,7 +181,7 @@ void tst_PackageExtractor::extractAndVerify() QVERIFY(checkEntries.removeOne(entry)); } - QVERIFY2(checkEntries.isEmpty(), qPrintable(checkEntries.join(qL1C(' ')))); + QVERIFY2(checkEntries.isEmpty(), qPrintable(checkEntries.join(u' '))); QStringList reportEntries = extractor.installationReport().files(); reportEntries.sort(); @@ -190,7 +192,7 @@ void tst_PackageExtractor::extractAndVerify() void tst_PackageExtractor::cancelExtraction() { { - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); extractor.cancel(); QVERIFY(!extractor.extract()); QVERIFY(extractor.wasCanceled()); @@ -198,7 +200,7 @@ void tst_PackageExtractor::cancelExtraction() QVERIFY(extractor.hasFailed()); } { - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); connect(&extractor, &PackageExtractor::progress, this, [&extractor](qreal p) { if (p >= 0.1) extractor.cancel(); @@ -216,7 +218,7 @@ public: FifoSource(const QString &file) : m_file(file) { - m_fifoPath = QDir::temp().absoluteFilePath(qSL("autotext-package-extractor-%1.fifo")) + m_fifoPath = QDir::temp().absoluteFilePath(u"autotext-package-extractor-%1.fifo"_s) .arg(QCoreApplication::applicationPid()) .toLocal8Bit(); #ifdef Q_OS_UNIX @@ -267,7 +269,7 @@ void tst_PackageExtractor::extractFromFifo() QSKIP("No FIFO support on this platform"); #endif - FifoSource fifo(qL1S(AM_TESTDATA_DIR "packages/test.appkg")); + FifoSource fifo(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")); fifo.start(); PackageExtractor extractor(QUrl::fromLocalFile(fifo.path()), m_extractDir->path()); diff --git a/tests/auto/packager-tool/tst_packager-tool.cpp b/tests/auto/packager-tool/tst_packager-tool.cpp index e8083e5d..8758c10b 100644 --- a/tests/auto/packager-tool/tst_packager-tool.cpp +++ b/tests/auto/packager-tool/tst_packager-tool.cpp @@ -20,6 +20,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static int spyTimeout = 5000; // shorthand for specifying QSignalSpy timeouts @@ -40,7 +42,7 @@ private Q_SLOTS: private: QString pathTo(const char *file) { - return QDir(m_workDir.path()).absoluteFilePath(QLatin1String(file)); + return QDir(m_workDir.path()).absoluteFilePath(QString::fromLatin1(file)); } bool createInfoYaml(QTemporaryDir &tmp, const QString &changeField = QString(), const QVariant &toValue = QVariant()); @@ -63,7 +65,7 @@ private: void tst_PackagerTool::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); spyTimeout *= timeoutFactor(); @@ -72,7 +74,7 @@ void tst_PackagerTool::initTestCase() QVERIFY(QDir::root().mkpath(pathTo("internal-0"))); QVERIFY(QDir::root().mkpath(pathTo("documents-0"))); - m_hardwareId = qSL("foobar"); + m_hardwareId = u"foobar"_s; PackageDatabase *pdb = new PackageDatabase({}, pathTo("internal-0")); try { @@ -89,8 +91,8 @@ void tst_PackagerTool::initTestCase() // crypto stuff - we need to load the root CA and developer CA certificates - QFile devcaFile(qL1S(AM_TESTDATA_DIR "certificates/devca.crt")); - QFile caFile(qL1S(AM_TESTDATA_DIR "certificates/ca.crt")); + QFile devcaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/devca.crt")); + QFile caFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/ca.crt")); QVERIFY2(devcaFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); QVERIFY2(caFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); @@ -102,12 +104,12 @@ void tst_PackagerTool::initTestCase() m_caFiles << devcaFile.fileName() << caFile.fileName(); - m_devPassword = qSL("password"); - m_devCertificate = qL1S(AM_TESTDATA_DIR "certificates/dev1.p12"); - m_storePassword = qSL("password"); - m_storeCertificate = qL1S(AM_TESTDATA_DIR "certificates/store.p12"); + m_devPassword = u"password"_s; + m_devCertificate = QString::fromLatin1(AM_TESTDATA_DIR "certificates/dev1.p12"); + m_storePassword = u"password"_s; + m_storeCertificate = QString::fromLatin1(AM_TESTDATA_DIR "certificates/store.p12"); - RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("qml"))); + RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(u"qml"_s)); } void tst_PackagerTool::cleanup() @@ -145,32 +147,32 @@ void tst_PackagerTool::test() // no valid destination QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), pathTo("test.appkg")), errorString)); - QVERIFY2(errorString.contains(qL1S("is not a directory")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"is not a directory"), qPrintable(errorString)); // no valid info.yaml QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("Cannot open for reading")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"Cannot open for reading"), qPrintable(errorString)); // add an info.yaml file createInfoYaml(tmp); // no icon QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("missing the file referenced by the 'icon' field")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"missing the file referenced by the 'icon' field"), qPrintable(errorString)); // add an icon createIconPng(tmp); // no valid code QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("missing the file referenced by the 'code' field")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"missing the file referenced by the 'code' field"), qPrintable(errorString)); // add a code file createCode(tmp); // invalid destination QVERIFY(!packagerCheck(PackagingJob::create(tmp.path(), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create package file")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create package file"), qPrintable(errorString)); // now everything is correct - try again QVERIFY2(packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString), qPrintable(errorString)); @@ -181,7 +183,7 @@ void tst_PackagerTool::test() pathTo("test.dev-signed.appkg"), m_devCertificate, m_devPassword), errorString)); - QVERIFY2(errorString.contains(qL1S("does not exist")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"does not exist"), qPrintable(errorString)); // invalid destination package QVERIFY(!packagerCheck(PackagingJob::developerSign( @@ -189,7 +191,7 @@ void tst_PackagerTool::test() pathTo("."), m_devCertificate, m_devPassword), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create package file")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create package file"), qPrintable(errorString)); // invalid dev key @@ -197,17 +199,17 @@ void tst_PackagerTool::test() pathTo("test.appkg"), pathTo("test.dev-signed.appkg"), m_devCertificate, - qSL("wrong-password")), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create signature")), qPrintable(errorString)); + u"wrong-password"_s), errorString)); + QVERIFY2(errorString.contains(u"could not create signature"), qPrintable(errorString)); // invalid store key QVERIFY(!packagerCheck(PackagingJob::storeSign( pathTo("test.appkg"), pathTo("test.store-signed.appkg"), m_storeCertificate, - qSL("wrong-password"), + u"wrong-password"_s, m_hardwareId), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create signature")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create signature"), qPrintable(errorString)); // sign QVERIFY2(packagerCheck(PackagingJob::developerSign( @@ -238,9 +240,9 @@ void tst_PackagerTool::test() installPackage(pathTo("test.dev-signed.appkg")); QDir checkDir(pathTo("internal-0")); - QVERIFY(checkDir.cd(qSL("com.pelagicore.test"))); + QVERIFY(checkDir.cd(u"com.pelagicore.test"_s)); - for (const QString &file : { qSL("info.yaml"), qSL("icon.png"), qSL("test.qml") }) { + for (const QString &file : { u"info.yaml"_s, u"icon.png"_s, u"test.qml"_s }) { QVERIFY(checkDir.exists(file)); QFile src(QDir(tmp.path()).absoluteFilePath(file)); QVERIFY(src.open(QFile::ReadOnly)); @@ -289,9 +291,9 @@ void tst_PackagerTool::iconFileName() QTemporaryDir tmp; QString errorString; - createInfoYaml(tmp, qSL("icon"), qSL("foo.bar")); + createInfoYaml(tmp, u"icon"_s, u"foo.bar"_s); createCode(tmp); - createDummyFile(tmp, qSL("foo.bar"), "this-is-a-dummy-icon-file"); + createDummyFile(tmp, u"foo.bar"_s, "this-is-a-dummy-icon-file"); QVERIFY2(packagerCheck(PackagingJob::create(pathTo("test-foobar-icon.appkg"), tmp.path()), errorString), qPrintable(errorString)); @@ -303,9 +305,9 @@ void tst_PackagerTool::iconFileName() m_pm->setAllowInstallationOfUnsignedPackages(false); QDir checkDir(pathTo("internal-0")); - QVERIFY(checkDir.cd(qSL("com.pelagicore.test"))); + QVERIFY(checkDir.cd(u"com.pelagicore.test"_s)); - for (const QString &file : { qSL("info.yaml"), qSL("foo.bar"), qSL("test.qml") }) { + for (const QString &file : { u"info.yaml"_s, u"foo.bar"_s, u"test.qml"_s }) { QVERIFY(checkDir.exists(file)); QFile src(QDir(tmp.path()).absoluteFilePath(file)); QVERIFY(src.open(QFile::ReadOnly)); @@ -343,19 +345,19 @@ bool tst_PackagerTool::createInfoYaml(QTemporaryDir &tmp, const QString &changeF yaml = QtYaml::yamlFromVariantDocuments({ docs.at(0), map }); } - QFile infoYaml(QDir(tmp.path()).absoluteFilePath(qSL("info.yaml"))); + QFile infoYaml(QDir(tmp.path()).absoluteFilePath(u"info.yaml"_s)); return infoYaml.open(QFile::WriteOnly) && infoYaml.write(yaml) == yaml.size(); } bool tst_PackagerTool::createIconPng(QTemporaryDir &tmp) { - QFile iconPng(QDir(tmp.path()).absoluteFilePath(qSL("icon.png"))); + QFile iconPng(QDir(tmp.path()).absoluteFilePath(u"icon.png"_s)); return iconPng.open(QFile::WriteOnly) && iconPng.write("\x89PNG") == 4; } bool tst_PackagerTool::createCode(QTemporaryDir &tmp) { - QFile code(QDir(tmp.path()).absoluteFilePath(qSL("test.qml"))); + QFile code(QDir(tmp.path()).absoluteFilePath(u"test.qml"_s)); return code.open(QFile::WriteOnly) && code.write("// test") == 7LL; } diff --git a/tests/auto/runtime/tst_runtime.cpp b/tests/auto/runtime/tst_runtime.cpp index d3591f64..d86e9865 100644 --- a/tests/auto/runtime/tst_runtime.cpp +++ b/tests/auto/runtime/tst_runtime.cpp @@ -14,6 +14,8 @@ #include "runtimefactory.h" #include "exception.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Runtime : public QObject @@ -68,7 +70,7 @@ public: : AbstractRuntimeManager(id, parent) { } - static QString defaultIdentifier() { return qSL("foo"); } + static QString defaultIdentifier() { return u"foo"_s; } bool inProcess() const override { @@ -93,8 +95,8 @@ void tst_Runtime::factory() QVERIFY(rf.get() == RuntimeFactory::instance()); QVERIFY(rf->runtimeIds().isEmpty()); - QVERIFY(rf->registerRuntime(new TestRuntimeManager(qSL("foo"), qApp))); - QVERIFY(rf->runtimeIds() == QStringList() << qSL("foo")); + QVERIFY(rf->registerRuntime(new TestRuntimeManager(u"foo"_s, qApp))); + QVERIFY(rf->runtimeIds() == QStringList() << u"foo"_s); QVERIFY(!rf->create(nullptr, nullptr)); diff --git a/tests/auto/signature/tst_signature.cpp b/tests/auto/signature/tst_signature.cpp index 67ccc867..babfd3a4 100644 --- a/tests/auto/signature/tst_signature.cpp +++ b/tests/auto/signature/tst_signature.cpp @@ -10,6 +10,8 @@ #include "signature.h" #include "cryptography.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Signature : public QObject @@ -43,17 +45,17 @@ tst_Signature::tst_Signature() void tst_Signature::initTestCase() { - QFile s(qSL(":/signing.p12")); + QFile s(u":/signing.p12"_s); QVERIFY(s.open(QIODevice::ReadOnly)); m_signingP12 = s.readAll(); QVERIFY(!m_signingP12.isEmpty()); - QFile snk(qSL(":/signing-no-key.p12")); + QFile snk(u":/signing-no-key.p12"_s); QVERIFY(snk.open(QIODevice::ReadOnly)); m_signingNoKeyP12 = snk.readAll(); QVERIFY(!m_signingNoKeyP12.isEmpty()); - QFile v(qSL(":/verifying.crt")); + QFile v(u":/verifying.crt"_s); QVERIFY(v.open(QIODevice::ReadOnly)); m_verifyingPEM << v.readAll(); QVERIFY(!m_verifyingPEM.first().isEmpty()); @@ -80,35 +82,35 @@ void tst_Signature::check() QVERIFY(!s2.verify(signature, m_verifyingPEM)); QVERIFY(s.create(m_signingP12, m_signingPassword + "not").isEmpty()); - QVERIFY2(s.errorString().contains(qSL("not parse")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not parse"_s), qPrintable(s.errorString())); QVERIFY(s.create(QByteArray(), m_signingPassword).isEmpty()); - QVERIFY2(s.errorString().contains(qSL("not read")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not read"_s), qPrintable(s.errorString())); Signature s3(QByteArray(4096, 'x')); QVERIFY(!s3.create(m_signingP12, m_signingPassword).isEmpty()); QVERIFY(!s.verify(signature, QList<QByteArray>())); - QVERIFY2(s.errorString().contains(qSL("Failed to verify")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"Failed to verify"_s), qPrintable(s.errorString())); QVERIFY(!s.verify(signature, QList<QByteArray>() << m_signingP12)); - QVERIFY2(s.errorString().contains(qSL("not load")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not load"_s), qPrintable(s.errorString())); QVERIFY(!s.verify(hash, QList<QByteArray>() << m_signingP12)); - QVERIFY2(s.errorString().contains(qSL("not read")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not read"_s), qPrintable(s.errorString())); Signature s4 { QByteArray() }; QVERIFY(s4.create(m_signingP12, m_signingPassword).isEmpty()); QVERIFY(s.create(m_signingNoKeyP12, m_signingPassword).isEmpty()); - QVERIFY2(s.errorString().contains(qSL("private key")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"private key"_s), qPrintable(s.errorString())); } void tst_Signature::crossPlatform() { QByteArray hash = "hello\nworld!"; - QFile fileOpenSsl(qSL(":/signature-openssl.p7")); - QFile fileWinCrypt(qSL(":/signature-wincrypt.p7")); - QFile fileSecurityFramework(qSL(":/signature-securityframework.p7")); + QFile fileOpenSsl(u":/signature-openssl.p7"_s); + QFile fileWinCrypt(u":/signature-wincrypt.p7"_s); + QFile fileSecurityFramework(u":/signature-securityframework.p7"_s); if (qEnvironmentVariableIsSet("AM_CREATE_SIGNATURE_FILE")) { QFile *nativeFile = nullptr; @@ -120,7 +122,7 @@ void tst_Signature::crossPlatform() nativeFile = &fileOpenSsl; #endif QVERIFY(nativeFile); - QFile f(qL1S(AM_TESTSOURCE_DIR "/../signature") + nativeFile->fileName().mid(1)); + QFile f(QString::fromLatin1(AM_TESTSOURCE_DIR "/../signature") + nativeFile->fileName().mid(1)); QVERIFY2(f.open(QFile::WriteOnly | QFile::Truncate), qPrintable(f.errorString())); Signature s(hash); diff --git a/tests/auto/systemreader/tst_systemreader.cpp b/tests/auto/systemreader/tst_systemreader.cpp index 2657c11d..7b56c55f 100644 --- a/tests/auto/systemreader/tst_systemreader.cpp +++ b/tests/auto/systemreader/tst_systemreader.cpp @@ -8,6 +8,8 @@ #include "systemreader.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_SystemReader : public QObject @@ -25,7 +27,7 @@ private slots: tst_SystemReader::tst_SystemReader() { - g_systemRootDir = qL1S(":/root"); + g_systemRootDir = u":/root"_s; } void tst_SystemReader::cgroupProcessInfo() @@ -36,14 +38,14 @@ void tst_SystemReader::cgroupProcessInfo() void tst_SystemReader::memoryReaderReadUsedValue() { - MemoryReader memoryReader(qSL("/system.slice/run-u5853.scope")); + MemoryReader memoryReader(u"/system.slice/run-u5853.scope"_s); quint64 value = memoryReader.readUsedValue(); QCOMPARE(value, Q_UINT64_C(66809856)); } void tst_SystemReader::memoryReaderGroupLimit() { - MemoryReader memoryReader(qSL("/system.slice/run-u5853.scope")); + MemoryReader memoryReader(u"/system.slice/run-u5853.scope"_s); quint64 value = memoryReader.groupLimit(); QCOMPARE(value, Q_UINT64_C(524288000)); } diff --git a/tests/auto/yaml/tst_yaml.cpp b/tests/auto/yaml/tst_yaml.cpp index 2c87c7c3..ae5e2cdb 100644 --- a/tests/auto/yaml/tst_yaml.cpp +++ b/tests/auto/yaml/tst_yaml.cpp @@ -12,6 +12,8 @@ #include "exception.h" #include "global.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Yaml : public QObject @@ -53,24 +55,24 @@ void tst_Yaml::parser() { "null-literal", vnull }, { "null-tilde", vnull }, { "null-empty", vnull }, - { "string-unquoted", QVariant::fromValue<QString>(qSL("unquoted")) }, - { "string-singlequoted", QVariant::fromValue<QString>(qSL("singlequoted")) }, - { "string-doublequoted", QVariant::fromValue<QString>(qSL("doublequoted")) }, + { "string-unquoted", QVariant::fromValue<QString>(u"unquoted"_s) }, + { "string-singlequoted", QVariant::fromValue<QString>(u"singlequoted"_s) }, + { "string-doublequoted", QVariant::fromValue<QString>(u"doublequoted"_s) }, { "list-int", QVariantList { 1, 2, 3 } }, - { "list-mixed", QVariantList { 1, qSL("two"), QVariantList { true, vnull } } }, - { "map1", QVariantMap { { qSL("a"), 1 }, { qSL("b"), qSL("two") }, - { qSL("c"), QVariantList { 1, 2, 3 } } } } + { "list-mixed", QVariantList { 1, u"two"_s, QVariantList { true, vnull } } }, + { "map1", QVariantMap { { u"a"_s, 1 }, { u"b"_s, u"two"_s }, + { u"c"_s, QVariantList { 1, 2, 3 } } } } }; try { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); YamlParser p(ba); auto header = p.parseHeader(); - QCOMPARE(header.first, qSL("testfile")); + QCOMPARE(header.first, u"testfile"_s); QCOMPARE(header.second, 42); QVERIFY(p.nextDocument()); @@ -114,20 +116,20 @@ void tst_Yaml::parser() QVERIFY(p->isScalar()); QVariant v = p->parseScalar(); QCOMPARE(v.metaType(), QMetaType::fromType<QString>()); - QCOMPARE(v.toString(), qSL("ext string")); + QCOMPARE(v.toString(), u"ext string"_s); } } }; p->parseFields(extFields); }); fields.emplace_back("stringlist-string", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList { qSL("string") }); + QCOMPARE(p->parseStringOrStringList(), QStringList { u"string"_s }); }); fields.emplace_back("stringlist-list1", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList { qSL("string") }); + QCOMPARE(p->parseStringOrStringList(), QStringList { u"string"_s }); }); fields.emplace_back("stringlist-list2", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList({ qSL("string1"), qSL("string2") })); + QCOMPARE(p->parseStringOrStringList(), QStringList({ u"string1"_s, u"string2"_s })); }); fields.emplace_back("list-of-maps", true, YamlParser::List, [](YamlParser *p) { @@ -159,48 +161,48 @@ void tst_Yaml::parser() static const QVariant vnull = QVariant::fromValue(nullptr); static const QVariantMap testHeaderDoc = { - { qSL("formatVersion"), 42 }, { qSL("formatType"), qSL("testfile") } + { u"formatVersion"_s, 42 }, { u"formatType"_s, u"testfile"_s } }; static const QVariantMap testMainDoc = { - { qSL("dec"), 10 }, - { qSL("hex"), 16 }, - { qSL("bin"), 2 }, - { qSL("oct"), 8 }, - { qSL("float1"), 10.1 }, - { qSL("float2"), .1 }, - { qSL("float3"), .1 }, - { qSL("number-separators"), 1234567 }, - { qSL("bool-true"), true }, - { qSL("bool-yes"), true }, - { qSL("bool-false"), false }, - { qSL("bool-no"), false }, - { qSL("null-literal"), vnull }, - { qSL("null-tilde"), vnull }, - { qSL("null-empty"), vnull }, - { qSL("string-unquoted"), qSL("unquoted") }, - { qSL("string-singlequoted"), qSL("singlequoted") }, - { qSL("string-doublequoted"), qSL("doublequoted") }, - { qSL("list-int"), QVariantList { 1, 2, 3 } }, - { qSL("list-mixed"), QVariantList { 1, qSL("two"), QVariantList { true, vnull } } }, - { qSL("map1"), QVariantMap { { qSL("a"), 1 }, { qSL("b"), qSL("two") }, - { qSL("c"), QVariantList { 1, 2, 3 } } } }, - - - { qSL("extended"), QVariantMap { { qSL("ext-string"), qSL("ext string") } } }, - - { qSL("stringlist-string"), qSL("string") }, - { qSL("stringlist-list1"), QVariantList { qSL("string") } }, - { qSL("stringlist-list2"), QVariantList { qSL("string1"), qSL("string2") } }, - - { qSL("list-of-maps"), QVariantList { QVariantMap { { qSL("index"), 1 }, { qSL("name"), qSL("1") } }, - QVariantMap { { qSL("index"), 2 }, { qSL("name"), qSL("2") } } } } + { u"dec"_s, 10 }, + { u"hex"_s, 16 }, + { u"bin"_s, 2 }, + { u"oct"_s, 8 }, + { u"float1"_s, 10.1 }, + { u"float2"_s, .1 }, + { u"float3"_s, .1 }, + { u"number-separators"_s, 1234567 }, + { u"bool-true"_s, true }, + { u"bool-yes"_s, true }, + { u"bool-false"_s, false }, + { u"bool-no"_s, false }, + { u"null-literal"_s, vnull }, + { u"null-tilde"_s, vnull }, + { u"null-empty"_s, vnull }, + { u"string-unquoted"_s, u"unquoted"_s }, + { u"string-singlequoted"_s, u"singlequoted"_s }, + { u"string-doublequoted"_s, u"doublequoted"_s }, + { u"list-int"_s, QVariantList { 1, 2, 3 } }, + { u"list-mixed"_s, QVariantList { 1, u"two"_s, QVariantList { true, vnull } } }, + { u"map1"_s, QVariantMap { { u"a"_s, 1 }, { u"b"_s, u"two"_s }, + { u"c"_s, QVariantList { 1, 2, 3 } } } }, + + + { u"extended"_s, QVariantMap { { u"ext-string"_s, u"ext string"_s } } }, + + { u"stringlist-string"_s, u"string"_s }, + { u"stringlist-list1"_s, QVariantList { u"string"_s } }, + { u"stringlist-list2"_s, QVariantList { u"string1"_s, u"string2"_s } }, + + { u"list-of-maps"_s, QVariantList { QVariantMap { { u"index"_s, 1 }, { u"name"_s, u"1"_s } }, + QVariantMap { { u"index"_s, 2 }, { u"name"_s, u"2"_s } } } } }; void tst_Yaml::documentParser() { try { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); @@ -253,7 +255,7 @@ public: void merge(CacheTest *ct1, const CacheTest *ct2) { ct1->name = ct2->name; - ct1->file = ct1->file + qSL(",") + ct2->file; + ct1->file = ct1->file + u","_s + ct2->file; ct1->value.append(ct2->value); } void preProcessSourceContent(QByteArray &sourceContent, const QString &fileName) @@ -264,11 +266,11 @@ public: void tst_Yaml::cache() { - QStringList files = { qSL(":/data/cache1.yaml"), qSL(":/data/cache2.yaml") }; + QStringList files = { u":/data/cache1.yaml"_s, u":/data/cache2.yaml"_s }; for (int step = 0; step < 2; ++step) { try { - ConfigCache<CacheTest> cache(files, qSL("cache-test"), { 'C','T','S','T' }, 1, + ConfigCache<CacheTest> cache(files, u"cache-test"_s, { 'C','T','S','T' }, 1, step == 0 ? AbstractConfigCache::ClearCache : AbstractConfigCache::None); cache.parse(); @@ -276,12 +278,12 @@ void tst_Yaml::cache() QVERIFY(cache.parseWroteToCache() == (step == 0)); CacheTest *ct1 = cache.takeResult(0); QVERIFY(ct1); - QCOMPARE(ct1->name, qSL("cache1")); - QCOMPARE(ct1->file, qSL(":/data/cache1.yaml")); + QCOMPARE(ct1->name, u"cache1"_s); + QCOMPARE(ct1->file, u":/data/cache1.yaml"_s); CacheTest *ct2 = cache.takeResult(1); QVERIFY(ct2); - QCOMPARE(ct2->name, qSL("cache2")); - QCOMPARE(ct2->file, qSL(":/data/cache2.yaml")); + QCOMPARE(ct2->name, u"cache2"_s); + QCOMPARE(ct2->file, u":/data/cache2.yaml"_s); delete ct1; delete ct2; @@ -290,41 +292,41 @@ void tst_Yaml::cache() } } - ConfigCache<CacheTest> wrongVersion(files, qSL("cache-test"), { 'C','T','S','T' }, 2, + ConfigCache<CacheTest> wrongVersion(files, u"cache-test"_s, { 'C','T','S','T' }, 2, AbstractConfigCache::None); QTest::ignoreMessage(QtWarningMsg, "Failed to read cache: failed to parse cache header"); wrongVersion.parse(); QVERIFY(!wrongVersion.parseReadFromCache()); - ConfigCache<CacheTest> wrongType(files, qSL("cache-test"), { 'X','T','S','T' }, 1, + ConfigCache<CacheTest> wrongType(files, u"cache-test"_s, { 'X','T','S','T' }, 1, AbstractConfigCache::None); QTest::ignoreMessage(QtWarningMsg, "Failed to read cache: failed to parse cache header"); wrongType.parse(); QVERIFY(!wrongType.parseReadFromCache()); - ConfigCache<CacheTest> duplicateCache({ qSL(":/cache1.yaml"), qSL(":/cache1.yaml") }, - qSL("cache-test"), { 'D','T','S','T' }, 1, + ConfigCache<CacheTest> duplicateCache({ u":/cache1.yaml"_s, u":/cache1.yaml"_s }, + u"cache-test"_s, { 'D','T','S','T' }, 1, AbstractConfigCache::None); try { duplicateCache.parse(); QVERIFY(false); } catch (const Exception &e) { - QVERIFY(e.errorString().contains(qSL("duplicate"))); + QVERIFY(e.errorString().contains(u"duplicate"_s)); } } void tst_Yaml::mergedCache() { // we need cache2 modifieable, so we copy it to a temp file - QTemporaryFile cache2File(qSL("cache2")); + QTemporaryFile cache2File(u"cache2"_s); QVERIFY(cache2File.open()); - QFile cache2Resource(qSL(":/data/cache2.yaml")); + QFile cache2Resource(u":/data/cache2.yaml"_s); QVERIFY(cache2Resource.open(QIODevice::ReadOnly)); QVERIFY(cache2File.write(cache2Resource.readAll()) > 0); QVERIFY(cache2File.flush()); const QString cache2FileName = QFileInfo(cache2File).absoluteFilePath(); - QStringList files = { qSL(":/data/cache1.yaml"), cache2FileName }; + QStringList files = { u":/data/cache1.yaml"_s, cache2FileName }; for (int step = 0; step < 4; ++step) { AbstractConfigCache::Options options = AbstractConfigCache::MergedResult; @@ -334,14 +336,14 @@ void tst_Yaml::mergedCache() std::reverse(files.begin(), files.end()); try { - ConfigCache<CacheTest> cache(files, qSL("cache-test"), { 'M','T','S','T' }, 1, options); + ConfigCache<CacheTest> cache(files, u"cache-test"_s, { 'M','T','S','T' }, 1, options); cache.parse(); QVERIFY(cache.parseReadFromCache() == (step % 2 == 1)); QVERIFY(cache.parseWroteToCache() == (step % 2 == 0)); CacheTest *ct = cache.takeMergedResult(); QVERIFY(ct); QCOMPARE(ct->name, QFileInfo(files.last()).baseName()); - QCOMPARE(ct->file, files.join(qSL(","))); + QCOMPARE(ct->file, files.join(u","_s)); delete ct; } catch (const Exception &e) { @@ -361,13 +363,13 @@ void tst_Yaml::mergedCache() QCOMPARE(cache2File.write(ba2), ba2.size()); QVERIFY(cache2File.flush()); - ConfigCache<CacheTest> brokenCache(files, qSL("cache-test"), { 'M','T','S','T' }, 1, + ConfigCache<CacheTest> brokenCache(files, u"cache-test"_s, { 'M','T','S','T' }, 1, AbstractConfigCache::MergedResult); QTest::ignoreMessage(QtWarningMsg, "Failed to read Cache: cached file checksums do not match"); brokenCache.parse(); QVERIFY(brokenCache.parseReadFromCache()); CacheTest *ct = brokenCache.takeMergedResult(); - QCOMPARE(ct->value, qSL("foobar")); + QCOMPARE(ct->value, u"foobar"_s); delete ct; } @@ -405,7 +407,7 @@ private: void tst_Yaml::parallel() { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); |