From eb8b24f8e3466ecfccb4975dd76c224847d34dd0 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 6 Jan 2022 14:26:03 +0200 Subject: Fix Replace -element beviour Replacable component was not correctly removed in install and update. Also added new tests for Replace element. Task-number: QTIFW-2454 Change-Id: Idce7fd1ef0ac2025ca5ca0952ab837e14516ac2b Reviewed-by: Arttu Tarkiainen --- .../componentreplace/componentreplace.pro | 9 + .../A.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../installPackagesRepository/A/1.0.0content.7z | Bin 0 -> 184 bytes .../B.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../installPackagesRepository/B/1.0.0content.7z | Bin 0 -> 184 bytes .../data/installPackagesRepository/Updates.xml | 45 +++++ .../A.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../repositoryWithMultiReplace/A/1.0.0content.7z | Bin 0 -> 184 bytes .../B.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../repositoryWithMultiReplace/B/1.0.0content.7z | Bin 0 -> 184 bytes .../data/repositoryWithMultiReplace/Updates.xml | 46 +++++ .../A.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../A/2.0.0content.7z | Bin 0 -> 184 bytes .../B.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../B/2.0.0content.7z | Bin 0 -> 184 bytes .../repositoryWithMultiReplaceInUpdate/Updates.xml | 46 +++++ .../repositoryWithReplace/A.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../data/repositoryWithReplace/A/1.0.0content.7z | Bin 0 -> 184 bytes .../repositoryWithReplace/B.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../data/repositoryWithReplace/B/2.0.0content.7z | Bin 0 -> 184 bytes .../data/repositoryWithReplace/Updates.xml | 46 +++++ .../A.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../A/2.0.0content.7z | Bin 0 -> 184 bytes .../B.sub1/1.0.0content.7z | Bin 0 -> 207 bytes .../B/2.0.0content.7z | Bin 0 -> 184 bytes .../repositoryWithUpdateToReplaceble/Updates.xml | 46 +++++ tests/auto/installer/componentreplace/settings.qrc | 29 +++ .../componentreplace/tst_componentreplace.cpp | 220 +++++++++++++++++++++ tests/auto/installer/installer.pro | 3 +- 29 files changed, 489 insertions(+), 1 deletion(-) create mode 100644 tests/auto/installer/componentreplace/componentreplace.pro create mode 100644 tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z create mode 100644 tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml create mode 100644 tests/auto/installer/componentreplace/settings.qrc create mode 100644 tests/auto/installer/componentreplace/tst_componentreplace.cpp (limited to 'tests') diff --git a/tests/auto/installer/componentreplace/componentreplace.pro b/tests/auto/installer/componentreplace/componentreplace.pro new file mode 100644 index 000000000..9df6f81ca --- /dev/null +++ b/tests/auto/installer/componentreplace/componentreplace.pro @@ -0,0 +1,9 @@ +include(../../qttest.pri) + +QT += qml + +SOURCES += tst_componentreplace.cpp + +RESOURCES += \ + settings.qrc \ + ../shared/config.qrc diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z new file mode 100644 index 000000000..adcc21ad7 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z new file mode 100644 index 000000000..916fdd1d0 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z new file mode 100644 index 000000000..ab63152f8 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z b/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z new file mode 100644 index 000000000..7b957b077 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml b/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml new file mode 100644 index 000000000..6f02aad2b --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/Updates.xml @@ -0,0 +1,45 @@ + + {AnyApplication} + 1.0.0 + false + + A + A + Example component A + 1.0.0 + 2021-01-01 + + content.7z + 53892cfe4d5f5b978553d3aa172944117604ef9c + + + A.sub1 + A subcomponent 1 + Subcomponent of component A + 1.0.0 + 2021-01-01 + + content.7z + 8bd5a1d2525cfdfb690a3c80165aeed44a17795f + + + B + B + Example component B + 1.0.0 + 2021-01-01 + + content.7z + b2d03273f01f45878c3f5081cc8502edc0826e08 + + + B.sub1 + B subcomponent 1 + Subcomponent of component B + 1.0.0 + 2021-01-01 + + content.7z + a10463141e30ce3fede9ac84bc52a07b0c5e919e + + diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z new file mode 100644 index 000000000..adcc21ad7 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z new file mode 100644 index 000000000..916fdd1d0 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z new file mode 100644 index 000000000..ab63152f8 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z new file mode 100644 index 000000000..7b957b077 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml new file mode 100644 index 000000000..c6b85077b --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/Updates.xml @@ -0,0 +1,46 @@ + + {AnyApplication} + 1.0.0 + false + + A + A + Example component A + 1.0.0 + 2021-01-01 + + content.7z + dd48e40f2f86559b20288424a6a3e2a1a05a172d + + + A.sub1 + A subcomponent 1 + Subcomponent of component A + 1.0.0 + 2021-01-01 + + content.7z + f8ff5da138516b1f800e641ab4999301dcb3c78b + + + B + B + Example component B + 1.0.0 + 2021-01-01 + A, A.sub1 + + content.7z + 8e83334a4a3c9c9d2bb6b073858d980da2c8871f + + + B.sub1 + B subcomponent 1 + Subcomponent of component B + 1.0.0 + 2021-01-01 + + content.7z + 36d374bbbfbe87a18f6b308e5398360e9cc54a84 + + diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z new file mode 100644 index 000000000..adcc21ad7 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z new file mode 100644 index 000000000..916fdd1d0 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z new file mode 100644 index 000000000..ab63152f8 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z new file mode 100644 index 000000000..7b957b077 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml new file mode 100644 index 000000000..5276637ed --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/Updates.xml @@ -0,0 +1,46 @@ + + {AnyApplication} + 1.0.0 + false + + A + A + Example component A + 2.0.0 + 2021-01-01 + + content.7z + 28cd1210a590a97a9c0507cc39519b55d8f0a08b + + + A.sub1 + A subcomponent 1 + Subcomponent of component A + 1.0.0 + 2021-01-01 + + content.7z + 9295f5a7f58c5e27a1c9ecf580f54a9328085aa5 + + + B + B + Example component B + 2.0.0 + 2021-01-01 + A, A.sub1 + + content.7z + b55f66866b7b909021f517941e921fd183fac7b0 + + + B.sub1 + B subcomponent 1 + Subcomponent of component B + 1.0.0 + 2021-01-01 + + content.7z + 4331736562fc047a4f47263be75f816298cbda30 + + diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z new file mode 100644 index 000000000..adcc21ad7 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z new file mode 100644 index 000000000..916fdd1d0 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z new file mode 100644 index 000000000..ab63152f8 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z new file mode 100644 index 000000000..7b957b077 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml new file mode 100644 index 000000000..ec74ac3e5 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/Updates.xml @@ -0,0 +1,46 @@ + + {AnyApplication} + 1.0.0 + false + + A + A + Example component A + 1.0.0 + 2021-01-01 + + content.7z + dba535b00f3ee2bc8387a299940384af3af3489b + + + A.sub1 + A subcomponent 1 + Subcomponent of component A + 1.0.0 + 2021-01-01 + + content.7z + ca3e5cdf08361775f744a6d6ec1837aae03cdc28 + + + B + B + Example component B + 2.0.0 + 2021-01-01 + A + + content.7z + c30d2146844195d27879e5360e864c4eae7b4cde + + + B.sub1 + B subcomponent 1 + Subcomponent of component B + 1.0.0 + 2021-01-01 + + content.7z + 05124ea8feadb6a5d8d9222cc41898ef72d562bb + + diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z new file mode 100644 index 000000000..adcc21ad7 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z new file mode 100644 index 000000000..916fdd1d0 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z new file mode 100644 index 000000000..ab63152f8 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z new file mode 100644 index 000000000..7b957b077 Binary files /dev/null and b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z differ diff --git a/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml new file mode 100644 index 000000000..b1846f7b1 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/Updates.xml @@ -0,0 +1,46 @@ + + {AnyApplication} + 1.0.0 + false + + A + A + Example component A + 2.0.0 + 2021-01-01 + + content.7z + a0dc47264727fd2e6a6cdd2fa879388eb732ac73 + + + A.sub1 + A subcomponent 1 + Subcomponent of component A + 1.0.0 + 2021-01-01 + + content.7z + 7b5fb2c36cb4a784816c34839d7ce4ac0114df50 + + + B + B + Example component B + 2.0.0 + 2021-01-01 + A + + content.7z + 9baaa7eaca7002ba10addc22306bb9383d2e5b46 + + + B.sub1 + B subcomponent 1 + Subcomponent of component B + 1.0.0 + 2021-01-01 + + content.7z + f840d6cd369d9dc471f0a718ff5c8c000d07d72c + + diff --git a/tests/auto/installer/componentreplace/settings.qrc b/tests/auto/installer/componentreplace/settings.qrc new file mode 100644 index 000000000..706cf91c6 --- /dev/null +++ b/tests/auto/installer/componentreplace/settings.qrc @@ -0,0 +1,29 @@ + + + data/installPackagesRepository/Updates.xml + data/installPackagesRepository/A/1.0.0content.7z + data/installPackagesRepository/B/1.0.0content.7z + data/installPackagesRepository/A.sub1/1.0.0content.7z + data/installPackagesRepository/B.sub1/1.0.0content.7z + data/repositoryWithReplace/Updates.xml + data/repositoryWithReplace/A/1.0.0content.7z + data/repositoryWithReplace/B/2.0.0content.7z + data/repositoryWithReplace/A.sub1/1.0.0content.7z + data/repositoryWithReplace/B.sub1/1.0.0content.7z + data/repositoryWithUpdateToReplaceble/Updates.xml + data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z + data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z + data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z + data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z + data/repositoryWithMultiReplace/Updates.xml + data/repositoryWithMultiReplace/A/1.0.0content.7z + data/repositoryWithMultiReplace/B/1.0.0content.7z + data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z + data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z + data/repositoryWithMultiReplaceInUpdate/Updates.xml + data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z + data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z + data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z + data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z + + diff --git a/tests/auto/installer/componentreplace/tst_componentreplace.cpp b/tests/auto/installer/componentreplace/tst_componentreplace.cpp new file mode 100644 index 000000000..55121019b --- /dev/null +++ b/tests/auto/installer/componentreplace/tst_componentreplace.cpp @@ -0,0 +1,220 @@ +/************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include "../shared/packagemanager.h" +#include "../shared/verifyinstaller.h" + +#include +#include + +#include +#include + +using namespace QInstaller; + +class tst_ComponentReplace : public QObject +{ + Q_OBJECT + +private: + void setRepository(const QString &repository, PackageManagerCore *core) + { + core->cancelMetaInfoJob(); //Call cancel to reset metadata so that update repositories are fetched + + QSet repoList; + Repository repo = Repository::fromUserInput(repository); + repoList.insert(repo); + core->settings().setDefaultRepositories(repoList); + } + +private slots: + void initTestCase() + { + m_installDir = QInstaller::generateTemporaryFileName(); + } + + void replaceNonInstalledItem() + { + QScopedPointer core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/repositoryWithReplace")); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + QList installedComponents = core->orderedComponentsToInstall(); + + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + } + + void replaceInstalledItem() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 2); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"); + + core->commitSessionOperations(); + core->setPackageManager(); + setRepository(":///data/repositoryWithReplace", core); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "B")); + + QVERIFY(core->componentByName("B.sub1") != 0); + QVERIFY(core->componentByName("B") != 0); + QVERIFY(core->componentByName("A.sub1") != 0); + QVERIFY(core->componentByName("A") == 0); // B has replaced A + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceInstalledItemInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithReplace", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceInstalledItemContainingUpdateInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithUpdateToReplaceble", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt" << "Asub1.txt"); + delete core; + } + + void replaceMultipleInstalledItems() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A")); + + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"); + + core->commitSessionOperations(); + core->setPackageManager(); + setRepository(":///data/repositoryWithMultiReplace", core); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + delete core; + } + + void replaceMultipleInstalledItemsInUpdate() + { + PackageManagerCore *core = PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/installPackagesRepository"); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + + QCOMPARE(core->orderedComponentsToInstall().count(), 4); + VerifyInstaller::verifyInstallerResources(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Asub1.txt" << "A.txt"<< "Bsub1.txt" << "B.txt"); + + core->commitSessionOperations(); + core->setUpdater(); + setRepository(":///data/repositoryWithMultiReplaceInUpdate", core); + QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList() << "B")); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "A.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B", "2.0.0content.txt"); + VerifyInstaller::verifyInstallerResources(m_installDir, "B.sub1", "1.0.0content.txt"); + VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" + << "Bsub1.txt" << "B.txt"); + delete core; + } + + void cleanup() + { + QDir dir(m_installDir); + QVERIFY(dir.removeRecursively()); + } +private: + QString m_installDir; +}; + + +QTEST_MAIN(tst_ComponentReplace) + +#include "tst_componentreplace.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index b877e5d20..947dc92a2 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -41,7 +41,8 @@ SUBDIRS += \ elevatedexecuteoperation \ treename \ createoffline \ - contentshaupdate + contentshaupdate \ + componentreplace CONFIG(libarchive) { SUBDIRS += libarchivearchive -- cgit v1.2.3