diff options
Diffstat (limited to 'tests')
16 files changed, 269 insertions, 7 deletions
diff --git a/tests/auto/installer/contentshaupdate/contentshaupdate.pro b/tests/auto/installer/contentshaupdate/contentshaupdate.pro new file mode 100644 index 000000000..84402794f --- /dev/null +++ b/tests/auto/installer/contentshaupdate/contentshaupdate.pro @@ -0,0 +1,9 @@ +include(../../qttest.pri) + +QT += qml + +SOURCES += tst_contentshaupdate.cpp + +RESOURCES += \ + settings.qrc \ + ..\shared\config.qrc diff --git a/tests/auto/installer/contentshaupdate/data/repository/Updates.xml b/tests/auto/installer/contentshaupdate/data/repository/Updates.xml new file mode 100644 index 000000000..a83d41384 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repository/Updates.xml @@ -0,0 +1,48 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>componentA</Name> + <DisplayName>Component A</DisplayName> + <Description>This component does not depend on any other component.</Description> + <Version>1.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>100</SortingPriority> + <UpdateFile OS="Any" CompressedSize="283" UncompressedSize="101"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>10</ContentSha1> + </PackageUpdate> + <PackageUpdate> + <Name>componentB</Name> + <DisplayName>Component B</DisplayName> + <Description>This component does not depend on any other component.</Description> + <Version>1.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>90</SortingPriority> + <UpdateFile OS="Any" CompressedSize="283" UncompressedSize="101"/> + <DownloadableArchives>content.7z</DownloadableArchives> + </PackageUpdate> + <PackageUpdate> + <Name>componentC</Name> + <DisplayName>Component C</DisplayName> + <Description>Component C</Description> + <Version>1.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>80</SortingPriority> + <UpdateFile OS="Any" CompressedSize="283" UncompressedSize="101"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>10</ContentSha1> + </PackageUpdate> + <PackageUpdate> + <Name>componentD</Name> + <DisplayName>Component D</DisplayName> + <Description>Component D</Description> + <Version>1.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>80</SortingPriority> + <UpdateFile CompressedSize="283" UncompressedSize="101" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>10</ContentSha1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/contentshaupdate/data/repository/componentA/1.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repository/componentA/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..46a9f1d1e --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repository/componentA/1.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repository/componentB/1.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repository/componentB/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..5f1fb2e1b --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repository/componentB/1.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repository/componentC/1.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repository/componentC/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..83e82b5a3 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repository/componentC/1.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repository/componentD/1.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repository/componentD/1.0.0content.7z Binary files differnew file mode 100644 index 000000000..da50742a4 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repository/componentD/1.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repositoryUpdate/Updates.xml b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/Updates.xml new file mode 100644 index 000000000..87017cf91 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/Updates.xml @@ -0,0 +1,48 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>false</Checksum> + <PackageUpdate> + <Name>componentA</Name> + <DisplayName>Component A</DisplayName> + <Description>Component A.</Description> + <Version>0.1.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>100</SortingPriority> + <UpdateFile CompressedSize="283" UncompressedSize="101" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>5</ContentSha1> + </PackageUpdate> + <PackageUpdate> + <Name>componentB</Name> + <DisplayName>Component B</DisplayName> + <Description>Component B.</Description> + <Version>0.1.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>90</SortingPriority> + <UpdateFile CompressedSize="283" UncompressedSize="101" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>10</ContentSha1> + </PackageUpdate> + <PackageUpdate> + <Name>componentC</Name> + <DisplayName>Component C</DisplayName> + <Description>Component C</Description> + <Version>2.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>80</SortingPriority> + <UpdateFile CompressedSize="283" UncompressedSize="101" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <ContentSha1>10</ContentSha1> + </PackageUpdate> + <PackageUpdate> + <Name>componentD</Name> + <DisplayName>Component D</DisplayName> + <Description>Component D</Description> + <Version>2.0.0</Version> + <ReleaseDate>2014-08-25</ReleaseDate> + <SortingPriority>80</SortingPriority> + <UpdateFile UncompressedSize="101" CompressedSize="283" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentA/0.1.0content.7z b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentA/0.1.0content.7z Binary files differnew file mode 100644 index 000000000..bdbabc7fd --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentA/0.1.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentB/0.1.0content.7z b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentB/0.1.0content.7z Binary files differnew file mode 100644 index 000000000..1c1129b9f --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentB/0.1.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentC/2.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentC/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..7f75bf503 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentC/2.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentD/2.0.0content.7z b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentD/2.0.0content.7z Binary files differnew file mode 100644 index 000000000..4207dfbf2 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/data/repositoryUpdate/componentD/2.0.0content.7z diff --git a/tests/auto/installer/contentshaupdate/settings.qrc b/tests/auto/installer/contentshaupdate/settings.qrc new file mode 100644 index 000000000..a5d045f46 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/settings.qrc @@ -0,0 +1,14 @@ +<RCC> + <qresource prefix="/"> + <file>data/repository/Updates.xml</file> + <file>data/repository/componentA/1.0.0content.7z</file> + <file>data/repository/componentB/1.0.0content.7z</file> + <file>data/repository/componentC/1.0.0content.7z</file> + <file>data/repository/componentD/1.0.0content.7z</file> + <file>data/repositoryUpdate/Updates.xml</file> + <file>data/repositoryUpdate/componentA/0.1.0content.7z</file> + <file>data/repositoryUpdate/componentB/0.1.0content.7z</file> + <file>data/repositoryUpdate/componentC/2.0.0content.7z</file> + <file>data/repositoryUpdate/componentD/2.0.0content.7z</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/contentshaupdate/tst_contentshaupdate.cpp b/tests/auto/installer/contentshaupdate/tst_contentshaupdate.cpp new file mode 100644 index 000000000..d8d2f5377 --- /dev/null +++ b/tests/auto/installer/contentshaupdate/tst_contentshaupdate.cpp @@ -0,0 +1,108 @@ +/************************************************************************** +** +** Copyright (C) 2021 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 <QTest> + +using namespace QInstaller; + +class tst_ContentSha1Update : public QObject +{ + Q_OBJECT + +private: + void setRepository(const QString &repository) + { + core->reset(); + 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(); + core = PackageManager::getPackageManagerWithInit(m_installDir); + } + + void updateWithContentSha1_data() + { + QTest::addColumn<QString>("component"); + QTest::addColumn<QString>("content"); + QTest::addColumn<QString>("updatedContent"); + QTest::addColumn<PackageManagerCore::Status>("expectedStatusAfterInstall"); + QTest::addColumn<PackageManagerCore::Status>("expectedStatusAfterUpdate"); + + QTest::newRow("ContentSha1Change") << "componentA" << "1.0.0content.txt" << "0.1.0content.txt" << PackageManagerCore::Success << PackageManagerCore::Success; + QTest::newRow("NewContentSha1") << "componentB" << "1.0.0content.txt" << "0.1.0content.txt" << PackageManagerCore::Success << PackageManagerCore::Success; + QTest::newRow("SameContentSha1") << "componentC" << "1.0.0content.txt" << "1.0.0content.txt" << PackageManagerCore::Success << PackageManagerCore::Canceled; + QTest::newRow("Sha1RemovedFromRepo") << "componentD" << "1.0.0content.txt" << "2.0.0content.txt" << PackageManagerCore::Success << PackageManagerCore::Success; + } + + void updateWithContentSha1() + { + QFETCH(QString, component); + QFETCH(QString, content); + QFETCH(QString, updatedContent); + QFETCH(PackageManagerCore::Status, expectedStatusAfterInstall); + QFETCH(PackageManagerCore::Status, expectedStatusAfterUpdate); + + setRepository(":///data/repository"); + QCOMPARE(expectedStatusAfterInstall, core->installSelectedComponentsSilently(QStringList() << component)); + QCOMPARE(expectedStatusAfterInstall, core->status()); + VerifyInstaller::verifyInstallerResources(m_installDir, component, content); + + core->commitSessionOperations(); + core->setPackageManager(); + setRepository(":///data/repositoryUpdate"); + QCOMPARE(expectedStatusAfterUpdate, core->updateComponentsSilently(QStringList())); + VerifyInstaller::verifyInstallerResources(m_installDir, component, updatedContent); + } + + void cleanupTestCase() + { + QDir dir(m_installDir); + QVERIFY(dir.removeRecursively()); + delete core; + } + +private: + QString m_installDir; + PackageManagerCore *core; +}; + + +QTEST_MAIN(tst_ContentSha1Update) + +#include "tst_contentshaupdate.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 114c43d7a..cb0438ab3 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -39,7 +39,8 @@ SUBDIRS += \ globalsettingsoperation \ elevatedexecuteoperation \ treename \ - createoffline + createoffline \ + contentshaupdate win32 { SUBDIRS += registerfiletypeoperation \ diff --git a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp index ae2c3b211..17343e49d 100644 --- a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp +++ b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp @@ -306,7 +306,7 @@ private slots: QTest::ignoreMessage(QtWarningMsg, re); QTest::ignoreMessage(QtDebugMsg, "No updates available."); - QCOMPARE(PackageManagerCore::Failure, core.updateComponentsSilently(QStringList())); + QCOMPARE(PackageManagerCore::Canceled, core.updateComponentsSilently(QStringList())); QVERIFY(QDir().rmdir(testDirectory)); } diff --git a/tests/auto/tools/repotest/tst_repotest.cpp b/tests/auto/tools/repotest/tst_repotest.cpp index 7a8542b7e..228c13c80 100644 --- a/tests/auto/tools/repotest/tst_repotest.cpp +++ b/tests/auto/tools/repotest/tst_repotest.cpp @@ -39,13 +39,13 @@ class tst_repotest : public QObject { Q_OBJECT private: - - void generateRepo(bool createSplitMetadata, bool createUnifiedMetadata, bool updateNewComponents) + void generateRepo(bool createSplitMetadata, bool createUnifiedMetadata, bool updateNewComponents, + QStringList packagesUpdatedWithSha = QStringList()) { QStringList filteredPackages; QInstallerTools::PackageInfoVector m_packages = QInstallerTools::collectPackages(m_repoInfo, - &filteredPackages, QInstallerTools::Exclude, updateNewComponents); + &filteredPackages, QInstallerTools::Exclude, updateNewComponents, packagesUpdatedWithSha); if (updateNewComponents) { //Verify that component B exists as that is not updated if (createSplitMetadata) { @@ -119,11 +119,11 @@ private: void verifyComponentRepository(const QString &componentAVersion, bool hasComponentMeta) { const QString content = "%1content.7z"; - const QString contentSha = "%1content.7z.sha1"; + const QString contentSha1 = "%1content.7z.sha1"; const QString meta = "%1meta.7z"; QStringList componentA; QStringList componentB; - componentA << qPrintable(content.arg(componentAVersion)) << qPrintable(contentSha.arg(componentAVersion)); + componentA << qPrintable(content.arg(componentAVersion)) << qPrintable(contentSha1.arg(componentAVersion)); componentB << "1.0.0content.7z" << "1.0.0content.7z.sha1"; if (hasComponentMeta) { componentA << qPrintable(meta.arg(componentAVersion)); @@ -257,6 +257,20 @@ private: QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(m_repoInfo.repositoryDir))); } + void verifyComponentShaUpdate(int shaUpdateComponents) + { + QString updatesXmlFile(m_repoInfo.repositoryDir + QDir::separator() + "Updates.xml"); + QFile file(updatesXmlFile); + QDomDocument dom; + + QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(dom.setContent(&file)); + file.close(); + QCOMPARE(dom.elementsByTagName("ContentSha1").count(), shaUpdateComponents); + VerifyInstaller::verifyFileContent(updatesXmlFile, + "<ContentSha1>059e5ed8cd3a1fbca08cccfa4075265192603e3f</ContentSha1>"); + } + private slots: void init() { @@ -305,6 +319,26 @@ private slots: verifyUniteMetadata("1.0.0"); } + void testWithComponentShaUpdate() + { + ignoreMessagesForComponentSha(QStringList () << "A" << "B", false); + generateRepo(true, false, false, QStringList () << "A"); + + verifyComponentRepository("1.0.0", true); + verifyComponentMetaUpdatesXml(); + verifyComponentShaUpdate(1); + } + + void testWithTwoComponentsShaUpdate() + { + ignoreMessagesForComponentSha(QStringList () << "A" << "B", false); + generateRepo(true, false, false, QStringList () << "A" << "B"); + + verifyComponentRepository("1.0.0", true); + verifyComponentMetaUpdatesXml(); + verifyComponentShaUpdate(2); + } + void testUpdateNewComponents() { // Create 'base' repository which will be updated |