diff options
| author | Jake Petroules <jake.petroules@petroules.com> | 2015-07-25 22:29:35 -0700 |
|---|---|---|
| committer | Jake Petroules <jake.petroules@petroules.com> | 2015-07-27 17:36:31 +0000 |
| commit | d0e244b3d6ecfc8a7a9cf521896823db3d7945d5 (patch) | |
| tree | a1ffcaf45f35f0d4763701e6dda03b89936753cd | |
| parent | 2b648adac20ca809af0b496ecb6fdef74b157799 (diff) | |
| download | qbs-d0e244b3d6ecfc8a7a9cf521896823db3d7945d5.tar.gz | |
Introduce HostOsInfo::hostOsVersion.
Removes ifdefs that would make a subsequent addition awkward.
Change-Id: I0412b3804f7eb92f584c88ab0aa7223933b7a24e
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
| -rw-r--r-- | src/lib/corelib/tools/hostosinfo.h | 21 | ||||
| -rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 14 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/corelib/tools/hostosinfo.h b/src/lib/corelib/tools/hostosinfo.h index fc27853c4..1025d08b8 100644 --- a/src/lib/corelib/tools/hostosinfo.h +++ b/src/lib/corelib/tools/hostosinfo.h @@ -32,9 +32,11 @@ #define QBS_HOSTOSINFO_H #include "qbs_export.h" +#include "version.h" #include <QtGlobal> #include <QMap> +#include <QSettings> #include <QString> #include <QStringList> @@ -63,6 +65,25 @@ public: static inline HostOs hostOs(); + static inline Version hostOsVersion() { + Version v; + if (HostOsInfo::isWindowsHost()) { + QSettings settings(QStringLiteral("HKEY_LOCAL_MACHINE\\Software\\" + "Microsoft\\Windows NT\\CurrentVersion"), + QSettings::NativeFormat); + v = v.fromString(settings.value(QStringLiteral("CurrentVersion")).toString() + + QLatin1Char('.') + + settings.value(QStringLiteral("CurrentBuildNumber")).toString()); + Q_ASSERT(v.isValid()); + } else if (HostOsInfo::isOsxHost()) { + QSettings settings(QStringLiteral("/System/Library/CoreServices/SystemVersion.plist"), + QSettings::NativeFormat); + v = v.fromString(settings.value(QStringLiteral("ProductVersion")).toString()); + Q_ASSERT(v.isValid()); + } + return v; + } + static bool isWindowsHost() { return hostOs() == HostOsWindows; } static bool isLinuxHost() { return hostOs() == HostOsLinux; } static bool isOsxHost() { return hostOs() == HostOsOsx; } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 9e467b8f1..cd7d2a897 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -45,11 +45,6 @@ #include <QScriptEngine> #include <QScriptValue> -// from qsysinfo.h -#ifndef Q_MV_OSX -#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) -#endif - #define WAIT_FOR_NEW_TIMESTAMP() waitForNewTimestamp(testDataDir) using qbs::InstallOptions; @@ -2620,10 +2615,9 @@ void TestBlackbox::testAssetCatalog() { if (!HostOsInfo::isOsxHost()) QSKIP("only applies on OS X"); -#ifdef Q_OS_MAC - if (QSysInfo::macVersion() < Q_MV_OSX(10, 9)) + + if (HostOsInfo::hostOsVersion() < qbs::Internal::Version(10, 9)) QSKIP("This test needs at least OS X 10.9."); -#endif QDir::setCurrent(testDataDir + QLatin1String("/ib/assetcatalog")); @@ -2664,9 +2658,7 @@ void TestBlackbox::testAssetCatalog() // make sure the nibs/storyboards are in there QVERIFY(regularFileExists(relativeProductBuildDir("assetcatalogempty") + "/assetcatalogempty.app/Contents/Resources/MainMenu.nib")); -#ifdef Q_OS_MAC - if (QSysInfo::macVersion() >= Q_MV_OSX(10, 10)) -#endif + if (HostOsInfo::hostOsVersion() >= qbs::Internal::Version(10, 10)) QVERIFY(directoryExists(relativeProductBuildDir("assetcatalogempty") + "/assetcatalogempty.app/Contents/Resources/Storyboard.storyboardc")); QDir::setCurrent(testDataDir + QLatin1String("/ib/multiple-asset-catalogs")); |
