summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2017-12-10 16:52:35 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2017-12-20 15:46:28 +0000
commit178a3e9d5d43fc6037cdfccfec0ebb141c8ae8ba (patch)
treec810557e68ead8f341379b00f43c060ff7e903bd
parent5b321f3a9c21dda961248b736ae665416b88442a (diff)
downloadqtapplicationmanager-178a3e9d5d43fc6037cdfccfec0ebb141c8ae8ba.tar.gz
Add installation state auto test
Also added argument to stateChanged signal. Change-Id: I5f4ce72acf022dbca803b9c4491d9e554d805464 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--src/application-lib/application.h2
-rw-r--r--src/manager-lib/applicationmanager.cpp10
-rw-r--r--tests/qml/installer/am-config.yaml18
-rw-r--r--tests/qml/installer/appv1.pkgbin0 -> 10240 bytes
-rw-r--r--tests/qml/installer/appv2.pkgbin0 -> 10240 bytes
-rw-r--r--tests/qml/installer/installer.pro4
-rw-r--r--tests/qml/installer/tst_installer.qml115
-rw-r--r--tests/qml/qml.pro3
8 files changed, 145 insertions, 7 deletions
diff --git a/src/application-lib/application.h b/src/application-lib/application.h
index ff436952..73b88ee7 100644
--- a/src/application-lib/application.h
+++ b/src/application-lib/application.h
@@ -177,7 +177,7 @@ signals:
void lastExitCodeChanged() const;
void lastExitStatusChanged() const;
void activated() const;
- void stateChanged() const;
+ void stateChanged(State state) const;
private:
Application();
diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp
index 79b1ddde..29f39eaf 100644
--- a/src/manager-lib/applicationmanager.cpp
+++ b/src/manager-lib/applicationmanager.cpp
@@ -1184,13 +1184,13 @@ bool ApplicationManager::startingApplicationInstallation(Application *installApp
return false;
newapp->mergeInto(const_cast<Application *>(app));
app->m_state = Application::BeingUpdated;
- emit app->stateChanged();
+ emit app->stateChanged(app->m_state);
app->m_progress = 0;
} else { // installation
newapp->setParent(this);
newapp->block();
newapp->m_state = Application::BeingInstalled;
- emit newapp->stateChanged();
+ emit newapp->stateChanged(newapp->m_state);
newapp->m_progress = 0;
app = newapp.take();
beginInsertRows(QModelIndex(), d->apps.count(), d->apps.count());
@@ -1215,7 +1215,7 @@ bool ApplicationManager::startingApplicationRemoval(const QString &id)
return false;
app->m_state = Application::BeingRemoved;
- emit app->stateChanged();
+ emit app->stateChanged(app->m_state);
app->m_progress = 0;
emitDataChanged(app, QVector<int> { IsUpdating });
return true;
@@ -1253,7 +1253,7 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id)
}
const_cast<Application *>(app)->setInstallationReport(ir.take());
app->m_state = Application::Installed;
- emit app->stateChanged();
+ emit app->stateChanged(app->m_state);
app->m_progress = 0;
try {
@@ -1319,7 +1319,7 @@ bool ApplicationManager::canceledApplicationInstall(const QString &id)
case Application::BeingUpdated:
case Application::BeingRemoved:
app->m_state = Application::Installed;
- emit app->stateChanged();
+ emit app->stateChanged(app->m_state);
app->m_progress = 0;
emitDataChanged(app, QVector<int> { IsUpdating });
diff --git a/tests/qml/installer/am-config.yaml b/tests/qml/installer/am-config.yaml
new file mode 100644
index 00000000..03a59daa
--- /dev/null
+++ b/tests/qml/installer/am-config.yaml
@@ -0,0 +1,18 @@
+formatVersion: 1
+formatType: am-configuration
+---
+applications:
+ builtinAppsManifestDir: "${CONFIG_PWD}/apps"
+ installedAppsManifestDir: "/tmp/am-installer-test/manifests"
+ appImageMountDir: "/tmp/am-installer-test/image-mounts"
+ database: "/tmp/am-installer-test/apps.db"
+
+installationLocations:
+- id: "internal-0"
+ installationPath: "/tmp/am-installer-test/apps"
+ documentPath: "/tmp/am-installer-test/docs"
+ mountPoint: "/tmp"
+ isDefault: true
+
+flags:
+ noSecurity: yes
diff --git a/tests/qml/installer/appv1.pkg b/tests/qml/installer/appv1.pkg
new file mode 100644
index 00000000..d2c5355f
--- /dev/null
+++ b/tests/qml/installer/appv1.pkg
Binary files differ
diff --git a/tests/qml/installer/appv2.pkg b/tests/qml/installer/appv2.pkg
new file mode 100644
index 00000000..5eb1a5b2
--- /dev/null
+++ b/tests/qml/installer/appv2.pkg
Binary files differ
diff --git a/tests/qml/installer/installer.pro b/tests/qml/installer/installer.pro
new file mode 100644
index 00000000..64cb6fec
--- /dev/null
+++ b/tests/qml/installer/installer.pro
@@ -0,0 +1,4 @@
+AM_CONFIG = am-config.yaml
+TEST_FILES = tst_installer.qml
+
+load(am-qml-testcase)
diff --git a/tests/qml/installer/tst_installer.qml b/tests/qml/installer/tst_installer.qml
new file mode 100644
index 00000000..1012f6d1
--- /dev/null
+++ b/tests/qml/installer/tst_installer.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Pelagicore Application Manager.
+**
+** $QT_BEGIN_LICENSE:LGPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: LGPL-3.0
+**
+****************************************************************************/
+
+import QtQuick 2.3
+import QtTest 1.0
+import QtApplicationManager 1.0 as AM
+
+TestCase {
+ name: "Installer"
+ when: windowShown
+
+ SignalSpy {
+ id: taskFinishedSpy
+ target: AM.ApplicationInstaller
+ signalName: "taskFinished"
+ }
+
+ SignalSpy {
+ id: taskRequestingInstallationAcknowledgeSpy
+ target: AM.ApplicationInstaller
+ signalName: "taskRequestingInstallationAcknowledge"
+ }
+
+ SignalSpy {
+ id: applicationAddedSpy
+ target: AM.ApplicationManager
+ signalName: "applicationAdded"
+ }
+
+ SignalSpy {
+ id: stateChangedSpy
+ signalName: "stateChanged"
+ }
+
+ function test_application_state() {
+ // App could potentially be installed already. Remove it.
+ if (AM.ApplicationInstaller.removePackage("test.install.app", false, true)) {
+ taskFinishedSpy.wait(2000);
+ compare(taskFinishedSpy.count, 1);
+ taskFinishedSpy.clear();
+ }
+
+ var id = AM.ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(2000);
+ compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
+ compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ taskRequestingInstallationAcknowledgeSpy.clear();
+ AM.ApplicationInstaller.acknowledgePackageInstallation(id);
+
+ applicationAddedSpy.wait(2000);
+ var appId = applicationAddedSpy.signalArguments[0][0];
+ var app = AM.ApplicationManager.application(appId);
+ compare(app.state, AM.Application.BeingInstalled)
+ stateChangedSpy.target = app;
+ stateChangedSpy.wait(2000);
+ compare(stateChangedSpy.signalArguments[0][0], AM.Application.Installed)
+ compare(app.state, AM.Application.Installed)
+
+ var id = AM.ApplicationInstaller.startPackageInstallation("internal-0", "appv2.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(2000);
+ compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
+ compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ AM.ApplicationInstaller.acknowledgePackageInstallation(id);
+
+ stateChangedSpy.wait(2000);
+ compare(stateChangedSpy.signalArguments[1][0], AM.Application.BeingUpdated)
+ compare(app.state, AM.Application.BeingUpdated)
+ stateChangedSpy.wait(2000);
+ compare(stateChangedSpy.signalArguments[2][0], AM.Application.Installed)
+ compare(app.state, AM.Application.Installed)
+
+ id = AM.ApplicationInstaller.removePackage(appId, false, false);
+ stateChangedSpy.wait(2000);
+ compare(stateChangedSpy.signalArguments[3][0], AM.Application.BeingRemoved)
+ // Cannot compare app.state any more, since app might already be dead
+ }
+}
diff --git a/tests/qml/qml.pro b/tests/qml/qml.pro
index 906bde2c..93201f45 100644
--- a/tests/qml/qml.pro
+++ b/tests/qml/qml.pro
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
simple \
windowmapping \
- fakeamwindow
+ fakeamwindow \
+ installer