diff options
Diffstat (limited to 'tests/auto/installer/createoffline')
22 files changed, 310 insertions, 0 deletions
diff --git a/tests/auto/installer/createoffline/createoffline.pro b/tests/auto/installer/createoffline/createoffline.pro new file mode 100644 index 000000000..5f14bf0bd --- /dev/null +++ b/tests/auto/installer/createoffline/createoffline.pro @@ -0,0 +1,9 @@ +include(../../qttest.pri) + +QT -= gui +QT += testlib + +SOURCES = tst_createoffline.cpp + +RESOURCES += settings.qrc \ + ..\shared\config.qrc diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-license/2020-12-01-1511_meta.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-license/2020-12-01-1511_meta.7z Binary files differnew file mode 100644 index 000000000..31ffc5764 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/2020-12-01-1511_meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-license/Updates.xml b/tests/auto/installer/createoffline/data/repository-bothmeta-license/Updates.xml new file mode 100644 index 000000000..064fc6529 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/Updates.xml @@ -0,0 +1,22 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>org.qtproject.ifw.example.licenseagreement</Name> + <DisplayName>README (requires license agreement)</DisplayName> + <Description>README can only be installed if the user agrees to the licenses.</Description> + <ReleaseDate>2021-01-01</ReleaseDate> + <Version>1.0.0-1</Version> + <Default>true</Default> + <UpdateFile CompressedSize="282" OS="Any" UncompressedSize="116"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <Licenses> + <License name="Creative Commons (CC0 1.0)" file="cc0.txt"/> + <License name="GNU GENERAL PUBLIC LICENSE Version 3" file="gpl3.txt"/> + </Licenses> + <SHA1>6d6a4cead84562b7034fcf1b9975779f1f030151</SHA1> + </PackageUpdate> + <SHA1>6d6a4cead84562b7034fcf1b9975779f1f030151</SHA1> + <MetadataName>2020-12-01-1511_meta.7z</MetadataName> +</Updates> diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..d80146aa8 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z.sha1 b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..49df32fea --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +192106030e00704e880fb729c3f7bed8ced8db92
\ No newline at end of file diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1meta.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1meta.7z Binary files differnew file mode 100644 index 000000000..31ffc5764 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7z Binary files differnew file mode 100644 index 000000000..93f95c1d7 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/Updates.xml b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/Updates.xml new file mode 100644 index 000000000..cc0ae0206 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/Updates.xml @@ -0,0 +1,20 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>or.qtproject.ifw.example.openreadme</Name> + <DisplayName>Open readme</DisplayName> + <Description>Show checkbox asking whether to open Readme at the end</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Default>true</Default> + <Script>installscript.qs</Script> + <UpdateFile UncompressedSize="49" OS="Any" CompressedSize="215"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <UserInterfaces>readmecheckboxform.ui</UserInterfaces> + <SHA1>9b8977a50cb49a77a6ff037d776b73c341412a25</SHA1> + </PackageUpdate> + <SHA1>9b8977a50cb49a77a6ff037d776b73c341412a25</SHA1> + <MetadataName>2020-12-01-1524_meta.7z</MetadataName> +</Updates> diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..98154743c --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z.sha1 b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..154c20383 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +27cdf6cc53d2317aa2a869cb3f93e7a54c489b5f
\ No newline at end of file diff --git a/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1meta.7z b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1meta.7z Binary files differnew file mode 100644 index 000000000..93f95c1d7 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-script/Updates.xml b/tests/auto/installer/createoffline/data/repository-componentmeta-script/Updates.xml new file mode 100644 index 000000000..42458e7ce --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-script/Updates.xml @@ -0,0 +1,17 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>org.qtproject.ifw.example</Name> + <DisplayName>README.txt</DisplayName> + <Description>A README.txt, accessible through a start menu entry.</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Default>true</Default> + <Script>installscript.qs</Script> + <UpdateFile UncompressedSize="131" CompressedSize="297" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>08c2a05d861543e88a8808f576d5c731e0301ab4</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..40ebd637a --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..d1c96e12b --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +d9ad62d190d93c92175741c02d17aa6c39b0e03d
\ No newline at end of file diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1meta.7z b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1meta.7z Binary files differnew file mode 100644 index 000000000..f35ec6071 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-missingdependency/Updates.xml b/tests/auto/installer/createoffline/data/repository-missingdependency/Updates.xml new file mode 100644 index 000000000..2ec3a5ac4 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-missingdependency/Updates.xml @@ -0,0 +1,22 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>example.with.unstable.dependency</Name> + <DisplayName>README.txt</DisplayName> + <Description>A README.txt, accessible through a start menu entry.</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Default>false</Default> + <Dependencies>missing.dependency.component</Dependencies> + </PackageUpdate> + <PackageUpdate> + <Name>example.without.unstable.dependency</Name> + <DisplayName>README.txt</DisplayName> + <Description>A README.txt, accessible through a start menu entry.</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2013-01-01</ReleaseDate> + <Default>false</Default> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/2020-12-01-1519_meta.7z b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/2020-12-01-1519_meta.7z Binary files differnew file mode 100644 index 000000000..e96ed9ec0 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/2020-12-01-1519_meta.7z diff --git a/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/Updates.xml b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/Updates.xml new file mode 100644 index 000000000..e0826ae86 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/Updates.xml @@ -0,0 +1,18 @@ +<Updates> + <ApplicationName>{AnyApplication}</ApplicationName> + <ApplicationVersion>1.0.0</ApplicationVersion> + <Checksum>true</Checksum> + <PackageUpdate> + <Name>org.qtproject.ifw.example</Name> + <DisplayName>README.txt</DisplayName> + <Description>A README.txt, accessible through a start menu entry.</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2021-01-01</ReleaseDate> + <Default>true</Default> + <Script>installscript.qs</Script> + <UpdateFile OS="Any" CompressedSize="297" UncompressedSize="131"/> + <DownloadableArchives>content.7z</DownloadableArchives> + </PackageUpdate> + <SHA1>70ff1e1062ada01ea698a908f7549fcb826f17e1</SHA1> + <MetadataName>2020-12-01-1519_meta.7z</MetadataName> +</Updates> diff --git a/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..40ebd637a --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z diff --git a/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..d1c96e12b --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +d9ad62d190d93c92175741c02d17aa6c39b0e03d
\ No newline at end of file diff --git a/tests/auto/installer/createoffline/settings.qrc b/tests/auto/installer/createoffline/settings.qrc new file mode 100644 index 000000000..2c546d7f2 --- /dev/null +++ b/tests/auto/installer/createoffline/settings.qrc @@ -0,0 +1,27 @@ +<RCC> + <qresource prefix="/"> + <file>data/repository-bothmeta-license/2020-12-01-1511_meta.7z</file> + <file>data/repository-bothmeta-license/Updates.xml</file> + <file>data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z</file> + <file>data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z.sha1</file> + <file>data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1meta.7z</file> + + <file>data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7z</file> + <file>data/repository-bothmeta-userinteface/Updates.xml</file> + <file>data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z</file> + <file>data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z.sha1</file> + <file>data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1meta.7z</file> + + <file>data/repository-componentmeta-script/Updates.xml</file> + <file>data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z</file> + <file>data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1</file> + <file>data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1meta.7z</file> + + <file>data/repository-missingdependency/Updates.xml</file> + + <file>data/repository-unifiedmeta-script/2020-12-01-1519_meta.7z</file> + <file>data/repository-unifiedmeta-script/Updates.xml</file> + <file>data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z</file> + <file>data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/createoffline/tst_createoffline.cpp b/tests/auto/installer/createoffline/tst_createoffline.cpp new file mode 100644 index 000000000..474b1d5de --- /dev/null +++ b/tests/auto/installer/createoffline/tst_createoffline.cpp @@ -0,0 +1,171 @@ +/************************************************************************** +** +** 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 <packagemanagercore.h> +#include <errors.h> + +#include <QFile> +#include <QTest> + +using namespace QInstaller; + +class tst_CreateOffline : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase() + { + // Need to provide a replacement base binary as we are not running actual installer +#ifdef Q_OS_WIN + m_installerBase = "../../../../bin/installerbase.exe"; +#else + m_installerBase = "../../../../bin/installerbase"; +#endif + if (!QFile(m_installerBase).exists()) { + QSKIP("No \"installerbase\" binary found in source tree. This can be " + "the case if this is an out of sources build or the binaries are " + "installed to a location with a different path prefix."); + } + } + + void init() + { + // Get new target directory for each test function + m_targetDir = QInstaller::generateTemporaryFileName(); + } + + void cleanup() + { + QDir dir(m_targetDir); + QVERIFY(dir.removeRecursively()); + } + + void testCreateOfflineInstaller_data() + { + QTest::addColumn<QString>("repository"); + QTest::addColumn<QString>("component"); + QTest::addColumn<PackageManagerCore::Status>("expectedStatus"); + QTest::newRow("Both metaformats | License") + << ":///data/repository-bothmeta-license" << "org.qtproject.ifw.example.licenseagreement" + << PackageManagerCore::Success; + QTest::newRow("Both metaformats | UserInterface") + << ":///data/repository-bothmeta-userinteface" << "or.qtproject.ifw.example.openreadme" + << PackageManagerCore::Success; + QTest::newRow("Component metaformat | Script") + << ":///data/repository-componentmeta-script" << "org.qtproject.ifw.example" + << PackageManagerCore::Success; + QTest::newRow("Unified metaformat | Script") + << ":///data/repository-unifiedmeta-script" << "org.qtproject.ifw.example" + << PackageManagerCore::Success; + QTest::newRow("Non-existing component") + << ":///data/repository-unifiedmeta-script" << "a.dummy.component" + << PackageManagerCore::Canceled; + QTest::newRow("Invalid repository") + << ":///data/repository-invalid" << "a.dummy.component" + << PackageManagerCore::Failure; + } + + void testCreateOfflineInstaller() + { + QFETCH(QString, repository); + QFETCH(QString, component); + QFETCH(PackageManagerCore::Status, expectedStatus); + + PackageManagerCore *core = PackageManager::getPackageManagerWithInit(m_targetDir, repository); + core->setCommandLineInstance(true); + core->setOfflineBaseBinary(m_installerBase); + core->setOfflineBinaryName("ifw_test_offline"); + core->setAutoAcceptLicenses(); + + // Replace the custom message handler installed in QInstaller::init() to suppress all output + qInstallMessageHandler(silentTestMessageHandler); + + QCOMPARE(expectedStatus, core->createOfflineInstaller(QStringList() << component)); + + if (expectedStatus == PackageManagerCore::Success) { +#ifdef Q_OS_LINUX + QVERIFY(QFile::exists(m_targetDir + QDir::separator() + "ifw_test_offline")); +#elif defined Q_OS_MACOS + QVERIFY(QFile::exists(m_targetDir + QDir::separator() + "ifw_test_offline.dmg")); +#elif defined Q_OS_WIN + QVERIFY(QFile::exists(m_targetDir + QDir::separator() + "ifw_test_offline.exe")); +#endif + } + } + + void testCreateOfflineWithUnstableComponent_data() + { + QTest::addColumn<QString>("repository"); + QTest::addColumn<QString>("component"); + QTest::addColumn<bool>("allowUnstable"); + QTest::addColumn<PackageManagerCore::Status>("expectedStatus"); + QTest::newRow("Allow unstable | Missing dependency with selected component") + << ":///data/repository-missingdependency" << "example.with.unstable.dependency" + << true << PackageManagerCore::Canceled; + QTest::newRow("Disallow unstable | Missing dependency with selected component") + << ":///data/repository-missingdependency" << "example.with.unstable.dependency" + << false << PackageManagerCore::Failure; + QTest::newRow("Allow unstable | Missing dependency with other component") + << ":///data/repository-missingdependency" << "example.without.unstable.dependency" + << true << PackageManagerCore::Success; + QTest::newRow("Disallow unstable | Missing dependency with other component") + << ":///data/repository-missingdependency" << "example.without.unstable.dependency" + << false << PackageManagerCore::Failure; + } + + void testCreateOfflineWithUnstableComponent() + { + QFETCH(QString, repository); + QFETCH(QString, component); + QFETCH(bool, allowUnstable); + QFETCH(PackageManagerCore::Status, expectedStatus); + + PackageManagerCore *core = PackageManager::getPackageManagerWithInit(m_targetDir, repository); + core->setCommandLineInstance(true); + core->setOfflineBaseBinary(m_installerBase); + core->setOfflineBinaryName("ifw_test_offline"); + core->settings().setAllowUnstableComponents(allowUnstable); + core->autoAcceptMessageBoxes(); + + // Replace the custom message handler installed in QInstaller::init() to suppress all output + qInstallMessageHandler(silentTestMessageHandler); + + QCOMPARE(expectedStatus, core->createOfflineInstaller(QStringList() << component)); + } + +private: + QString m_targetDir; + QString m_installerBase; +}; + +QTEST_GUILESS_MAIN(tst_CreateOffline) + +#include "tst_createoffline.moc" |