diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-12-19 18:56:46 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-01-12 02:13:21 +0000 |
commit | 2b928ef6f95c528449d6ec9650325f3ccaac5094 (patch) | |
tree | cfffe1bfa4e027f6de84773137232f96543a8636 /tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp | |
parent | 5865e582fd537fff530c13301e5229a7b4ed21c7 (diff) |
Provide sensible defaults for QCoreApplication::applicationVersion
[ChangeLog][QtCore] QCoreApplication::applicationVersion now defaults to
an appropriate platform-specific value. On Windows, it defaults to the
PRODUCTVERSION parameter of the VERSIONINFO resource for classic desktop
apps, and the version attribute of the application package manifest for
Univeral Windows Platform apps. On Apple Platforms (macOS, iOS, tvOS,
watchOS), it defaults to the CFBundleVersion property of the information
property list (Info.plist) file. On Android, it defaults to the
android:versionName attribute of the AndroidManifest.xml manifest
element. On other platforms, the default remains an empty string.
Task-number: QTBUG-57715
Change-Id: I26f83dd00737e06f4321cf962aa5fab8398104ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 0691297497..a7c608ec2e 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -153,6 +153,41 @@ void tst_QCoreApplication::qAppName() QCOMPARE(QCoreApplication::applicationName(), QString()); } +void tst_QCoreApplication::qAppVersion() +{ +#if defined(Q_OS_WIN) + const char appVersion[] = "1.2.3.4"; +#elif defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) + const char appVersion[] = "1.2.3"; +#else + const char appVersion[] = ""; +#endif + + { + int argc = 0; + char *argv[] = { nullptr }; + TestApplication app(argc, argv); + QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion)); + } + // The application version should still be available after destruction + QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion)); + + // Setting the appversion before creating the application should work + const QString wantedAppVersion("0.0.1"); + { + int argc = 0; + char *argv[] = { nullptr }; + QCoreApplication::setApplicationVersion(wantedAppVersion); + TestApplication app(argc, argv); + QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion); + } + QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion); + + // Restore to initial value + QCoreApplication::setApplicationVersion(QString()); + QCOMPARE(QCoreApplication::applicationVersion(), QString()); +} + void tst_QCoreApplication::argc() { #if defined(Q_OS_WINRT) |