diff options
Diffstat (limited to 'tests/qml/installer')
16 files changed, 340 insertions, 20 deletions
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 Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/installer/apps/builtin.app/icon1.png 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 Binary files differindex d2c5355f..416cf018 100644 --- a/tests/qml/installer/appv1.pkg +++ b/tests/qml/installer/appv1.pkg diff --git a/tests/qml/installer/appv2.pkg b/tests/qml/installer/appv2.pkg Binary files differindex 5eb1a5b2..d3a15de5 100644 --- a/tests/qml/installer/appv2.pkg +++ b/tests/qml/installer/appv2.pkg diff --git a/tests/qml/installer/builtinv2.pkg b/tests/qml/installer/builtinv2.pkg Binary files differnew file mode 100644 index 00000000..b32c2422 --- /dev/null +++ b/tests/qml/installer/builtinv2.pkg 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 Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/installer/install-apps/appv1/icon1.png 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 Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/installer/install-apps/appv2/icon2.png 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 Binary files differnew file mode 100644 index 00000000..c1397153 --- /dev/null +++ b/tests/qml/installer/install-apps/builtinv2/icon2.png 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"); + } } |