From 4146f1067905c3718b0504b510367bb4349b4622 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Tue, 19 Feb 2019 23:24:16 +0100 Subject: Add const-references for non trivial types in range-for loops This fixes -Wclazy-range-loop Change-Id: I5424d2626d6134ac7be2ce70b83f5a617f58dd7e Reviewed-by: Christian Kandeler --- tests/auto/blackbox/tst_blackbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 8154e7262..94f0d4b52 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -815,7 +815,7 @@ void TestBlackbox::changeTrackingAndMultiplexing() static QJsonObject findByName(const QJsonArray &objects, const QString &name) { - for (const QJsonValue v : objects) { + for (const QJsonValue &v : objects) { if (!v.isObject()) continue; QJsonObject obj = v.toObject(); @@ -5484,7 +5484,7 @@ void TestBlackbox::chooseModuleInstanceByPriority() QFile file(installRoot + "/gerbil.txt"); QVERIFY(file.open(QIODevice::ReadOnly)); const QString content = QString::fromUtf8(file.readAll()); - for (auto str : expectedSubStrings) { + for (const auto &str : expectedSubStrings) { if (content.contains(str)) continue; qDebug() << "content:" << content; -- cgit v1.2.3 From 1d479510cae797f875b53e6a3d11af94de675ab8 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Wed, 20 Feb 2019 09:39:09 +0100 Subject: Replace non-const calls to temporaries with const This fixes -Wclazy-detaching-temporary Change-Id: I3c866c29c05f16e93eb86551efb21ccf9dc120b9 Reviewed-by: Denis Shienkov Reviewed-by: Christian Kandeler --- tests/auto/blackbox/tst_blackbox.cpp | 2 +- tests/benchmarker/commandlineparser.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 94f0d4b52..e1f5026bd 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -135,7 +135,7 @@ QMap TestBlackbox::findTypeScript(int *status) QString TestBlackbox::findArchiver(const QString &fileName, int *status) { if (fileName == "jar") - return findJdkTools(status)[fileName]; + return findJdkTools(status).value(fileName); QString binary = findExecutable(QStringList(fileName)); if (binary.isEmpty()) { diff --git a/tests/benchmarker/commandlineparser.cpp b/tests/benchmarker/commandlineparser.cpp index 97b127d94..7c7e1a9c7 100644 --- a/tests/benchmarker/commandlineparser.cpp +++ b/tests/benchmarker/commandlineparser.cpp @@ -78,9 +78,9 @@ void CommandLineParser::parse() << oldCommitOption << newCommitOption << testProjectOption << qbsRepoOption; for (const QCommandLineOption &o : mandatoryOptions) { if (!parser.isSet(o)) - throwException(o.names().front(), parser.helpText()); + throwException(o.names().constFirst(), parser.helpText()); if (parser.value(o).isEmpty()) - throwException(o.names().front(), QString(), parser.helpText()); + throwException(o.names().constFirst(), QString(), parser.helpText()); } m_oldCommit = parser.value(oldCommitOption); m_newCommit = parser.value(newCommitOption); @@ -99,7 +99,9 @@ void CommandLineParser::parse() } else if (activityString == nullBuildActivity()) { m_activities |= ActivityNullBuild; } else { - throwException(activitiesOption.names().front(), activityString, parser.helpText()); + throwException(activitiesOption.names().constFirst(), + activityString, + parser.helpText()); } } m_regressionThreshold = 5; @@ -108,7 +110,9 @@ void CommandLineParser::parse() const QString rawThresholdValue = parser.value(thresholdOption); m_regressionThreshold = rawThresholdValue.toInt(&ok); if (!ok) - throwException(thresholdOption.names().first(), rawThresholdValue, parser.helpText()); + throwException(thresholdOption.names().constFirst(), + rawThresholdValue, + parser.helpText()); } } -- cgit v1.2.3 From 6615e52e4308962a7d10d606eead188fbfe198f3 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Tue, 19 Feb 2019 22:57:10 +0300 Subject: Use 'const auto' keywords more at objects allocations Change-Id: I592d433e7c473ae9f27ca08e701516efe53650ba Reviewed-by: Ivan Komissarov Reviewed-by: Christian Kandeler --- tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp | 2 +- .../blackbox/testdata-qt/trackAddMocInclude/after/main.cpp | 2 +- .../testdata-qt/trackAddMocInclude/before/main.cpp | 2 +- tests/auto/blackbox/testdata/enableRtti/main.cpp | 2 +- tests/auto/buildgraph/tst_buildgraph.cpp | 14 +++++++------- tests/auto/language/tst_language.cpp | 2 +- tests/auto/tools/tst_tools.cpp | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp b/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp index d6568d77c..0491719d7 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) scene.setSceneRect(-500, -500, 1000, 1000); scene.setItemIndexMethod(QGraphicsScene::NoIndex); - auto car = new Car(); + const auto car = new Car(); scene.addItem(car); QGraphicsView view(&scene); diff --git a/tests/auto/blackbox/testdata-qt/trackAddMocInclude/after/main.cpp b/tests/auto/blackbox/testdata-qt/trackAddMocInclude/after/main.cpp index 94b288440..aa63c20b3 100644 --- a/tests/auto/blackbox/testdata-qt/trackAddMocInclude/after/main.cpp +++ b/tests/auto/blackbox/testdata-qt/trackAddMocInclude/after/main.cpp @@ -41,7 +41,7 @@ public: int main(int argc, char **argv) { QCoreApplication app(argc, argv); - auto obj = new MyObject(&app); + const auto obj = new MyObject(&app); return app.exec(); } diff --git a/tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/main.cpp b/tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/main.cpp index 0d216e970..350c25f62 100644 --- a/tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/main.cpp +++ b/tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/main.cpp @@ -41,7 +41,7 @@ public: int main(int argc, char **argv) { QCoreApplication app(argc, argv); - auto obj = new MyObject(&app); + const auto obj = new MyObject(&app); return app.exec(); } diff --git a/tests/auto/blackbox/testdata/enableRtti/main.cpp b/tests/auto/blackbox/testdata/enableRtti/main.cpp index b7faa3d6b..4dcd5d2e8 100644 --- a/tests/auto/blackbox/testdata/enableRtti/main.cpp +++ b/tests/auto/blackbox/testdata/enableRtti/main.cpp @@ -47,7 +47,7 @@ class B : public I { }; int main() { - auto a = new A(); + const auto a = new A(); B *b = dynamic_cast(a); (void)b; delete a; diff --git a/tests/auto/buildgraph/tst_buildgraph.cpp b/tests/auto/buildgraph/tst_buildgraph.cpp index 626c1e9e7..95314ad20 100644 --- a/tests/auto/buildgraph/tst_buildgraph.cpp +++ b/tests/auto/buildgraph/tst_buildgraph.cpp @@ -85,9 +85,9 @@ ResolvedProductConstPtr TestBuildGraph::productWithDirectCycle() const ResolvedProductPtr product = ResolvedProduct::create(); product->project = project; product->buildData.reset(new ProductBuildData); - auto root = new Artifact; + const auto root = new Artifact; root->product = product; - auto child = new Artifact; + const auto child = new Artifact; child->product = product; product->buildData->addRootNode(root); product->buildData->addNode(root); @@ -102,9 +102,9 @@ ResolvedProductConstPtr TestBuildGraph::productWithLessDirectCycle() const ResolvedProductPtr product = ResolvedProduct::create(); product->project = project; product->buildData.reset(new ProductBuildData); - auto root = new Artifact; - auto child = new Artifact; - auto grandchild = new Artifact; + const auto root = new Artifact; + const auto child = new Artifact; + const auto grandchild = new Artifact; root->product = product; child->product = product; grandchild->product = product; @@ -124,8 +124,8 @@ ResolvedProductConstPtr TestBuildGraph::productWithNoCycle() const ResolvedProductPtr product = ResolvedProduct::create(); product->project = project; product->buildData.reset(new ProductBuildData); - auto root = new Artifact; - auto root2 = new Artifact; + const auto root = new Artifact; + const auto root2 = new Artifact; root->product = product; root2->product = product; product->buildData->addRootNode(root); diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index 6b5cc2447..9a7071f3b 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -1567,7 +1567,7 @@ public: { JSSourceValuePtr value = JSSourceValue::create(); value->setFile(m_fileContext); - auto str = new QString(sourceCode); + const auto str = new QString(sourceCode); m_strings.push_back(str); value->setSourceCode(QStringRef(str)); return value; diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 0073f9e68..33cb95a78 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -319,7 +319,7 @@ void TestTools::testSettingsMigration_data() QString TestTools::setupSettingsDir1() { - auto baseDir = new QTemporaryDir; + const auto baseDir = new QTemporaryDir; m_tmpDirs.push_back(baseDir); const Version thisVersion = Version::fromString(QBS_VERSION); @@ -362,7 +362,7 @@ QString TestTools::setupSettingsDir1() QString TestTools::setupSettingsDir2() { - auto baseDir = new QTemporaryDir; + const auto baseDir = new QTemporaryDir; m_tmpDirs.push_back(baseDir); const QString settingsDir = baseDir->path(); QSettings s(settingsDir + QLatin1String("/qbs.conf"), @@ -378,7 +378,7 @@ QString TestTools::setupSettingsDir2() QString TestTools::setupSettingsDir3() { - auto baseDir = new QTemporaryDir; + const auto baseDir = new QTemporaryDir; m_tmpDirs.push_back(baseDir); return baseDir->path(); } -- cgit v1.2.3 From e160b26d8c7476c63f6220ac69d1d6405e8ce3aa Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Wed, 20 Feb 2019 13:38:24 +0300 Subject: Replace 'typedef' with 'using' where it is possible One exception is that the 'typedef' for function pointers were skipped due to an additional work is required. Change-Id: I2112fded3abeaee1d1f49f56adfd2914d5db0324 Reviewed-by: Christian Kandeler --- tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp | 4 ++-- tests/benchmarker/benchmarker.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp b/tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp index 535d6d63f..7311f2d60 100644 --- a/tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp +++ b/tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp @@ -32,13 +32,13 @@ #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include #include -typedef QGuiApplication Application; +using Application = QGuiApplication; #define AH_SO_THIS_IS_QT5 #else #include #include #define AH_SO_THIS_IS_QT4 -typedef QApplication Application; +using Application = QApplication; #endif int main(int argc, char *argv[]) diff --git a/tests/benchmarker/benchmarker.h b/tests/benchmarker/benchmarker.h index 7027c9d15..9b6d5a157 100644 --- a/tests/benchmarker/benchmarker.h +++ b/tests/benchmarker/benchmarker.h @@ -48,7 +48,7 @@ public: qint64 oldPeakMemoryUsage; qint64 newPeakMemoryUsage; }; -typedef QHash BenchmarkResults; +using BenchmarkResults = QHash; class Benchmarker { -- cgit v1.2.3 From 0876dc4d6abb147ccdcc190adfad01c704a73e61 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Tue, 19 Feb 2019 22:16:04 +0300 Subject: Use QStringLiteral more where it is possible Change-Id: I7419cc3fbc1e8776de3943852dcedab4c95d1c32 Reviewed-by: Anton Kudryavtsev Reviewed-by: Christian Kandeler --- tests/auto/api/tst_api.cpp | 10 +-- .../blackbox/testdata-qt/plugin-meta-data/app.cpp | 6 +- tests/auto/blackbox/tst_blackbox.cpp | 98 +++++++++++----------- tests/auto/blackbox/tst_blackboxandroid.cpp | 4 +- tests/auto/blackbox/tst_blackboxbase.cpp | 4 +- tests/auto/language/tst_language.cpp | 44 +++++----- tests/auto/tools/tst_tools.cpp | 40 ++++----- tests/benchmarker/benchmarker.cpp | 2 +- tests/benchmarker/commandlineparser.cpp | 6 +- tests/benchmarker/runsupport.cpp | 8 +- tests/benchmarker/valgrindrunner.cpp | 18 ++-- tests/fuzzy-test/commandlineparser.cpp | 14 ++-- tests/fuzzy-test/fuzzytester.cpp | 24 +++--- 13 files changed, 139 insertions(+), 139 deletions(-) (limited to 'tests') diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 228b0e078..58150150a 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -1372,7 +1372,7 @@ void TestApi::generatedFilesList() const QStringList directParents = project.generatedFiles(product, uiFilePath, false); QCOMPARE(directParents.size(), 1); const QFileInfo uiHeaderFileInfo(directParents.front()); - QCOMPARE(uiHeaderFileInfo.fileName(), QLatin1String("ui_mainwindow.h")); + QCOMPARE(uiHeaderFileInfo.fileName(), QStringLiteral("ui_mainwindow.h")); QVERIFY(!uiHeaderFileInfo.exists()); const QStringList allParents = project.generatedFiles(product, uiFilePath, true); QCOMPARE(allParents.size(), 3); @@ -1448,7 +1448,7 @@ void TestApi::installableFiles() { qbs::SetupProjectParameters setupParams = defaultSetupParameters("installed-artifact"); QVariantMap overriddenValues; - overriddenValues.insert(QLatin1String("qbs.installRoot"), QLatin1String("/tmp")); + overriddenValues.insert(QStringLiteral("qbs.installRoot"), QStringLiteral("/tmp")); setupParams.setOverriddenValues(overriddenValues); std::unique_ptr job(qbs::Project().setupProject(setupParams, m_logSink, 0)); @@ -1471,7 +1471,7 @@ void TestApi::installableFiles() if (!QFileInfo(f.filePath()).fileName().startsWith("main")) { QVERIFY(f.isExecutable()); QString expectedTargetFilePath = qbs::Internal::HostOsInfo - ::appendExecutableSuffix(QLatin1String("/tmp/usr/bin/installedApp")); + ::appendExecutableSuffix(QStringLiteral("/tmp/usr/bin/installedApp")); QCOMPARE(f.installData().localInstallFilePath(), expectedTargetFilePath); QCOMPARE(product.targetExecutable(), expectedTargetFilePath); break; @@ -1872,7 +1872,7 @@ void TestApi::multiArch() // Error check: Try to build for the same profile twice, this time attaching // the properties via the product name. - overriddenValues.remove(QLatin1String("project.targetProfile")); + overriddenValues.remove(QStringLiteral("project.targetProfile")); overriddenValues.insert("products.p1.myProfiles", targetProfile.name() + ',' + targetProfile.name()); setupParams.setOverriddenValues(overriddenValues); @@ -2185,7 +2185,7 @@ void TestApi::nonexistingProjectPropertyFromCommandLine() = defaultSetupParameters("nonexistingprojectproperties"); removeBuildDir(setupParams); QVariantMap projectProperties; - projectProperties.insert(QLatin1String("project.blubb"), QLatin1String("true")); + projectProperties.insert(QStringLiteral("project.blubb"), QStringLiteral("true")); setupParams.setOverriddenValues(projectProperties); std::unique_ptr job(qbs::Project().setupProject(setupParams, m_logSink, 0)); diff --git a/tests/auto/blackbox/testdata-qt/plugin-meta-data/app.cpp b/tests/auto/blackbox/testdata-qt/plugin-meta-data/app.cpp index 8f2aec87d..c57504e9e 100644 --- a/tests/auto/blackbox/testdata-qt/plugin-meta-data/app.cpp +++ b/tests/auto/blackbox/testdata-qt/plugin-meta-data/app.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) #endif if (metaData.isEmpty()) metaData = QPluginLoader("thePlugin").metaData(); - const QJsonValue v = metaData.value(QLatin1String("theKey")); + const QJsonValue v = metaData.value(QStringLiteral("theKey")); if (!v.isArray()) { qDebug() << "value is" << v; return 1; @@ -72,8 +72,8 @@ int main(int argc, char *argv[]) qDebug() << "value is" << v; return 1; } - const QJsonValue v2 = metaData.value(QLatin1String("MetaData")).toObject() - .value(QLatin1String("theOtherKey")); + const QJsonValue v2 = metaData.value(QStringLiteral("MetaData")).toObject() + .value(QStringLiteral("theOtherKey")); if (v2.toString() != QLatin1String("theOtherValue")) { qDebug() << "metadata:" << metaData; return 1; diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index e1f5026bd..d8c2d2c82 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -819,7 +819,7 @@ static QJsonObject findByName(const QJsonArray &objects, const QString &name) if (!v.isObject()) continue; QJsonObject obj = v.toObject(); - const QString objName = obj.value(QLatin1String("name")).toString(); + const QString objName = obj.value(QStringLiteral("name")).toString(); if (objName == name) return obj; } @@ -850,14 +850,14 @@ void TestBlackbox::dependenciesProperty() QJsonArray dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 2); QJsonObject product2 = findByName(dependencies, QStringLiteral("product2")); - QJsonArray product2_type = product2.value(QLatin1String("type")).toArray(); + QJsonArray product2_type = product2.value(QStringLiteral("type")).toArray(); QCOMPARE(product2_type.size(), 1); QCOMPARE(product2_type.first().toString(), QLatin1String("application")); QCOMPARE(product2.value(QLatin1String("narf")).toString(), QLatin1String("zort")); QJsonArray product2_cppArtifacts = product2.value("artifacts").toObject().value("cpp").toArray(); QCOMPARE(product2_cppArtifacts.size(), 1); - QJsonArray product2_deps = product2.value(QLatin1String("dependencies")).toArray(); + QJsonArray product2_deps = product2.value(QStringLiteral("dependencies")).toArray(); QVERIFY(!product2_deps.empty()); QJsonObject product2_qbs = findByName(product2_deps, QStringLiteral("qbs")); QVERIFY(!product2_qbs.empty()); @@ -918,9 +918,9 @@ void TestBlackbox::dependenciesProperty() dependencies = jsondoc.array(); QCOMPARE(dependencies.size(), 3); product2 = findByName(dependencies, QStringLiteral("product2")); - product2_deps = product2.value(QLatin1String("dependencies")).toArray(); + product2_deps = product2.value(QStringLiteral("dependencies")).toArray(); product2_cpp = findByName(product2_deps, QStringLiteral("cpp")); - product2_cpp_defines = product2_cpp.value(QLatin1String("defines")).toArray(); + product2_cpp_defines = product2_cpp.value(QStringLiteral("defines")).toArray(); QCOMPARE(product2_cpp_defines.size(), 1); QCOMPARE(product2_cpp_defines.first().toString(), QLatin1String("DIGEDAG")); } @@ -1532,7 +1532,7 @@ void TestBlackbox::clean() QCOMPARE(runQbs(), 0); QVERIFY(regularFileExists(appObjectFilePath)); QVERIFY(regularFileExists(appExeFilePath)); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"))), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("clean"))), 0); QVERIFY(!QFile(appObjectFilePath).exists()); QVERIFY(!QFile(appExeFilePath).exists()); QVERIFY(!QFile(depObjectFilePath).exists()); @@ -1563,7 +1563,7 @@ void TestBlackbox::clean() QCOMPARE(runQbs(), 0); QVERIFY(regularFileExists(appObjectFilePath)); QVERIFY(regularFileExists(appExeFilePath)); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"), QStringList("-n"))), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("clean"), QStringList("-n"))), 0); QVERIFY(regularFileExists(appObjectFilePath)); QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(regularFileExists(depObjectFilePath)); @@ -1577,7 +1577,7 @@ void TestBlackbox::clean() QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(regularFileExists(depObjectFilePath)); QVERIFY(regularFileExists(depLibFilePath)); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"), QStringList("-p") << "dep")), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("clean"), QStringList("-p") << "dep")), 0); QVERIFY(regularFileExists(appObjectFilePath)); QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(!QFile(depObjectFilePath).exists()); @@ -1591,7 +1591,7 @@ void TestBlackbox::clean() QVERIFY(regularFileExists(appExeFilePath)); QVERIFY(regularFileExists(depObjectFilePath)); QVERIFY(regularFileExists(depLibFilePath)); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("clean"), QStringList("-p") << "app")), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("clean"), QStringList("-p") << "app")), 0); QVERIFY(!QFile(appObjectFilePath).exists()); QVERIFY(!QFile(appExeFilePath).exists()); QVERIFY(regularFileExists(depObjectFilePath)); @@ -2042,7 +2042,7 @@ void TestBlackbox::trackRemoveFile() QFile::copy("../before/main.cpp", "main.cpp"); QVERIFY(QFile::remove("zort.h")); QVERIFY(QFile::remove("zort.cpp")); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("resolve"))), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("resolve"))), 0); touch("main.cpp"); touch("trackAddFile.qbs"); @@ -2184,7 +2184,7 @@ void TestBlackbox::wildcardRenaming() QVERIFY(QFileInfo(defaultInstallRoot + "/pioniere.txt").exists()); WAIT_FOR_NEW_TIMESTAMP(); QFile::rename(QDir::currentPath() + "/pioniere.txt", QDir::currentPath() + "/fdj.txt"); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"), + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("install"), QStringList("--clean-install-root"))), 0); QVERIFY(!QFileInfo(defaultInstallRoot + "/pioniere.txt").exists()); QVERIFY(QFileInfo(defaultInstallRoot + "/fdj.txt").exists()); @@ -2198,7 +2198,7 @@ void TestBlackbox::recursiveRenaming() QVERIFY(QFileInfo(defaultInstallRoot + "/dir/subdir/blubb.txt").exists()); WAIT_FOR_NEW_TIMESTAMP(); QVERIFY(QFile::rename(QDir::currentPath() + "/dir/wasser.txt", QDir::currentPath() + "/dir/wein.txt")); - QCOMPARE(runQbs(QbsRunParameters(QLatin1String("install"), + QCOMPARE(runQbs(QbsRunParameters(QStringLiteral("install"), QStringList("--clean-install-root"))), 0); QVERIFY(!QFileInfo(defaultInstallRoot + "/dir/wasser.txt").exists()); QVERIFY(QFileInfo(defaultInstallRoot + "/dir/wein.txt").exists()); @@ -2679,25 +2679,25 @@ void TestBlackbox::overrideProjectProperties() { QDir::setCurrent(testDataDir + "/overrideProjectProperties"); QCOMPARE(runQbs(QbsRunParameters(QStringList() - << QLatin1String("-f") - << QLatin1String("overrideProjectProperties.qbs") - << QLatin1String("project.nameSuffix:ForYou") - << QLatin1String("project.someBool:false") - << QLatin1String("project.someInt:156") - << QLatin1String("project.someStringList:one") - << QLatin1String("products.MyAppForYou.mainFile:main.cpp"))), + << QStringLiteral("-f") + << QStringLiteral("overrideProjectProperties.qbs") + << QStringLiteral("project.nameSuffix:ForYou") + << QStringLiteral("project.someBool:false") + << QStringLiteral("project.someInt:156") + << QStringLiteral("project.someStringList:one") + << QStringLiteral("products.MyAppForYou.mainFile:main.cpp"))), 0); QVERIFY(regularFileExists(relativeExecutableFilePath("MyAppForYou"))); QVERIFY(QFile::remove(relativeBuildGraphFilePath())); QbsRunParameters params; - params.arguments << QLatin1String("-f") << QLatin1String("project_using_helper_lib.qbs"); + params.arguments << QStringLiteral("-f") << QStringLiteral("project_using_helper_lib.qbs"); params.expectFailure = true; QVERIFY(runQbs(params) != 0); rmDirR(relativeBuildDir()); - params.arguments = QStringList() << QLatin1String("-f") - << QLatin1String("project_using_helper_lib.qbs") - << QLatin1String("project.linkSuccessfully:true"); + params.arguments = QStringList() << QStringLiteral("-f") + << QStringLiteral("project_using_helper_lib.qbs") + << QStringLiteral("project.linkSuccessfully:true"); params.expectFailure = false; QCOMPARE(runQbs(params), 0); } @@ -2968,8 +2968,8 @@ void TestBlackbox::probesAndShadowProducts() void TestBlackbox::probeInExportedModule() { QDir::setCurrent(testDataDir + "/probe-in-exported-module"); - QCOMPARE(runQbs(QbsRunParameters(QStringList() << QLatin1String("-f") - << QLatin1String("probe-in-exported-module.qbs"))), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringList() << QStringLiteral("-f") + << QStringLiteral("probe-in-exported-module.qbs"))), 0); QVERIFY2(m_qbsStdout.contains("found: true"), m_qbsStdout.constData()); QVERIFY2(m_qbsStdout.contains("prop: yes"), m_qbsStdout.constData()); QVERIFY2(m_qbsStdout.contains("listProp: my,myother"), m_qbsStdout.constData()); @@ -2989,8 +2989,8 @@ void TestBlackbox::probesAndArrayProperties() void TestBlackbox::productProperties() { QDir::setCurrent(testDataDir + "/productproperties"); - QCOMPARE(runQbs(QbsRunParameters(QStringList() << QLatin1String("-f") - << QLatin1String("productproperties.qbs"))), 0); + QCOMPARE(runQbs(QbsRunParameters(QStringList() << QStringLiteral("-f") + << QStringLiteral("productproperties.qbs"))), 0); QVERIFY(regularFileExists(relativeExecutableFilePath("blubb_user"))); } @@ -5069,7 +5069,7 @@ void TestBlackbox::properQuoting() { QDir::setCurrent(testDataDir + "/proper quoting"); QCOMPARE(runQbs(), 0); - QbsRunParameters params(QLatin1String("run"), QStringList() << "-q" << "-p" << "Hello World"); + QbsRunParameters params(QStringLiteral("run"), QStringList() << "-q" << "-p" << "Hello World"); params.expectFailure = true; // Because the exit code is non-zero. QCOMPARE(runQbs(params), 156); const char * const expectedOutput = "whitespaceless\ncontains space\ncontains\ttab\n" @@ -5318,7 +5318,7 @@ void TestBlackbox::installedApp() QCOMPARE(runQbs(), 0); QVERIFY(regularFileExists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QStringLiteral("/usr/bin/installedApp")))); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("qbs.installRoot:" + testDataDir + "/installed-app"))), 0); @@ -5333,7 +5333,7 @@ void TestBlackbox::installedApp() QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); QCOMPARE(runQbs(QbsRunParameters(QStringList() << "--clean-install-root")), 0); QVERIFY(regularFileExists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QStringLiteral("/usr/bin/installedApp")))); QVERIFY(regularFileExists(defaultInstallRoot + QLatin1String("/usr/src/main.cpp"))); QVERIFY(!addedFile.exists()); @@ -5343,7 +5343,7 @@ void TestBlackbox::installedApp() "qbs.installPrefix: '/usr/local'"); QCOMPARE(runQbs(), 0); QVERIFY(regularFileExists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/local/bin/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QStringLiteral("/usr/local/bin/installedApp")))); QVERIFY(regularFileExists(defaultInstallRoot + QLatin1String("/usr/local/src/main.cpp"))); // Check whether changing install parameters on the artifact causes re-installation. @@ -5352,7 +5352,7 @@ void TestBlackbox::installedApp() "qbs.installDir: 'custom'"); QCOMPARE(runQbs(), 0); QVERIFY(regularFileExists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/local/custom/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QStringLiteral("/usr/local/custom/installedApp")))); // Check whether changing install parameters on a source file causes re-installation. WAIT_FOR_NEW_TIMESTAMP(); @@ -5410,7 +5410,7 @@ void TestBlackbox::installedSourceFiles() void TestBlackbox::toolLookup() { - QbsRunParameters params(QLatin1String("setup-toolchains"), QStringList("--help")); + QbsRunParameters params(QStringLiteral("setup-toolchains"), QStringList("--help")); params.profile.clear(); QCOMPARE(runQbs(params), 0); } @@ -5514,13 +5514,13 @@ public: TemporaryDefaultProfileRemover(qbs::Settings *settings) : m_settings(settings), m_defaultProfile(settings->defaultProfile()) { - m_settings->remove(QLatin1String("defaultProfile")); + m_settings->remove(QStringLiteral("defaultProfile")); } ~TemporaryDefaultProfileRemover() { if (!m_defaultProfile.isEmpty()) - m_settings->setValue(QLatin1String("defaultProfile"), m_defaultProfile); + m_settings->setValue(QStringLiteral("defaultProfile"), m_defaultProfile); } private: @@ -5680,15 +5680,15 @@ void TestBlackbox::explicitlyDependsOn_data() static bool haveMakeNsis() { QStringList regKeys; - regKeys << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS") - << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS"); + regKeys << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS") + << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS"); QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); for (const QString &key : qAsConst(regKeys)) { QSettings settings(key, QSettings::NativeFormat); - QString str = settings.value(QLatin1String(".")).toString(); + QString str = settings.value(QStringLiteral(".")).toString(); if (!str.isEmpty()) paths.prepend(str); } @@ -5696,7 +5696,7 @@ static bool haveMakeNsis() bool haveMakeNsis = false; for (const QString &path : qAsConst(paths)) { if (regularFileExists(QDir::fromNativeSeparators(path) + - HostOsInfo::appendExecutableSuffix(QLatin1String("/makensis")))) { + HostOsInfo::appendExecutableSuffix(QStringLiteral("/makensis")))) { haveMakeNsis = true; break; } @@ -5904,8 +5904,8 @@ static bool haveWiX(const Profile &profile) } QStringList regKeys; - regKeys << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML\\") - << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML\\"); + regKeys << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML\\") + << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML\\"); QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); @@ -5914,7 +5914,7 @@ static bool haveWiX(const Profile &profile) const QStringList versions = QSettings(key, QSettings::NativeFormat).childGroups(); for (const QString &version : versions) { QSettings settings(key + version, QSettings::NativeFormat); - QString str = settings.value(QLatin1String("InstallRoot")).toString(); + QString str = settings.value(QStringLiteral("InstallRoot")).toString(); if (!str.isEmpty()) paths.prepend(str); } @@ -5922,9 +5922,9 @@ static bool haveWiX(const Profile &profile) for (const QString &path : qAsConst(paths)) { if (regularFileExists(QDir::fromNativeSeparators(path) + - HostOsInfo::appendExecutableSuffix(QLatin1String("/candle"))) && + HostOsInfo::appendExecutableSuffix(QStringLiteral("/candle"))) && regularFileExists(QDir::fromNativeSeparators(path) + - HostOsInfo::appendExecutableSuffix(QLatin1String("/light")))) { + HostOsInfo::appendExecutableSuffix(QStringLiteral("/light")))) { return true; } } @@ -6043,7 +6043,7 @@ void TestBlackbox::typescript() QCOMPARE(status, 0); params.expectFailure = false; - params.command = QLatin1String("run"); + params.command = QStringLiteral("run"); params.arguments = QStringList() << "-p" << "animals"; QCOMPARE(runQbs(params), 0); @@ -6093,22 +6093,22 @@ static bool haveInnoSetup(const Profile &profile) return true; QStringList regKeys; - regKeys << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1") - << QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1"); + regKeys << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1") + << QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1"); QStringList paths = QProcessEnvironment::systemEnvironment().value("PATH") .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); for (const QString &key : regKeys) { QSettings settings(key, QSettings::NativeFormat); - QString str = settings.value(QLatin1String("InstallLocation")).toString(); + QString str = settings.value(QStringLiteral("InstallLocation")).toString(); if (!str.isEmpty()) paths.prepend(str); } for (const QString &path : paths) { if (regularFileExists(QDir::fromNativeSeparators(path) + - HostOsInfo::appendExecutableSuffix(QLatin1String("/ISCC")))) + HostOsInfo::appendExecutableSuffix(QStringLiteral("/ISCC")))) return true; } diff --git a/tests/auto/blackbox/tst_blackboxandroid.cpp b/tests/auto/blackbox/tst_blackboxandroid.cpp index bf47c241c..e02f70213 100644 --- a/tests/auto/blackbox/tst_blackboxandroid.cpp +++ b/tests/auto/blackbox/tst_blackboxandroid.cpp @@ -192,7 +192,7 @@ void TestBlackboxAndroid::android_data() const SettingsPtr s = settings(); const Profile p(profileName(), s.get()); const Profile pQt(theProfileName(true), s.get()); - QStringList archsStringList = p.value(QLatin1String("qbs.architectures")).toStringList(); + QStringList archsStringList = p.value(QStringLiteral("qbs.architectures")).toStringList(); if (archsStringList.empty()) archsStringList << QStringLiteral("armv7a"); // must match default in common.qbs QByteArrayList archs; @@ -203,7 +203,7 @@ void TestBlackboxAndroid::android_data() .replace("arm64", "arm64-v8a"); }); const auto cxxLibPath = [&p, &pQt](const QByteArray &oldcxxLib, bool forQt) { - const bool usesClang = (forQt ? pQt : p).value(QLatin1String("qbs.toolchainType")) + const bool usesClang = (forQt ? pQt : p).value(QStringLiteral("qbs.toolchainType")) .toString() == "clang"; return QByteArray("lib/${ARCH}/") + (usesClang ? "libc++_shared.so" : oldcxxLib); }; diff --git a/tests/auto/blackbox/tst_blackboxbase.cpp b/tests/auto/blackbox/tst_blackboxbase.cpp index e1844b69c..85bc26ba4 100644 --- a/tests/auto/blackbox/tst_blackboxbase.cpp +++ b/tests/auto/blackbox/tst_blackboxbase.cpp @@ -79,9 +79,9 @@ int TestBlackboxBase::runQbs(const QbsRunParameters ¶ms) if (!params.settingsDir.isEmpty() && supportsSettingsDirOption(params.command)) args << "--settings-dir" << params.settingsDir; if (supportsBuildDirectoryOption(params.command)) { - args.push_back(QLatin1String("-d")); + args.push_back(QStringLiteral("-d")); args.push_back(params.buildDirectory.isEmpty() - ? QLatin1String(".") + ? QStringLiteral(".") : params.buildDirectory); } args << params.arguments; diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index 9a7071f3b..31aebfa3a 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -79,8 +79,8 @@ using namespace qbs; using namespace qbs::Internal; static QString testDataDir() { - return FileInfo::resolvePath(QLatin1String(SRCDIR), - QLatin1String("../../../tests/auto/language/testdata")); + return FileInfo::resolvePath(QStringLiteral(SRCDIR), + QStringLiteral("../../../tests/auto/language/testdata")); } static QString testProject(const char *fileName) { return testDataDir() + QLatin1Char('/') + QLatin1String(fileName); @@ -180,7 +180,7 @@ void TestLanguage::initTestCase() m_engine = ScriptEngine::create(m_logger, EvalContext::PropertyEvaluation, this); loader = new Loader(m_engine, m_logger); loader->setSearchPaths(QStringList() - << QLatin1String(SRCDIR "/../../../share/qbs")); + << QStringLiteral(SRCDIR "/../../../share/qbs")); defaultParameters.setTopLevelProfile(profileName()); defaultParameters.setConfigurationName("default"); defaultParameters.expandBuildConfiguration(); @@ -343,7 +343,7 @@ void TestLanguage::canonicalArchitecture() project = loader->loadProject(defaultParameters); QVERIFY(!!project); QHash products = productsFromProject(project); - ResolvedProductPtr product = products.value(QLatin1String("x86")); + ResolvedProductPtr product = products.value(QStringLiteral("x86")); QVERIFY(!!product); } catch (const ErrorInfo &e) { exceptionCaught = true; @@ -360,7 +360,7 @@ void TestLanguage::rfc1034Identifier() project = loader->loadProject(defaultParameters); QVERIFY(!!project); QHash products = productsFromProject(project); - ResolvedProductPtr product = products.value(QLatin1String("this-has-special-characters-" + ResolvedProductPtr product = products.value(QStringLiteral("this-has-special-characters-" "uh-oh-Undersc0r3s-Are.Bad")); QVERIFY(!!product); } catch (const ErrorInfo &e) { @@ -753,7 +753,7 @@ void TestLanguage::environmentVariable() bool exceptionCaught = false; try { // Create new environment: - const QString varName = QLatin1String("PRODUCT_NAME"); + const QString varName = QStringLiteral("PRODUCT_NAME"); const QString productName = QLatin1String("MyApp") + QString::number(qrand()); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(varName, productName); @@ -1161,11 +1161,11 @@ void TestLanguage::getNativeSetting() QString expectedTargetName; if (HostOsInfo::isMacosHost()) - expectedTargetName = QLatin1String("Mac OS X"); + expectedTargetName = QStringLiteral("Mac OS X"); else if (HostOsInfo::isWindowsHost()) - expectedTargetName = QLatin1String("Windows"); + expectedTargetName = QStringLiteral("Windows"); else - expectedTargetName = QLatin1String("Unix"); + expectedTargetName = QStringLiteral("Unix"); QVERIFY(!!project); QHash products; @@ -1173,7 +1173,7 @@ void TestLanguage::getNativeSetting() products.insert(product->targetName, product); ResolvedProductPtr product = products.value(expectedTargetName); QVERIFY(!!product); - ResolvedProductPtr product2 = products.value(QLatin1String("fallback")); + ResolvedProductPtr product2 = products.value(QStringLiteral("fallback")); QVERIFY(!!product2); } catch (const ErrorInfo &e) { exceptionCaught = true; @@ -1288,11 +1288,11 @@ void TestLanguage::homeDirectory() dir.filePath("a")); QCOMPARE(product->productProperties.value("bogus1").toString(), - FileInfo::resolvePath(product->sourceDirectory, QLatin1String("a~b"))); + FileInfo::resolvePath(product->sourceDirectory, QStringLiteral("a~b"))); QCOMPARE(product->productProperties.value("bogus2").toString(), - FileInfo::resolvePath(product->sourceDirectory, QLatin1String("a/~/bb"))); + FileInfo::resolvePath(product->sourceDirectory, QStringLiteral("a/~/bb"))); QCOMPARE(product->productProperties.value("user").toString(), - FileInfo::resolvePath(product->sourceDirectory, QLatin1String("~foo/bar"))); + FileInfo::resolvePath(product->sourceDirectory, QStringLiteral("~foo/bar"))); } catch (const ErrorInfo &e) { qDebug() << e.toString(); @@ -1650,7 +1650,7 @@ void TestLanguage::jsImportUsedInMultipleScopes() try { SetupProjectParameters params = defaultParameters; params.setProjectFilePath(testProject("jsimportsinmultiplescopes.qbs")); - params.setOverriddenValues({std::make_pair(QLatin1String("qbs.buildVariant"), + params.setOverriddenValues({std::make_pair(QStringLiteral("qbs.buildVariant"), buildVariant)}); params.expandBuildConfiguration(); TopLevelProjectPtr project = loader->loadProject(params); @@ -1703,7 +1703,7 @@ void TestLanguage::modulePrioritizationBySearchPath() try { SetupProjectParameters params = defaultParameters; params.setProjectFilePath(testProject("module-prioritization-by-search-path/project.qbs")); - params.setOverriddenValues({std::make_pair(QLatin1String("project.qbsSearchPaths"), + params.setOverriddenValues({std::make_pair(QStringLiteral("project.qbsSearchPaths"), searchPaths)}); params.expandBuildConfiguration(); TopLevelProjectPtr project = loader->loadProject(params); @@ -2398,9 +2398,9 @@ void TestLanguage::pathProperties() QStringList() << "dummy" << "includePaths").toStringList(); QCOMPARE(includePaths, QStringList() << projectFileDir); QCOMPARE(productProps.value("base_fileInProductDir").toString(), - FileInfo::resolvePath(projectFileDir, QLatin1String("foo"))); + FileInfo::resolvePath(projectFileDir, QStringLiteral("foo"))); QCOMPARE(productProps.value("base_fileInBaseProductDir").toString(), - FileInfo::resolvePath(projectFileDir, QLatin1String("subdir/bar"))); + FileInfo::resolvePath(projectFileDir, QStringLiteral("subdir/bar"))); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -2412,7 +2412,7 @@ void TestLanguage::profileValuesAndOverriddenValues() { bool exceptionCaught = false; try { - TemporaryProfile tp(QLatin1String("tst_lang_profile"), m_settings); + TemporaryProfile tp(QStringLiteral("tst_lang_profile"), m_settings); Profile profile = tp.p; profile.setValue("dummy.defines", "IN_PROFILE"); profile.setValue("dummy.cFlags", "IN_PROFILE"); @@ -2435,7 +2435,7 @@ void TestLanguage::profileValuesAndOverriddenValues() QCOMPARE(values.length(), 1); QCOMPARE(values.front().toString(), QString("IN_PROFILE")); values = product->moduleProperties->moduleProperty("dummy", "defines").toList(); - QCOMPARE(values, QVariantList() << QLatin1String("IN_FILE") << QLatin1String("IN_PROFILE")); + QCOMPARE(values, QVariantList() << QStringLiteral("IN_FILE") << QStringLiteral("IN_PROFILE")); values = product->moduleProperties->moduleProperty("dummy", "cFlags").toList(); QCOMPARE(values.length(), 1); QCOMPARE(values.front().toString(), QString("OVERRIDDEN")); @@ -2536,9 +2536,9 @@ void TestLanguage::productDirectories() product = products.value("MyApp"); QVERIFY(!!product); const QVariantMap config = product->productProperties; - QCOMPARE(config.value(QLatin1String("buildDirectory")).toString(), + QCOMPARE(config.value(QStringLiteral("buildDirectory")).toString(), product->buildDirectory()); - QCOMPARE(config.value(QLatin1String("sourceDirectory")).toString(), testDataDir()); + QCOMPARE(config.value(QStringLiteral("sourceDirectory")).toString(), testDataDir()); } catch (const ErrorInfo &e) { exceptionCaught = true; @@ -2911,7 +2911,7 @@ void TestLanguage::throwingProbe() SetupProjectParameters params = defaultParameters; params.setProjectFilePath(testProject("throwing-probe.qbs")); QVariantMap properties; - properties.insert(QLatin1String("products.theProduct.enableProbe"), enableProbe); + properties.insert(QStringLiteral("products.theProduct.enableProbe"), enableProbe); params.setOverriddenValues(properties); const TopLevelProjectPtr project = loader->loadProject(params); QVERIFY(!!project); diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 33cb95a78..da40a2dc6 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -387,37 +387,37 @@ void TestTools::testBuildConfigMerging() { TemporaryProfile tp(QLatin1String("tst_tools_profile"), m_settings); Profile profile = tp.p; - profile.setValue(QLatin1String("topLevelKey"), QLatin1String("topLevelValue")); - profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc")); - profile.setValue(QLatin1String("qbs.architecture"), - QLatin1String("Jean-Claude Pillemann")); - profile.setValue(QLatin1String("cpp.treatWarningsAsErrors"), true); + profile.setValue(QStringLiteral("topLevelKey"), QStringLiteral("topLevelValue")); + profile.setValue(QStringLiteral("qbs.toolchain"), QStringLiteral("gcc")); + profile.setValue(QStringLiteral("qbs.architecture"), + QStringLiteral("Jean-Claude Pillemann")); + profile.setValue(QStringLiteral("cpp.treatWarningsAsErrors"), true); QVariantMap overrideMap; - overrideMap.insert(QLatin1String("qbs.toolchain"), QLatin1String("clang")); - overrideMap.insert(QLatin1String("qbs.installRoot"), QLatin1String("/blubb")); + overrideMap.insert(QStringLiteral("qbs.toolchain"), QStringLiteral("clang")); + overrideMap.insert(QStringLiteral("qbs.installRoot"), QStringLiteral("/blubb")); SetupProjectParameters params; params.setSettingsDirectory(m_settings->baseDirectory()); params.setTopLevelProfile(profile.name()); - params.setConfigurationName(QLatin1String("debug")); + params.setConfigurationName(QStringLiteral("debug")); params.setOverriddenValues(overrideMap); const ErrorInfo error = params.expandBuildConfiguration(); QVERIFY2(!error.hasError(), qPrintable(error.toString())); const QVariantMap finalMap = params.finalBuildConfigurationTree(); QCOMPARE(finalMap.size(), 3); - QCOMPARE(finalMap.value(QLatin1String("topLevelKey")).toString(), - QString::fromLatin1("topLevelValue")); - const QVariantMap finalQbsMap = finalMap.value(QLatin1String("qbs")).toMap(); + QCOMPARE(finalMap.value(QStringLiteral("topLevelKey")).toString(), + QStringLiteral("topLevelValue")); + const QVariantMap finalQbsMap = finalMap.value(QStringLiteral("qbs")).toMap(); QCOMPARE(finalQbsMap.size(), 4); - QCOMPARE(finalQbsMap.value(QLatin1String("toolchain")).toString(), - QString::fromLatin1("clang")); - QCOMPARE(finalQbsMap.value(QLatin1String("configurationName")).toString(), - QString::fromLatin1("debug")); - QCOMPARE(finalQbsMap.value(QLatin1String("architecture")).toString(), - QString::fromLatin1("Jean-Claude Pillemann")); - QCOMPARE(finalQbsMap.value(QLatin1String("installRoot")).toString(), QLatin1String("/blubb")); - const QVariantMap finalCppMap = finalMap.value(QLatin1String("cpp")).toMap(); + QCOMPARE(finalQbsMap.value(QStringLiteral("toolchain")).toString(), + QStringLiteral("clang")); + QCOMPARE(finalQbsMap.value(QStringLiteral("configurationName")).toString(), + QStringLiteral("debug")); + QCOMPARE(finalQbsMap.value(QStringLiteral("architecture")).toString(), + QStringLiteral("Jean-Claude Pillemann")); + QCOMPARE(finalQbsMap.value(QStringLiteral("installRoot")).toString(), QLatin1String("/blubb")); + const QVariantMap finalCppMap = finalMap.value(QStringLiteral("cpp")).toMap(); QCOMPARE(finalCppMap.size(), 1); - QCOMPARE(finalCppMap.value(QLatin1String("treatWarningsAsErrors")).toBool(), true); + QCOMPARE(finalCppMap.value(QStringLiteral("treatWarningsAsErrors")).toBool(), true); } void TestTools::testProcessNameByPid() diff --git a/tests/benchmarker/benchmarker.cpp b/tests/benchmarker/benchmarker.cpp index 050eb97a7..5ecdbf08b 100644 --- a/tests/benchmarker/benchmarker.cpp +++ b/tests/benchmarker/benchmarker.cpp @@ -116,7 +116,7 @@ void Benchmarker::rememberCurrentRepoState() void Benchmarker::buildQbs(const QString &buildDir) const { if (!QDir::root().mkpath(buildDir)) - throw Exception(QString::fromLatin1("Failed to create directory '%1'.").arg(buildDir)); + throw Exception(QStringLiteral("Failed to create directory '%1'.").arg(buildDir)); runProcess(QStringList() << "qmake" << "CONFIG+=force_debug_info" << (m_qbsRepo + "/qbs.pro"), buildDir); runProcess(QStringList() << "make" << "-s", buildDir); diff --git a/tests/benchmarker/commandlineparser.cpp b/tests/benchmarker/commandlineparser.cpp index 7c7e1a9c7..4e5052453 100644 --- a/tests/benchmarker/commandlineparser.cpp +++ b/tests/benchmarker/commandlineparser.cpp @@ -64,7 +64,7 @@ void CommandLineParser::parse() "repo path"); parser.addOption(qbsRepoOption); QCommandLineOption activitiesOption(QStringList{"activities", "a"}, - QString::fromLatin1("The activities to benchmark. Possible values (CSV): %1,%2,%3,%4") + QStringLiteral("The activities to benchmark. Possible values (CSV): %1,%2,%3,%4") .arg(resolveActivity(), ruleExecutionActivity(), nullBuildActivity(), allActivities()), "activities", allActivities()); parser.addOption(activitiesOption); @@ -119,14 +119,14 @@ void CommandLineParser::parse() void CommandLineParser::throwException(const QString &optionName, const QString &illegalValue, const QString &helpText) { - const QString errorText(QString::fromLatin1("Error parsing command line: Illegal value '%1' " + const QString errorText(QStringLiteral("Error parsing command line: Illegal value '%1' " "for option '--%2'.\n%3").arg(illegalValue, optionName, helpText)); throw Exception(errorText); } void CommandLineParser::throwException(const QString &missingOption, const QString &helpText) { - const QString errorText(QString::fromLatin1("Error parsing command line: Missing mandatory " + const QString errorText(QStringLiteral("Error parsing command line: Missing mandatory " "option '--%1'.\n%3").arg(missingOption, helpText)); throw Exception(errorText); } diff --git a/tests/benchmarker/runsupport.cpp b/tests/benchmarker/runsupport.cpp index e01200067..3f8f46470 100644 --- a/tests/benchmarker/runsupport.cpp +++ b/tests/benchmarker/runsupport.cpp @@ -46,20 +46,20 @@ void runProcess(const QStringList &commandLine, const QString &workingDir, QByte p.setWorkingDirectory(workingDir); p.start(command, args); if (!p.waitForStarted()) - throw Exception(QString::fromLatin1("Process '%1' failed to start.").arg(command)); + throw Exception(QStringLiteral("Process '%1' failed to start.").arg(command)); p.waitForFinished(-1); if (p.exitStatus() != QProcess::NormalExit) { - throw Exception(QString::fromLatin1("Error running '%1': %2") + throw Exception(QStringLiteral("Error running '%1': %2") .arg(command, p.errorString())); } if (exitCode) *exitCode = p.exitCode(); if (p.exitCode() != 0) { - QString errorString = QString::fromLatin1("Command '%1' finished with exit code %2.") + QString errorString = QStringLiteral("Command '%1' finished with exit code %2.") .arg(command).arg(p.exitCode()); const QByteArray stdErr = p.readAllStandardError(); if (!stdErr.isEmpty()) { - errorString += QString::fromLatin1("\nStandard error output was: '%1'") + errorString += QStringLiteral("\nStandard error output was: '%1'") .arg(QString::fromLocal8Bit(stdErr)); } throw Exception(errorString); diff --git a/tests/benchmarker/valgrindrunner.cpp b/tests/benchmarker/valgrindrunner.cpp index 399216226..0441e1b10 100644 --- a/tests/benchmarker/valgrindrunner.cpp +++ b/tests/benchmarker/valgrindrunner.cpp @@ -51,7 +51,7 @@ ValgrindRunner::ValgrindRunner(Activities activities, const QString &testProject , m_baseOutputDir(baseOutputDir) { if (!QDir::root().mkpath(m_baseOutputDir)) - throw Exception(QString::fromLatin1("Failed to create directory '%1'.").arg(baseOutputDir)); + throw Exception(QStringLiteral("Failed to create directory '%1'.").arg(baseOutputDir)); } void ValgrindRunner::run() @@ -163,7 +163,7 @@ qint64 ValgrindRunner::runCallgrind(const QString &qbsCommand, const QString &bu runProcess(valgrindCommandLine(qbsCommand, buildDir, dryRun, "callgrind", outFile)); QFile f(outFile); if (!f.open(QIODevice::ReadOnly)) { - throw Exception(QString::fromLatin1("Failed to open file '%1': %2") + throw Exception(QStringLiteral("Failed to open file '%1': %2") .arg(outFile, f.errorString())); } while (!f.atEnd()) { @@ -175,14 +175,14 @@ qint64 ValgrindRunner::runCallgrind(const QString &qbsCommand, const QString &bu bool ok; const qint64 iCount = icString.toLongLong(&ok); if (!ok) { - throw Exception(QString::fromLatin1("Unexpected line in callgrind output file " + throw Exception(QStringLiteral("Unexpected line in callgrind output file " "'%1': '%2'.") .arg(outFile, QString::fromLocal8Bit(line))); } return iCount; } - throw Exception(QString::fromLatin1("Failed to find summary line in callgrind " + throw Exception(QStringLiteral("Failed to find summary line in callgrind " "output file '%1'.").arg(outFile)); } @@ -195,7 +195,7 @@ qint64 ValgrindRunner::runMassif(const QString &qbsCommand, const QString &build QBuffer buffer(&ms_printOutput); buffer.open(QIODevice::ReadOnly); QByteArray peakSnapshot; - const QString exceptionStringPattern = QString::fromLatin1("Failed to extract peak memory " + const QString exceptionStringPattern = QStringLiteral("Failed to extract peak memory " "usage from file '%1': %2").arg(outFile); while (!buffer.atEnd()) { const QByteArray line = buffer.readLine(); @@ -207,7 +207,7 @@ qint64 ValgrindRunner::runMassif(const QString &qbsCommand, const QString &build if (delimiterOffset == -1) delimiterOffset = line.lastIndexOf('[', magicStringOffset); if (delimiterOffset == -1) { - const QString details = QString::fromLatin1("Failed to extract peak snapshot from " + const QString details = QStringLiteral("Failed to extract peak snapshot from " "line '%1'.").arg(QString::fromLocal8Bit(line)); throw Exception(exceptionStringPattern.arg(details)); } @@ -222,7 +222,7 @@ qint64 ValgrindRunner::runMassif(const QString &qbsCommand, const QString &build continue; const QList entries = line.split(' '); if (entries.size() != 6) { - const QString details = QString::fromLatin1("Expected 6 entries in line '%1', but " + const QString details = QStringLiteral("Expected 6 entries in line '%1', but " "there are %2.").arg(QString::fromLocal8Bit(line)).arg(entries.size()); throw Exception(exceptionStringPattern.arg(details)); } @@ -231,14 +231,14 @@ qint64 ValgrindRunner::runMassif(const QString &qbsCommand, const QString &build bool ok; qint64 peakMemoryUsage = peakMemoryString.toLongLong(&ok); if (!ok) { - const QString details = QString::fromLatin1("Failed to parse peak memory value '%1' " + const QString details = QStringLiteral("Failed to parse peak memory value '%1' " "as a number.").arg(QString::fromLocal8Bit(peakMemoryString)); throw Exception(exceptionStringPattern.arg(details)); } return peakMemoryUsage; } - const QString details = QString::fromLatin1("Failed to find snapshot '%1'.") + const QString details = QStringLiteral("Failed to find snapshot '%1'.") .arg(QString::fromLocal8Bit(peakSnapshot)); throw Exception(exceptionStringPattern.arg(details)); } diff --git a/tests/fuzzy-test/commandlineparser.cpp b/tests/fuzzy-test/commandlineparser.cpp index 86f498dec..18515604b 100644 --- a/tests/fuzzy-test/commandlineparser.cpp +++ b/tests/fuzzy-test/commandlineparser.cpp @@ -64,7 +64,7 @@ void CommandLineParser::parse(const QStringList &commandLine) else if (arg == logOption()) m_log = true; else - throw ParseException(QString::fromLatin1("Unknown parameter '%1'").arg(arg)); + throw ParseException(QStringLiteral("Unknown parameter '%1'").arg(arg)); } if (m_profile.isEmpty()) throw ParseException("No profile given."); @@ -74,7 +74,7 @@ void CommandLineParser::parse(const QStringList &commandLine) QString CommandLineParser::usageString() const { - return QString::fromLatin1("%1 %2 %3 [%4 ] " + return QStringLiteral("%1 %2 %3 [%4 ] " "[%5 ] [%6]") .arg(QFileInfo(m_command).fileName(), profileOption(), startCommitOption(), maxDurationoption(), jobCountOption(), logOption()); @@ -83,10 +83,10 @@ QString CommandLineParser::usageString() const void CommandLineParser::assignOptionArgument(const QString &option, QString &argument) { if (m_commandLine.empty()) - throw ParseException(QString::fromLatin1("Option '%1' needs an argument.").arg(option)); + throw ParseException(QStringLiteral("Option '%1' needs an argument.").arg(option)); argument = m_commandLine.takeFirst(); if (argument.isEmpty()) { - throw ParseException(QString::fromLatin1("Argument for option '%1' must not be empty.") + throw ParseException(QStringLiteral("Argument for option '%1' must not be empty.") .arg(option)); } } @@ -98,7 +98,7 @@ void CommandLineParser::assignOptionArgument(const QString &option, int &argumen bool ok; argument = numberString.toInt(&ok); if (!ok || argument <= 0) { - throw ParseException(QString::fromLatin1("Invalid argument '%1' for option '%2'.") + throw ParseException(QStringLiteral("Invalid argument '%1' for option '%2'.") .arg(numberString, option)); } } @@ -116,7 +116,7 @@ void CommandLineParser::parseDuration() bool ok; m_maxDuration = choppedDurationString.toInt(&ok); if (!ok || m_maxDuration <= 0) { - throw ParseException(QString::fromLatin1("Invalid duration argument '%1'.") + throw ParseException(QStringLiteral("Invalid duration argument '%1'.") .arg(durationString)); } if (hasSuffix) { @@ -125,7 +125,7 @@ void CommandLineParser::parseDuration() case 'd': m_maxDuration *= 24; // Fall-through. case 'h': m_maxDuration *= 60; break; default: - throw ParseException(QString::fromLatin1("Invalid duration suffix '%1'.") + throw ParseException(QStringLiteral("Invalid duration suffix '%1'.") .arg(suffix)); } } diff --git a/tests/fuzzy-test/fuzzytester.cpp b/tests/fuzzy-test/fuzzytester.cpp index 37a6c56fe..b836ee623 100644 --- a/tests/fuzzy-test/fuzzytester.cpp +++ b/tests/fuzzy-test/fuzzytester.cpp @@ -100,10 +100,10 @@ void FuzzyTester::runTest(const QString &profile, const QString &startCommit, // for errors, as information from change tracking has to be serialized correctly. QString qbsError; m_currentActivity = resolveIncrementalActivity(); - bool success = runQbs(defaultBuildDir(), QLatin1String("resolve"), &qbsError); + bool success = runQbs(defaultBuildDir(), QStringLiteral("resolve"), &qbsError); if (success) { m_currentActivity = buildIncrementalActivity(); - success = runQbs(defaultBuildDir(), QLatin1String("build"), &qbsError); + success = runQbs(defaultBuildDir(), QStringLiteral("build"), &qbsError); } m_currentActivity = buildFromScratchActivity(); if (success) { @@ -111,7 +111,7 @@ void FuzzyTester::runTest(const QString &profile, const QString &startCommit, QString message = "An incremental build succeeded " "with a commit for which a clean build failed."; if (!m_log) { - message += QString::fromLatin1("\nThe qbs error message " + message += QStringLiteral("\nThe qbs error message " "for the clean build was: '%1'").arg(qbsError); } throwIncrementalBuildError(message, buildSequence); @@ -122,7 +122,7 @@ void FuzzyTester::runTest(const QString &profile, const QString &startCommit, QString message = "An incremental build failed " "with a commit for which a clean build succeeded."; if (!m_log) { - message += QString::fromLatin1("\nThe qbs error message for " + message += QStringLiteral("\nThe qbs error message for " "the incremental build was: '%1'").arg(qbsError); } throwIncrementalBuildError(message, buildSequence); @@ -166,14 +166,14 @@ QString FuzzyTester::findWorkingStartCommit(const QString &startCommit) } checkoutCommit(m_currentCommit); removeDir(defaultBuildDir()); - if (runQbs(defaultBuildDir(), QLatin1String("build"), &qbsError)) { + if (runQbs(defaultBuildDir(), QStringLiteral("build"), &qbsError)) { m_buildableCommits << m_currentCommit; return m_currentCommit; } qDebug("Commit %s is not buildable.", qPrintable(m_currentCommit)); m_unbuildableCommits << m_currentCommit; } - throw TestError(QString::fromLatin1("Cannot run test: Failed to find a single commit that " + throw TestError(QStringLiteral("Cannot run test: Failed to find a single commit that " "builds successfully with qbs. The last qbs error was: '%1'").arg(qbsError)); } @@ -184,9 +184,9 @@ void FuzzyTester::runGit(const QStringList &arguments, QString *output) if (!git.waitForStarted()) throw TestError("Failed to start git. It is expected to be in the PATH."); if (!git.waitForFinished(300000) || git.exitStatus() != QProcess::NormalExit) // 5 minutes ought to be enough for everyone - throw TestError(QString::fromLatin1("git failed: %1").arg(git.errorString())); + throw TestError(QStringLiteral("git failed: %1").arg(git.errorString())); if (git.exitCode() != 0) { - throw TestError(QString::fromLatin1("git failed: %1") + throw TestError(QStringLiteral("git failed: %1") .arg(QString::fromLocal8Bit(git.readAllStandardError()))); } if (output) @@ -222,7 +222,7 @@ bool FuzzyTester::runQbs(const QString &buildDir, const QString &command, QStrin commandLine << ("profile:" + m_profile); qbs.start("qbs", commandLine); if (!qbs.waitForStarted()) { - throw TestError(QString::fromLatin1("Failed to start qbs. It is expected to be " + throw TestError(QStringLiteral("Failed to start qbs. It is expected to be " "in the PATH. QProcess error string: '%1'").arg(qbs.errorString())); } if (!qbs.waitForFinished(-1) || qbs.exitCode() != 0) { @@ -237,7 +237,7 @@ void FuzzyTester::removeDir(const QString &dirPath) { QDir dir(dirPath); if (!dir.removeRecursively()) { - throw TestError(QString::fromLatin1("Failed to remove temporary dir '%1'.") + throw TestError(QStringLiteral("Failed to remove temporary dir '%1'.") .arg(dir.absolutePath())); } } @@ -254,7 +254,7 @@ bool FuzzyTester::doCleanBuild(QString *errorMessage) } const QString cleanBuildDir = "fuzzytest-verification-build"; removeDir(cleanBuildDir); - if (runQbs(cleanBuildDir, QLatin1String("build"), errorMessage)) { + if (runQbs(cleanBuildDir, QStringLiteral("build"), errorMessage)) { m_buildableCommits << m_currentCommit; return true; } @@ -266,7 +266,7 @@ void FuzzyTester::throwIncrementalBuildError(const QString &message, const QStringList &commitSequence) { const QString commitSequenceString = commitSequence.join(QLatin1Char(',')); - throw TestError(QString::fromLatin1("Found qbs bug with incremental build!\n" + throw TestError(QStringLiteral("Found qbs bug with incremental build!\n" "%1\n" "The sequence of commits was: %2.").arg(message, commitSequenceString)); } -- cgit v1.2.3 From 4fd17d627106fde01284075038e15cc0680611bc Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Tue, 26 Feb 2019 14:38:54 +0300 Subject: Return initializer list where it is possible This fixes this clang-tidy warning: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] Change-Id: I421e1e47462fe0e97788672684d47943af7df850 Reviewed-by: Christian Kandeler --- .../blackbox/testdata-qt/dbus-adaptors/car.cpp | 2 +- tests/auto/blackbox/tst_blackbox.cpp | 28 +++++++++------------- tests/auto/blackbox/tst_blackboxandroid.cpp | 4 ++-- tests/auto/blackbox/tst_blackboxapple.cpp | 2 +- tests/auto/blackbox/tst_blackboxbase.cpp | 6 ++--- tests/auto/blackbox/tst_blackboxjava.cpp | 4 ++-- 6 files changed, 20 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp b/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp index 466ed4b8e..5e4f348d2 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp @@ -56,7 +56,7 @@ static const double Pi = 3.14159265358979323846264338327950288419717; QRectF Car::boundingRect() const { - return QRectF(-35, -81, 70, 115); + return {-35, -81, 70, 115}; } Car::Car() : color(Qt::green), wheelsAngle(0), speed(0) diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index d8c2d2c82..8dd79528b 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -89,11 +89,9 @@ QMap TestBlackbox::findCli(int *status) *status = res; QFile file(temp.path() + "/" + relativeProductBuildDir("find-cli") + "/cli.json"); if (!file.open(QIODevice::ReadOnly)) - return QMap { }; + return {}; const auto tools = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); - return QMap { - {"path", QDir::fromNativeSeparators(tools["path"].toString())}, - }; + return {{"path", QDir::fromNativeSeparators(tools["path"].toString())}}; } QMap TestBlackbox::findNodejs(int *status) @@ -107,11 +105,9 @@ QMap TestBlackbox::findNodejs(int *status) *status = res; QFile file(temp.path() + "/" + relativeProductBuildDir("find-nodejs") + "/nodejs.json"); if (!file.open(QIODevice::ReadOnly)) - return QMap { }; + return {}; const auto tools = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); - return QMap { - {"node", QDir::fromNativeSeparators(tools["node"].toString())} - }; + return {{"node", QDir::fromNativeSeparators(tools["node"].toString())}}; } QMap TestBlackbox::findTypeScript(int *status) @@ -125,11 +121,9 @@ QMap TestBlackbox::findTypeScript(int *status) *status = res; QFile file(temp.path() + "/" + relativeProductBuildDir("find-typescript") + "/typescript.json"); if (!file.open(QIODevice::ReadOnly)) - return QMap { }; + return {}; const auto tools = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); - return QMap { - {"tsc", QDir::fromNativeSeparators(tools["tsc"].toString())} - }; + return {{"tsc", QDir::fromNativeSeparators(tools["tsc"].toString())}}; } QString TestBlackbox::findArchiver(const QString &fileName, int *status) @@ -823,7 +817,7 @@ static QJsonObject findByName(const QJsonArray &objects, const QString &name) if (objName == name) return obj; } - return QJsonObject(); + return {}; } static void readDepsOutput(const QString &depsFilePath, QJsonDocument &jsonDocument) @@ -2546,16 +2540,16 @@ static QString soName(const QString &readElfPath, const QString &libFilePath) readElf.start(readElfPath, QStringList() << "-a" << libFilePath); if (!readElf.waitForStarted() || !readElf.waitForFinished() || readElf.exitCode() != 0) { qDebug() << readElf.errorString() << readElf.readAllStandardError(); - return QString(); + return {}; } const QByteArray output = readElf.readAllStandardOutput(); const QByteArray magicString = "Library soname: ["; const int magicStringIndex = output.indexOf(magicString); if (magicStringIndex == -1) - return QString(); + return {}; const int endIndex = output.indexOf(']', magicStringIndex); if (endIndex == -1) - return QString(); + return {}; const int nameIndex = magicStringIndex + magicString.size(); const QByteArray theName = output.mid(nameIndex, endIndex - nameIndex); return QString::fromLatin1(theName); @@ -5537,7 +5531,7 @@ void TestBlackbox::assembly() QFile propertiesFile(relativeProductBuildDir("assembly") + "/properties.json"); if (propertiesFile.open(QIODevice::ReadOnly)) return QJsonDocument::fromJson(propertiesFile.readAll()).toVariant().toMap(); - return QVariantMap(); + return QVariantMap{}; })(); QVERIFY(!properties.empty()); const auto toolchain = properties.value("qbs.toolchain").toStringList(); diff --git a/tests/auto/blackbox/tst_blackboxandroid.cpp b/tests/auto/blackbox/tst_blackboxandroid.cpp index e02f70213..caf7cf0bc 100644 --- a/tests/auto/blackbox/tst_blackboxandroid.cpp +++ b/tests/auto/blackbox/tst_blackboxandroid.cpp @@ -53,9 +53,9 @@ QMap TestBlackboxAndroid::findAndroid(int *status, const QStri QFile file(temp.path() + "/" + relativeProductBuildDir("find-android") + "/android.json"); if (!file.open(QIODevice::ReadOnly)) - return QMap { }; + return {}; const auto tools = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); - return QMap { + return { {"sdk", QDir::fromNativeSeparators(tools["sdk"].toString())}, {"sdk-build-tools-dx", QDir::fromNativeSeparators(tools["sdk-build-tools-dx"].toString())}, {"ndk", QDir::fromNativeSeparators(tools["ndk"].toString())}, diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index 0cb4d5abb..7cbc07b95 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -784,7 +784,7 @@ QVariantMap TestBlackboxApple::findXcode(int *status) QFile file(temp.path() + "/" + relativeProductBuildDir("find-xcode") + "/xcode.json"); if (!file.open(QIODevice::ReadOnly)) - return QVariantMap { }; + return {}; return QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); } diff --git a/tests/auto/blackbox/tst_blackboxbase.cpp b/tests/auto/blackbox/tst_blackboxbase.cpp index 85bc26ba4..61b0271f6 100644 --- a/tests/auto/blackbox/tst_blackboxbase.cpp +++ b/tests/auto/blackbox/tst_blackboxbase.cpp @@ -210,7 +210,7 @@ QString TestBlackboxBase::findExecutable(const QStringList &fileNames) return QDir::cleanPath(fullPath); } } - return QString(); + return {}; } QMap TestBlackboxBase::findJdkTools(int *status) @@ -224,9 +224,9 @@ QMap TestBlackboxBase::findJdkTools(int *status) *status = res; QFile file(temp.path() + "/" + relativeProductBuildDir("find-jdk") + "/jdk.json"); if (!file.open(QIODevice::ReadOnly)) - return QMap { }; + return {}; const auto tools = QJsonDocument::fromJson(file.readAll()).toVariant().toMap(); - return QMap { + return { {"java", QDir::fromNativeSeparators(tools["java"].toString())}, {"javac", QDir::fromNativeSeparators(tools["javac"].toString())}, {"jar", QDir::fromNativeSeparators(tools["jar"].toString())} diff --git a/tests/auto/blackbox/tst_blackboxjava.cpp b/tests/auto/blackbox/tst_blackboxjava.cpp index 0ea3c41ce..f7feb0612 100644 --- a/tests/auto/blackbox/tst_blackboxjava.cpp +++ b/tests/auto/blackbox/tst_blackboxjava.cpp @@ -134,7 +134,7 @@ static QString dpkgArch(const QString &prefix = QString()) dpkg.waitForFinished(); if (dpkg.exitStatus() == QProcess::NormalExit && dpkg.exitCode() == 0) return prefix + QString::fromLocal8Bit(dpkg.readAllStandardOutput().trimmed()); - return QString(); + return {}; } void TestBlackboxJava::javaDependencyTracking() @@ -191,7 +191,7 @@ void TestBlackboxJava::javaDependencyTracking_data() } } - return QString(); + return {}; }; static const auto knownJdkVersions = QStringList() << "1.6" << "1.7" << "1.8" << "1.9" -- cgit v1.2.3 From 50eb4d183ccb526874cefe73c7f4c2129769aa4a Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 18 Feb 2019 17:38:37 +0100 Subject: Android: Check for valid package name upon package creation That's nicer than letting users get a cryptic error message when they try to install their package on the device. Change-Id: Ie5321a28475f879f991c4440c7e64c1c3ebd5a9d Fixes: QBS-1428 Reviewed-by: Joerg Bornemann --- .../minimal-native/minimal-native.qbs | 2 ++ .../src/main/java/minimal/MinimalNative.java | 22 ---------------------- .../src/main/java/my/minimal/MinimalNative.java | 22 ++++++++++++++++++++++ .../blackbox/testdata-android/qml-app/qml-app.qbs | 2 ++ 4 files changed, 26 insertions(+), 22 deletions(-) delete mode 100644 tests/auto/blackbox/testdata-android/minimal-native/src/main/java/minimal/MinimalNative.java create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/src/main/java/my/minimal/MinimalNative.java (limited to 'tests') diff --git a/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs b/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs index 8cdda7a3c..570152707 100644 --- a/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs +++ b/tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs @@ -2,6 +2,8 @@ CppApplication { name: "minimalnative" qbs.buildVariant: "release" Properties { condition: qbs.toolchain.contains("clang"); Android.ndk.appStl: "c++_shared" } + Android.sdk.packageName: "my.minimalnative" + Android.sdk.apkBaseName: name Android.ndk.appStl: "stlport_shared" files: "src/main/native/native.c" Group { diff --git a/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/minimal/MinimalNative.java b/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/minimal/MinimalNative.java deleted file mode 100644 index 1464d2593..000000000 --- a/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/minimal/MinimalNative.java +++ /dev/null @@ -1,22 +0,0 @@ -package minimalnative; - -import android.app.Activity; -import android.widget.TextView; -import android.os.Bundle; - -public class MinimalNative extends Activity -{ - @Override - public void onCreate(Bundle savedInstanceState) - { - TextView tv = new TextView(this); - tv.setText(stringFromNative()); - setContentView(tv); - } - - public native String stringFromNative(); - - static { - System.loadLibrary("minimal"); - } -} diff --git a/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/my/minimal/MinimalNative.java b/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/my/minimal/MinimalNative.java new file mode 100644 index 000000000..1464d2593 --- /dev/null +++ b/tests/auto/blackbox/testdata-android/minimal-native/src/main/java/my/minimal/MinimalNative.java @@ -0,0 +1,22 @@ +package minimalnative; + +import android.app.Activity; +import android.widget.TextView; +import android.os.Bundle; + +public class MinimalNative extends Activity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + TextView tv = new TextView(this); + tv.setText(stringFromNative()); + setContentView(tv); + } + + public native String stringFromNative(); + + static { + System.loadLibrary("minimal"); + } +} diff --git a/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs b/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs index 56b9d6eaf..e91a14902 100644 --- a/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs +++ b/tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs @@ -6,6 +6,8 @@ QtApplication { condition: qbs.targetOS.contains("android") Qt.android_support.extraPrefixDirs: path } + Android.sdk.packageName: "my.qmlapp" + Android.sdk.apkBaseName: name property stringList qmlImportPaths: path files: [ "main.cpp", -- cgit v1.2.3