summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2022-04-26 12:46:18 +0200
committerDominik Holland <dominik.holland@qt.io>2022-05-17 16:14:38 +0200
commitc4eddc6a1fbfe8d6df7f9977dda63e02d1c223d7 (patch)
tree300f697f77d793d286b511e821024e3b80489a44
parent621b54ff8cb1df811ab87232d8c8ad81d37d184d (diff)
downloadqtapplicationmanager-c4eddc6a1fbfe8d6df7f9977dda63e02d1c223d7.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)
-rw-r--r--src/tools/testrunner/amtest.cpp6
-rw-r--r--src/tools/testrunner/amtest.h1
-rw-r--r--tests/qml/installer/tst_installer.qml40
3 files changed, 33 insertions, 14 deletions
diff --git a/src/tools/testrunner/amtest.cpp b/src/tools/testrunner/amtest.cpp
index c992c569..83dd5381 100644
--- a/src/tools/testrunner/amtest.cpp
+++ b/src/tools/testrunner/amtest.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QPointer>
+#include <QDir>
#include <QRegularExpression>
#include <QAbstractEventDispatcher>
#if defined(Q_OS_LINUX)
@@ -115,6 +116,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 91bb43b0..db4fac4c 100644
--- a/src/tools/testrunner/amtest.h
+++ b/src/tools/testrunner/amtest.h
@@ -66,6 +66,7 @@ public:
Q_INVOKABLE void ignoreMessage(MsgType type, const QRegExp &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/qml/installer/tst_installer.qml b/tests/qml/installer/tst_installer.qml
index 04233cf6..bc81b2d6 100644
--- a/tests/qml/installer/tst_installer.qml
+++ b/tests/qml/installer/tst_installer.qml
@@ -49,6 +49,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
@@ -111,6 +120,8 @@ TestCase {
}
function test_1states() {
+ checkSkip()
+
PackageManager.packageAdded.connect(function(pkgId) {
var pkg = PackageManager.package(pkgId);
stateList.push(pkg.state)
@@ -121,8 +132,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);
@@ -142,8 +152,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);
@@ -187,8 +196,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);
@@ -203,8 +213,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");
@@ -218,14 +227,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);
@@ -241,10 +251,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);
@@ -275,6 +286,8 @@ TestCase {
}
function test_5stop_on_update() {
+ checkSkip()
+
taskStateChangedSpy.clear()
taskBlockingUntilInstallationAcknowledgeSpy.clear()
applicationRunStateChangedSpy.clear()
@@ -295,8 +308,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);