diff options
author | Katja Marttila <katja.marttila@qt.io> | 2022-01-06 14:26:03 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2022-01-11 12:50:15 +0200 |
commit | eb8b24f8e3466ecfccb4975dd76c224847d34dd0 (patch) | |
tree | ae1be03b22f61c358b93fab0eef697fdc270ae97 /tests | |
parent | c048aecb4858286a1516dba50317b4568f0d5c3d (diff) |
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 <arttu.tarkiainen@qt.io>
Diffstat (limited to 'tests')
29 files changed, 489 insertions, 1 deletions
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 Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/A.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/A/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/B.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/installPackagesRepository/B/1.0.0content.7z 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 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>53892cfe4d5f5b978553d3aa172944117604ef9c</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>8bd5a1d2525cfdfb690a3c80165aeed44a17795f</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>b2d03273f01f45878c3f5081cc8502edc0826e08</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>a10463141e30ce3fede9ac84bc52a07b0c5e919e</SHA1> + </PackageUpdate> +</Updates> 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 Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/A/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplace/B/1.0.0content.7z 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 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>dd48e40f2f86559b20288424a6a3e2a1a05a172d</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>f8ff5da138516b1f800e641ab4999301dcb3c78b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A, A.sub1</Replaces> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>8e83334a4a3c9c9d2bb6b073858d980da2c8871f</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>36d374bbbfbe87a18f6b308e5398360e9cc54a84</SHA1> + </PackageUpdate> +</Updates> 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 Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z 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 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" OS="Any" CompressedSize="224"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>28cd1210a590a97a9c0507cc39519b55d8f0a08b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" OS="Any" CompressedSize="247"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9295f5a7f58c5e27a1c9ecf580f54a9328085aa5</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A, A.sub1</Replaces> + <UpdateFile UncompressedSize="74" OS="Any" CompressedSize="224"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>b55f66866b7b909021f517941e921fd183fac7b0</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" OS="Any" CompressedSize="247"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>4331736562fc047a4f47263be75f816298cbda30</SHA1> + </PackageUpdate> +</Updates> 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 Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/A/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithReplace/B/2.0.0content.7z 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 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>dba535b00f3ee2bc8387a299940384af3af3489b</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>ca3e5cdf08361775f744a6d6ec1837aae03cdc28</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A</Replaces> + <UpdateFile UncompressedSize="74" CompressedSize="224" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>c30d2146844195d27879e5360e864c4eae7b4cde</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile UncompressedSize="89" CompressedSize="247" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>05124ea8feadb6a5d8d9222cc41898ef72d562bb</SHA1> + </PackageUpdate> +</Updates> 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 Binary files differnew file mode 100644 index 000000000..adcc21ad7 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..916fdd1d0 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..ab63152f8 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..7b957b077 --- /dev/null +++ b/tests/auto/installer/componentreplace/data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z 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 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>A</Name> + <DisplayName>A</DisplayName> + <Description>Example component A</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>a0dc47264727fd2e6a6cdd2fa879388eb732ac73</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>A.sub1</Name> + <DisplayName>A subcomponent 1</DisplayName> + <Description>Subcomponent of component A</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="247" OS="Any" UncompressedSize="89"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>7b5fb2c36cb4a784816c34839d7ce4ac0114df50</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>2.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Replaces>A</Replaces> + <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9baaa7eaca7002ba10addc22306bb9383d2e5b46</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B.sub1</Name> + <DisplayName>B subcomponent 1</DisplayName> + <Description>Subcomponent of component B</Description> + <Version>1.0.0</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <UpdateFile CompressedSize="247" OS="Any" UncompressedSize="89"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>f840d6cd369d9dc471f0a718ff5c8c000d07d72c</SHA1> + </PackageUpdate> +</Updates> 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 @@ +<RCC> + <qresource prefix="/"> + <file>data/installPackagesRepository/Updates.xml</file> + <file>data/installPackagesRepository/A/1.0.0content.7z</file> + <file>data/installPackagesRepository/B/1.0.0content.7z</file> + <file>data/installPackagesRepository/A.sub1/1.0.0content.7z</file> + <file>data/installPackagesRepository/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithReplace/Updates.xml</file> + <file>data/repositoryWithReplace/A/1.0.0content.7z</file> + <file>data/repositoryWithReplace/B/2.0.0content.7z</file> + <file>data/repositoryWithReplace/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithReplace/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/Updates.xml</file> + <file>data/repositoryWithUpdateToReplaceble/A/2.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/B/2.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithUpdateToReplaceble/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/Updates.xml</file> + <file>data/repositoryWithMultiReplace/A/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/B/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplace/B.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/Updates.xml</file> + <file>data/repositoryWithMultiReplaceInUpdate/A/2.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/B/2.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/A.sub1/1.0.0content.7z</file> + <file>data/repositoryWithMultiReplaceInUpdate/B.sub1/1.0.0content.7z</file> + </qresource> +</RCC> 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 <component.h> +#include <packagemanagercore.h> + +#include <QLoggingCategory> +#include <QTest> + +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<Repository> repoList; + Repository repo = Repository::fromUserInput(repository); + repoList.insert(repo); + core->settings().setDefaultRepositories(repoList); + } + +private slots: + void initTestCase() + { + m_installDir = QInstaller::generateTemporaryFileName(); + } + + void replaceNonInstalledItem() + { + QScopedPointer<PackageManagerCore> core(PackageManager::getPackageManagerWithInit + (m_installDir, ":///data/repositoryWithReplace")); + QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList() << "A" << "B")); + QList<Component*> 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 |