summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2019-09-06 13:12:50 +0200
committerBernd Weimer <bernd.weimer@pelagicore.com>2019-09-12 11:59:45 +0200
commit877e4cd4cf7f581a0a92eb2adb6f95695b186104 (patch)
tree55f35f8dcde6fd73d7704df275f1857b619615d8
parentff4bc7cbaf5827736fda4b1a8c85fcdd351680c1 (diff)
Fix canceling installations
Canceling an update left the app in an inconsistent state. There is still a known issues: canceling the update of an already updated built-in app will revert back to the original app. This will be fixed in 5.14 Also downgrading a built-in app didn't work as expected (the app would be blocked, the icon etc. wouldn't be updated). Change-Id: I6c72e7f87e993a6839e97ceb6cea443f07e1fd77 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--src/manager-lib/application.cpp16
-rw-r--r--src/manager-lib/application.h4
-rw-r--r--src/manager-lib/applicationmanager.cpp27
-rw-r--r--tests/qml/installer/apps/builtin.app/app1.qml46
-rw-r--r--tests/qml/installer/apps/builtin.app/icon1.pngbin0 -> 1486 bytes
-rw-r--r--tests/qml/installer/apps/builtin.app/info.yaml10
-rw-r--r--tests/qml/installer/appv1.pkgbin10240 -> 10240 bytes
-rw-r--r--tests/qml/installer/appv2.pkgbin10240 -> 10240 bytes
-rw-r--r--tests/qml/installer/builtinv2.pkgbin0 -> 10240 bytes
-rw-r--r--tests/qml/installer/install-apps/appv1/app1.qml44
-rw-r--r--tests/qml/installer/install-apps/appv1/icon1.pngbin0 -> 1486 bytes
-rw-r--r--tests/qml/installer/install-apps/appv1/info.yaml10
-rw-r--r--tests/qml/installer/install-apps/appv2/app2.qml44
-rw-r--r--tests/qml/installer/install-apps/appv2/icon2.pngbin0 -> 1486 bytes
-rw-r--r--tests/qml/installer/install-apps/appv2/info.yaml10
-rw-r--r--tests/qml/installer/install-apps/builtinv2/app2.qml46
-rw-r--r--tests/qml/installer/install-apps/builtinv2/icon2.pngbin0 -> 1486 bytes
-rw-r--r--tests/qml/installer/install-apps/builtinv2/info.yaml10
-rw-r--r--tests/qml/installer/tst_installer.qml140
19 files changed, 365 insertions, 42 deletions
diff --git a/src/manager-lib/application.cpp b/src/manager-lib/application.cpp
index 4eff6990..e4cb7292 100644
--- a/src/manager-lib/application.cpp
+++ b/src/manager-lib/application.cpp
@@ -417,25 +417,20 @@ QVector<AbstractApplication *> AbstractApplication::fromApplicationInfoVector(
// There's already another ApplicationInfo with the same id. It's probably an update for a
// built-in app, in which case we use the same Application instance to hold both
// ApplicationInfo instances.
- bool merged = false;
-
if (!otherAbsApp->isAlias()) {
auto otherApp = static_cast<Application*>(otherAbsApp);
auto fullAppInfo = static_cast<ApplicationInfo*>(appInfo);
if (otherApp->isBuiltIn() && !fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) {
otherApp->setUpdatedInfo(static_cast<ApplicationInfo*>(appInfo));
- merged = true;
} else if (!otherApp->isBuiltIn() && fullAppInfo->isBuiltIn() && !otherApp->updatedInfo()) {
auto currentBaseInfo = otherApp->takeBaseInfo();
otherApp->setBaseInfo(static_cast<ApplicationInfo*>(appInfo));
otherApp->setUpdatedInfo(currentBaseInfo);
- merged = true;
}
+ } else {
+ qCWarning(LogSystem) << "Found a second application with id" << appInfo->id()
+ << "which is not an update for a built-in one. Ignoring it.";
}
-
- if (!merged)
- qCWarning(LogSystem).nospace() << "Found a second application with id "
- << appInfo->id() << " which is not an update for a built-in one. Ignoring it.";
} else {
app.reset(new Application(static_cast<ApplicationInfo*>(appInfo)));
}
@@ -564,6 +559,11 @@ void Application::setUpdatedInfo(ApplicationInfo* info)
emit bulkChange();
}
+ApplicationInfo *Application::takeUpdatedInfo()
+{
+ return m_updatedInfo.take();
+}
+
void Application::setState(State state)
{
if (m_state != state) {
diff --git a/src/manager-lib/application.h b/src/manager-lib/application.h
index 673cdfe5..b5c62338 100644
--- a/src/manager-lib/application.h
+++ b/src/manager-lib/application.h
@@ -201,9 +201,11 @@ public:
removed when requested.
*/
void setBaseInfo(ApplicationInfo*);
+ AbstractApplicationInfo *baseInfo() const { return m_info.data(); }
+ ApplicationInfo *takeBaseInfo();
void setUpdatedInfo(ApplicationInfo*);
ApplicationInfo *updatedInfo() const { return m_updatedInfo.data(); }
- ApplicationInfo *takeBaseInfo();
+ ApplicationInfo *takeUpdatedInfo();
void setState(State);
void setProgress(qreal);
diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp
index b2745ecb..dc6071d9 100644
--- a/src/manager-lib/applicationmanager.cpp
+++ b/src/manager-lib/applicationmanager.cpp
@@ -1203,16 +1203,10 @@ bool ApplicationManager::startingApplicationInstallation(ApplicationInfo *info)
if (!blockApplication(app->id()))
return false;
- if (app->isBuiltIn()) {
- // overlay the existing base info
- // we will rollback to the base one if this update is removed.
- app->setUpdatedInfo(newInfo.take());
- } else {
- // overwrite the existing base info
- // we're not keeping track of the original. so removing the updated base version removes the
- // application entirely.
- app->setBaseInfo(newInfo.take());
- }
+ // There is still an issue with "shadowing" built-in apps (which will be properly fixed in 5.14):
+ // As the updatedInfo might be used already (by an already updated built-in app), we cannot revert back any
+ // more to the previous version. Canceling the update will therefore revert back to the original app.
+ app->setUpdatedInfo(newInfo.take());
app->setState(Application::BeingUpdated);
app->setProgress(0);
emitDataChanged(app);
@@ -1290,8 +1284,11 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id)
case Application::Installed:
return false;
- case Application::BeingInstalled:
- case Application::BeingUpdated: {
+ case Application::BeingUpdated:
+ if (!static_cast<ApplicationInfo*>(app->baseInfo())->isBuiltIn())
+ app->setBaseInfo(app->takeUpdatedInfo());
+ Q_FALLTHROUGH();
+ case Application::BeingInstalled: {
// The Application object has been updated right at the start of the installation/update.
// Now's the time to update the InstallationReport that was written by the installer.
QFile irfile(QDir(app->nonAliasedInfo()->manifestDir()).absoluteFilePath(qSL("installation-report.yaml")));
@@ -1316,6 +1313,8 @@ bool ApplicationManager::finishedApplicationInstall(const QString &id)
app->setUpdatedInfo(nullptr);
app->setState(Application::Installed);
registerMimeTypes();
+ emitDataChanged(app);
+ unblockApplication(id);
break;
case Application::BeingRemoved: {
int row = d->apps.indexOf(app);
@@ -1361,11 +1360,13 @@ bool ApplicationManager::canceledApplicationInstall(const QString &id)
break;
}
case Application::BeingUpdated:
+ app->setUpdatedInfo(nullptr);
+ Q_FALLTHROUGH();
case Application::BeingDowngraded:
case Application::BeingRemoved:
app->setState(Application::Installed);
app->setProgress(0);
- emitDataChanged(app, QVector<int> { IsUpdating });
+ emitDataChanged(app);
unblockApplication(id);
break;
diff --git a/tests/qml/installer/apps/builtin.app/app1.qml b/tests/qml/installer/apps/builtin.app/app1.qml
new file mode 100644
index 00000000..c18b5421
--- /dev/null
+++ b/tests/qml/installer/apps/builtin.app/app1.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Luxoft 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 QtApplicationManager.Application 2.0
+
+ApplicationManagerWindow {
+ color: "green"
+}
diff --git a/tests/qml/installer/apps/builtin.app/icon1.png b/tests/qml/installer/apps/builtin.app/icon1.png
new file mode 100644
index 00000000..c1397153
--- /dev/null
+++ b/tests/qml/installer/apps/builtin.app/icon1.png
Binary files differ
diff --git a/tests/qml/installer/apps/builtin.app/info.yaml b/tests/qml/installer/apps/builtin.app/info.yaml
new file mode 100644
index 00000000..9320306b
--- /dev/null
+++ b/tests/qml/installer/apps/builtin.app/info.yaml
@@ -0,0 +1,10 @@
+formatVersion: 1
+formatType: am-application
+---
+id: 'builtin.app'
+version: 'v1'
+icon: 'icon1.png'
+code: 'app1.qml'
+runtime: 'qml'
+name:
+ en: 'Builtin Installation Test App v1'
diff --git a/tests/qml/installer/appv1.pkg b/tests/qml/installer/appv1.pkg
index d2c5355f..416cf018 100644
--- a/tests/qml/installer/appv1.pkg
+++ b/tests/qml/installer/appv1.pkg
Binary files differ
diff --git a/tests/qml/installer/appv2.pkg b/tests/qml/installer/appv2.pkg
index 5eb1a5b2..d3a15de5 100644
--- a/tests/qml/installer/appv2.pkg
+++ b/tests/qml/installer/appv2.pkg
Binary files differ
diff --git a/tests/qml/installer/builtinv2.pkg b/tests/qml/installer/builtinv2.pkg
new file mode 100644
index 00000000..b32c2422
--- /dev/null
+++ b/tests/qml/installer/builtinv2.pkg
Binary files differ
diff --git a/tests/qml/installer/install-apps/appv1/app1.qml b/tests/qml/installer/install-apps/appv1/app1.qml
new file mode 100644
index 00000000..4934be54
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv1/app1.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Luxoft 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.4
+
+Item {}
diff --git a/tests/qml/installer/install-apps/appv1/icon1.png b/tests/qml/installer/install-apps/appv1/icon1.png
new file mode 100644
index 00000000..c1397153
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv1/icon1.png
Binary files differ
diff --git a/tests/qml/installer/install-apps/appv1/info.yaml b/tests/qml/installer/install-apps/appv1/info.yaml
new file mode 100644
index 00000000..2c04ec5d
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv1/info.yaml
@@ -0,0 +1,10 @@
+formatVersion: 1
+formatType: am-application
+---
+id: 'test.install.app'
+version: 'v1'
+icon: 'icon1.png'
+code: 'app1.qml'
+runtime: 'qml'
+name:
+ en: 'Installation Test App Version 1'
diff --git a/tests/qml/installer/install-apps/appv2/app2.qml b/tests/qml/installer/install-apps/appv2/app2.qml
new file mode 100644
index 00000000..0e1798c3
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv2/app2.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Luxoft 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.4
+
+Rectangle {}
diff --git a/tests/qml/installer/install-apps/appv2/icon2.png b/tests/qml/installer/install-apps/appv2/icon2.png
new file mode 100644
index 00000000..c1397153
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv2/icon2.png
Binary files differ
diff --git a/tests/qml/installer/install-apps/appv2/info.yaml b/tests/qml/installer/install-apps/appv2/info.yaml
new file mode 100644
index 00000000..f7e2f96a
--- /dev/null
+++ b/tests/qml/installer/install-apps/appv2/info.yaml
@@ -0,0 +1,10 @@
+formatVersion: 1
+formatType: am-application
+---
+id: 'test.install.app'
+version: 'v2'
+icon: 'icon2.png'
+code: 'app2.qml'
+runtime: 'qml'
+name:
+ en: 'Installation Test App Version 2'
diff --git a/tests/qml/installer/install-apps/builtinv2/app2.qml b/tests/qml/installer/install-apps/builtinv2/app2.qml
new file mode 100644
index 00000000..b65b03ce
--- /dev/null
+++ b/tests/qml/installer/install-apps/builtinv2/app2.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Luxoft Sweden AB
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Luxoft 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.4
+
+Rectangle {
+ color: "red"
+}
diff --git a/tests/qml/installer/install-apps/builtinv2/icon2.png b/tests/qml/installer/install-apps/builtinv2/icon2.png
new file mode 100644
index 00000000..c1397153
--- /dev/null
+++ b/tests/qml/installer/install-apps/builtinv2/icon2.png
Binary files differ
diff --git a/tests/qml/installer/install-apps/builtinv2/info.yaml b/tests/qml/installer/install-apps/builtinv2/info.yaml
new file mode 100644
index 00000000..3e90f151
--- /dev/null
+++ b/tests/qml/installer/install-apps/builtinv2/info.yaml
@@ -0,0 +1,10 @@
+formatVersion: 1
+formatType: am-application
+---
+id: 'builtin.app'
+version: 'v2'
+icon: 'icon2.png'
+code: 'app2.qml'
+runtime: 'qml'
+name:
+ en: 'Builtin Installation Test App v2'
diff --git a/tests/qml/installer/tst_installer.qml b/tests/qml/installer/tst_installer.qml
index 8bfcc246..01bb7a32 100644
--- a/tests/qml/installer/tst_installer.qml
+++ b/tests/qml/installer/tst_installer.qml
@@ -49,6 +49,9 @@ TestCase {
name: "Installer"
when: windowShown
+ property var stateList: []
+ property int spyTimeout: 5000 * AmTest.timeoutFactor
+
SignalSpy {
id: taskFinishedSpy
target: ApplicationInstaller
@@ -56,6 +59,12 @@ TestCase {
}
SignalSpy {
+ id: taskFailedSpy
+ target: ApplicationInstaller
+ signalName: "taskFailed"
+ }
+
+ SignalSpy {
id: taskStateChangedSpy
target: ApplicationInstaller
signalName: "taskStateChanged"
@@ -67,27 +76,34 @@ TestCase {
signalName: "taskRequestingInstallationAcknowledge"
}
- property var stateList: []
- property int spyTimeout: 5000 * AmTest.timeoutFactor
+ SignalSpy {
+        id: applicationChangedSpy
+        target: ApplicationManager
+        signalName: "applicationChanged"
+    }
- function test_states() {
- // App could potentially be installed already. Remove it.
+
+ function init() {
+ // Remove previous installations
if (ApplicationInstaller.removePackage("test.install.app", false, true)) {
taskFinishedSpy.wait(spyTimeout);
compare(taskFinishedSpy.count, 1);
taskFinishedSpy.clear();
}
+ }
- ApplicationManager.applicationAdded.connect(function(appId) {
- var app = ApplicationManager.application(appId);
- stateList.push(app.state)
+ function test_states() {
+ ApplicationManager.applicationAdded.connect(function(id) {
+ var app = ApplicationManager.application(id);
+ stateList.push(app.state);
app.stateChanged.connect(function(state) {
- compare(state, app.state)
- stateList.push(state)
- })
- })
+ compare(state, app.state);
+ stateList.push(state);
+ });
+ });
- var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg")
+ taskStateChangedSpy.clear();
+ var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg");
taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
@@ -101,23 +117,24 @@ TestCase {
taskFinishedSpy.clear();
compare(stateList.length, 2);
- compare(stateList[0], ApplicationObject.BeingInstalled)
- compare(stateList[1], ApplicationObject.Installed)
- stateList = []
+ compare(stateList[0], ApplicationObject.BeingInstalled);
+ compare(stateList[1], ApplicationObject.Installed);
+ stateList = [];
id = ApplicationInstaller.startPackageInstallation("internal-0", "appv2.pkg")
taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ taskRequestingInstallationAcknowledgeSpy.clear();
ApplicationInstaller.acknowledgePackageInstallation(id);
taskFinishedSpy.wait(spyTimeout);
compare(taskFinishedSpy.count, 1);
taskFinishedSpy.clear();
- compare(stateList[0], ApplicationObject.BeingUpdated)
- compare(stateList[1], ApplicationObject.Installed)
- stateList = []
+ compare(stateList[0], ApplicationObject.BeingUpdated);
+ compare(stateList[1], ApplicationObject.Installed);
+ stateList = [];
id = ApplicationInstaller.removePackage(appId, false, false);
@@ -125,8 +142,8 @@ TestCase {
compare(taskFinishedSpy.count, 1);
taskFinishedSpy.clear();
- compare(stateList[0], ApplicationObject.BeingRemoved)
- stateList = []
+ compare(stateList[0], ApplicationObject.BeingRemoved);
+ stateList = [];
// Cannot compare app.state any more, since app might already be dead
verify(taskStateChangedSpy.count > 10);
@@ -144,4 +161,87 @@ TestCase {
for (var i = 0; i < taskStates.length; i++)
compare(taskStateChangedSpy.signalArguments[i][1], taskStates[i], "- index: " + i);
}
+
+ function test_cancel_update() {
+ var id = ApplicationInstaller.startPackageInstallation("internal-0", "appv1.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
+ compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
+ compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ var appId = taskRequestingInstallationAcknowledgeSpy.signalArguments[0][1].id
+ compare(appId, "test.install.app");
+ taskRequestingInstallationAcknowledgeSpy.clear();
+ ApplicationInstaller.acknowledgePackageInstallation(id);
+
+ taskFinishedSpy.wait(spyTimeout);
+ taskFinishedSpy.clear();
+
+ var app = ApplicationManager.application(appId);
+ compare(app.icon.toString().slice(-9), "icon1.png")
+ compare(app.version, "v1");
+
+ id = ApplicationInstaller.startPackageInstallation("internal-0", "appv2.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
+ appId = taskRequestingInstallationAcknowledgeSpy.signalArguments[0][1].id
+ compare(appId, "test.install.app");
+ taskRequestingInstallationAcknowledgeSpy.clear();
+ ApplicationInstaller.cancelTask(id);
+
+ taskFailedSpy.wait(spyTimeout);
+ taskFailedSpy.clear();
+
+ compare(app.icon.toString().slice(-9), "icon1.png")
+ compare(app.version, "v1");
+ }
+
+ function test_cancel_builtin_update() {
+ taskStateChangedSpy.clear()
+ var app = ApplicationManager.application("builtin.app");
+ verify(app.builtIn);
+ compare(app.icon.toString().slice(-9), "icon1.png")
+ compare(app.version, "v1");
+
+ var id = ApplicationInstaller.startPackageInstallation("internal-0", "builtinv2.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
+ compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
+ compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ taskRequestingInstallationAcknowledgeSpy.clear();
+ ApplicationInstaller.cancelTask(id);
+
+ taskFailedSpy.wait(spyTimeout);
+ taskFailedSpy.clear();
+
+ verify(app.builtIn);
+ compare(app.icon.toString().slice(-9), "icon1.png")
+ compare(app.version, "v1");
+ }
+
+ function test_builtin_update_downgrade() {
+ taskStateChangedSpy.clear()
+ var id = ApplicationInstaller.startPackageInstallation("internal-0", "builtinv2.pkg")
+ taskRequestingInstallationAcknowledgeSpy.wait(spyTimeout);
+ compare(taskRequestingInstallationAcknowledgeSpy.count, 1);
+ compare(taskRequestingInstallationAcknowledgeSpy.signalArguments[0][0], id);
+ taskRequestingInstallationAcknowledgeSpy.clear();
+ ApplicationInstaller.acknowledgePackageInstallation(id);
+
+ taskFinishedSpy.wait(spyTimeout);
+ compare(ApplicationManager.get("builtin.app").version, "v2");
+ taskFinishedSpy.clear();
+ applicationChangedSpy.clear();
+
+ // remvove is a downgrade
+ verify(ApplicationInstaller.removePackage("builtin.app", false, true));
+ taskFinishedSpy.wait(spyTimeout);
+ compare(taskFinishedSpy.count, 1);
+ taskFinishedSpy.clear();
+
+ compare(applicationChangedSpy.count, 5);
+ compare(applicationChangedSpy.signalArguments[3][0], "builtin.app");
+ compare(applicationChangedSpy.signalArguments[3][1], []);
+ compare(applicationChangedSpy.signalArguments[4][1], ["isBlocked"]);
+
+ var appmodel = ApplicationManager.get("builtin.app");
+ verify(!appmodel.isBlocked);
+ compare(appmodel.version, "v1");
+ }
}