diff options
author | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-06-25 23:17:12 -0500 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-06-26 15:55:15 +0000 |
commit | a161ea60ffb2f55a6abfd44d9670bfcdda4ac536 (patch) | |
tree | 85cdc8c4ffb240fd8937809c11d798967bedb0ee /tests/auto/blackbox/tst_blackboxapple.cpp | |
parent | 617f3561e8483eb5a7470c044040c4bc42c85d26 (diff) | |
download | qbs-a161ea60ffb2f55a6abfd44d9670bfcdda4ac536.tar.gz |
Fix TestBlackboxApple::infoPlist for tvos/ios/watchos platforms
On non-desktop OSes, Info.plist is located in the other folder:
infoplist.app/Info.plist instead of infoplist.app/Contents/Info.plist
Plus, it uses binary format by default, so convert resulting
file to JSON to simplify checking its contents
Plus, some properties that are present on macOS are not present
on ios/others. Check only common subset plus macOS-specific
properties
Change-Id: Ic709f6b79a5ecc89c3866ca69ca4004341dfad9f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxapple.cpp')
-rw-r--r-- | tests/auto/blackbox/tst_blackboxapple.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index f71cc6aa8..96cd70b58 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -33,6 +33,7 @@ #include <tools/profile.h> #include <QtCore/qjsondocument.h> +#include <QtCore/qjsonobject.h> #include <QtXml/qdom.h> #include <regex> @@ -718,12 +719,38 @@ void TestBlackboxApple::infoPlist() params.arguments = QStringList() << "-f" << "infoplist.qbs"; QCOMPARE(runQbs(params), 0); - QFile infoplist(relativeProductBuildDir("infoplist") + "/infoplist.app/Contents/Info.plist"); + auto infoplistPath = relativeProductBuildDir("infoplist") + + "/infoplist.app/Contents/Info.plist"; + if (!QFile::exists(infoplistPath)) + infoplistPath = relativeProductBuildDir("infoplist") + "/infoplist.app/Info.plist"; + QVERIFY(QFile::exists(infoplistPath)); + QProcess plutil; + plutil.start("plutil", { + QStringLiteral("-convert"), + QStringLiteral("json"), + infoplistPath + }); + QVERIFY2(plutil.waitForStarted(), qPrintable(plutil.errorString())); + QVERIFY2(plutil.waitForFinished(), qPrintable(plutil.errorString())); + QVERIFY2(plutil.exitCode() == 0, qPrintable(plutil.readAllStandardError().constData())); + + QFile infoplist(infoplistPath); QVERIFY(infoplist.open(QIODevice::ReadOnly)); - const QByteArray fileContents = infoplist.readAll(); - QVERIFY2(fileContents.contains("<key>LSMinimumSystemVersion</key>"), fileContents.constData()); - QVERIFY2(fileContents.contains("<string>10.7</string>"), fileContents.constData()); - QVERIFY2(fileContents.contains("<key>NSPrincipalClass</key>"), fileContents.constData()); + QJsonParseError error; + const auto json = QJsonDocument::fromJson(infoplist.readAll(), &error); + QCOMPARE(error.error, QJsonParseError::NoError); + QVERIFY(json.isObject()); + // common values + QCOMPARE(json.object().value(QStringLiteral("CFBundleIdentifier")), + QStringLiteral("org.example.infoplist")); + QCOMPARE(json.object().value(QStringLiteral("CFBundleName")), QStringLiteral("infoplist")); + QCOMPARE(json.object().value(QStringLiteral("CFBundleExecutable")), + QStringLiteral("infoplist")); + + if (!json.object().contains(QStringLiteral("SDKROOT"))) { // macOS-specific values + QCOMPARE(json.object().value("LSMinimumSystemVersion"), QStringLiteral("10.7")); + QVERIFY(json.object().contains("NSPrincipalClass")); + } } void TestBlackboxApple::objcArc() |