diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-04-26 12:46:18 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-04-27 09:20:57 +0000 |
commit | d0333da94a14d4d4230f8cbf4ec6c8fad12abd09 (patch) | |
tree | 9b90c6323e70d5d66523c7de30277b7c6dca4b19 | |
parent | 61d9365a54bf8534bd0e0b4569f545cda16fd253 (diff) | |
download | qtapplicationmanager-d0333da94a14d4d4230f8cbf4ec6c8fad12abd09.tar.gz |
Fix the QML tst_installer to run on Windows
Change-Id: Ic6a24d2d849a3d00e4e44f83ef6410bab4aca7c2
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
(cherry picked from commit 5184cb19845e1b5bc25665e49e423f0dd8a25a5c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/main-lib/Qt6AppManMainPrivateMacros.cmake | 2 | ||||
-rw-r--r-- | src/tools/testrunner/amtest.cpp | 6 | ||||
-rw-r--r-- | src/tools/testrunner/amtest.h | 1 | ||||
-rw-r--r-- | tests/auto/qml/installer/tst_installer.qml | 40 |
4 files changed, 34 insertions, 15 deletions
diff --git a/src/main-lib/Qt6AppManMainPrivateMacros.cmake b/src/main-lib/Qt6AppManMainPrivateMacros.cmake index 3b0c5653..663fffca 100644 --- a/src/main-lib/Qt6AppManMainPrivateMacros.cmake +++ b/src/main-lib/Qt6AppManMainPrivateMacros.cmake @@ -197,7 +197,7 @@ function (qt_am_internal_add_qml_test target) endif() if (ARG_TESTDATA_DIR) - list(APPEND WRAPPER_ARGS EXTRA_ARGS "-o \'systemProperties: { public: { AM_TESTDATA_DIR: ${ARG_TESTDATA_DIR} } }'") + list(APPEND WRAPPER_ARGS EXTRA_ARGS -o "\"systemProperties: { public: { AM_TESTDATA_DIR: ${ARG_TESTDATA_DIR} } }\"") endif() list(APPEND WRAPPER_ARGS EXTRA_ARGS --no-cache --no-dlt-logging) diff --git a/src/tools/testrunner/amtest.cpp b/src/tools/testrunner/amtest.cpp index 2cbd4aa3..c0c5ca8b 100644 --- a/src/tools/testrunner/amtest.cpp +++ b/src/tools/testrunner/amtest.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include <QPointer> +#include <QDir> #include <QRegularExpression> #include <QAbstractEventDispatcher> #if defined(Q_OS_LINUX) @@ -101,6 +102,11 @@ void AmTest::aboutToBlock() emit QAbstractEventDispatcher::instance()->aboutToBlock(); } +bool AmTest::dirExists(const QString &dir) +{ + return QDir(dir).exists(); +} + #if defined(Q_OS_LINUX) QString AmTest::ps(int pid) { diff --git a/src/tools/testrunner/amtest.h b/src/tools/testrunner/amtest.h index 0fe54e3b..fbaf9db3 100644 --- a/src/tools/testrunner/amtest.h +++ b/src/tools/testrunner/amtest.h @@ -55,6 +55,7 @@ public: Q_INVOKABLE void ignoreMessage(QT_PREPEND_NAMESPACE_AM(AmTest::MsgType) type, const QRegularExpression &expression); Q_INVOKABLE int observeObjectDestroyed(QObject *obj); Q_INVOKABLE void aboutToBlock(); + Q_INVOKABLE bool dirExists(const QString &dir); #if defined(Q_OS_LINUX) Q_INVOKABLE QString ps(int pid); Q_INVOKABLE QString cmdLine(int pid); diff --git a/tests/auto/qml/installer/tst_installer.qml b/tests/auto/qml/installer/tst_installer.qml index 701b7242..ae4e8559 100644 --- a/tests/auto/qml/installer/tst_installer.qml +++ b/tests/auto/qml/installer/tst_installer.qml @@ -37,6 +37,15 @@ TestCase { name: "Installer" when: windowShown + property string packageDir: ApplicationManager.systemProperties.AM_TESTDATA_DIR + "/packages/" + + // this should be initTestCase(), but a skip() there doesn't skip the whole TestCase the + // same way as it works on the C++ side, so we have to call this from every test function + function checkSkip() { + if (!AmTest.dirExists(packageDir)) + skip("No test packages available in the data/ directory") + } + property var stateList: [] property int spyTimeout: 5000 * AmTest.timeoutFactor @@ -99,6 +108,8 @@ TestCase { } function test_1states() { + checkSkip() + PackageManager.packageAdded.connect(function(pkgId) { var pkg = PackageManager.package(pkgId); stateList.push(pkg.state) @@ -109,8 +120,7 @@ TestCase { }) taskStateChangedSpy.clear(); - var id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/test-dev-signed.appkg") + var id = PackageManager.startPackageInstallation(packageDir + "test-dev-signed.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -130,8 +140,7 @@ TestCase { compare(PackageManager.package(pkgId).version, "1.0"); - id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/test-update-dev-signed.appkg") + id = PackageManager.startPackageInstallation(packageDir + "test-update-dev-signed.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -175,8 +184,9 @@ TestCase { } function test_2cancel_update() { - var id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/test-dev-signed.appkg") + checkSkip() + + var id = PackageManager.startPackageInstallation(packageDir + "test-dev-signed.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -191,8 +201,7 @@ TestCase { var pkg = PackageManager.package(pkgId); compare(pkg.version, "1.0"); - id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/test-update-dev-signed.appkg") + id = PackageManager.startPackageInstallation(packageDir + "test-update-dev-signed.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); pkgId = taskRequestingInstallationAcknowledgeSpy.signalArguments[0][1].id compare(pkgId, "com.pelagicore.test"); @@ -206,14 +215,15 @@ TestCase { } function test_3cancel_builtin_update() { + checkSkip() + taskStateChangedSpy.clear() var pkg = PackageManager.package("hello-world.red"); verify(pkg.builtIn); compare(pkg.icon.toString().slice(-9), "icon1.png") compare(pkg.version, "v1"); - var id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/hello-world.red.appkg") + var id = PackageManager.startPackageInstallation(packageDir + "hello-world.red.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -229,10 +239,11 @@ TestCase { } function test_4builtin_update_downgrade() { + checkSkip() + taskStateChangedSpy.clear() - var id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/hello-world.red.appkg") + var id = PackageManager.startPackageInstallation(packageDir + "hello-world.red.appkg") taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskRequestingInstallationAcknowledgeSpy.count, 1); compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id); @@ -263,6 +274,8 @@ TestCase { } function test_5stop_on_update() { + checkSkip() + taskStateChangedSpy.clear() taskBlockingUntilInstallationAcknowledgeSpy.clear() applicationRunStateChangedSpy.clear() @@ -283,8 +296,7 @@ TestCase { applicationRunStateChangedSpy.clear() // now install the update - var id = PackageManager.startPackageInstallation(ApplicationManager.systemProperties.AM_TESTDATA_DIR - + "/packages/hello-world.red.appkg") + var id = PackageManager.startPackageInstallation(packageDir + "hello-world.red.appkg") taskBlockingUntilInstallationAcknowledgeSpy.wait(spyTimeout); compare(taskBlockingUntilInstallationAcknowledgeSpy.count, 1); compare(taskBlockingUntilInstallationAcknowledgeSpy.signalArguments[0][0], id); |