summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/installer/packagemanagercore.cpp10
-rw-r--r--src/libs/installer/packagemanagercore.h1
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp1
-rw-r--r--tests/auto/installer/cliinterface/tst_cliinterface.cpp10
-rw-r--r--tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp11
-rw-r--r--tests/auto/installer/createoffline/createoffline.pro9
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-license/2020-12-01-1511_meta.7zbin0 -> 13745 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-license/Updates.xml22
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7zbin0 -> 242 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1content.7z.sha11
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-license/org.qtproject.ifw.example.licenseagreement/1.0.0-1meta.7zbin0 -> 13745 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7zbin0 -> 1489 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/Updates.xml20
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7zbin0 -> 175 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1content.7z.sha11
-rw-r--r--tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/or.qtproject.ifw.example.openreadme/1.0.0-1meta.7zbin0 -> 1489 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-componentmeta-script/Updates.xml17
-rw-r--r--tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7zbin0 -> 257 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha11
-rw-r--r--tests/auto/installer/createoffline/data/repository-componentmeta-script/org.qtproject.ifw.example/1.0.0-1meta.7zbin0 -> 1078 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-missingdependency/Updates.xml22
-rw-r--r--tests/auto/installer/createoffline/data/repository-unifiedmeta-script/2020-12-01-1519_meta.7zbin0 -> 1078 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-unifiedmeta-script/Updates.xml18
-rw-r--r--tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7zbin0 -> 257 bytes
-rw-r--r--tests/auto/installer/createoffline/data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha11
-rw-r--r--tests/auto/installer/createoffline/settings.qrc27
-rw-r--r--tests/auto/installer/createoffline/tst_createoffline.cpp171
-rw-r--r--tests/auto/installer/installer.pro3
-rw-r--r--tests/auto/installer/shared/packagemanager.h2
29 files changed, 330 insertions, 18 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 41744ff96..7528a3188 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -2274,6 +2274,9 @@ bool PackageManagerCore::checkComponentsForInstallation(const QStringList &compo
: errorMessage.append(tr("Cannot install %1. Component not found.\n").arg(name));
}
}
+ if (!installComponentsFound)
+ setCanceled();
+
return installComponentsFound;
}
@@ -2351,7 +2354,7 @@ PackageManagerCore::Status PackageManagerCore::updateComponentsSilently(const QS
if (userSelectedComponents && componentsToBeUpdated.isEmpty()) {
qCDebug(QInstaller::lcInstallerInstallLog)
<< "No updates available for selected components.";
- return PackageManagerCore::Success;
+ return PackageManagerCore::Canceled;
}
foreach (Component *componentToUpdate, componentsToBeUpdated) {
const QModelIndex &idx = model->indexFromComponentName(componentToUpdate->treeName());
@@ -2429,7 +2432,7 @@ PackageManagerCore::Status PackageManagerCore::uninstallComponentsSilently(const
if (components.isEmpty()) {
qCDebug(QInstaller::lcInstallerInstallLog) << "No components selected for uninstallation.";
- return PackageManagerCore::Success;
+ return PackageManagerCore::Canceled;
}
ComponentModel *model = defaultComponentModel();
@@ -2527,7 +2530,7 @@ PackageManagerCore::Status PackageManagerCore::installSelectedComponentsSilently
helperStrList.removeDuplicates();
if (helperStrList.count() == installedPackages.count()) {
qCDebug(QInstaller::lcInstallerInstallLog) << "Components already installed.";
- return PackageManagerCore::Success;
+ return PackageManagerCore::Canceled;
}
}
@@ -2566,6 +2569,7 @@ PackageManagerCore::Status PackageManagerCore::installDefaultComponentsSilently(
}
} else {
qCDebug(QInstaller::lcInstallerInstallLog) << "No components available for default installation.";
+ setCanceled();
}
return status();
}
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index ef94dc79a..c845fb1fa 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -429,5 +429,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(PackageManagerCore::ComponentTypes)
}
Q_DECLARE_METATYPE(QInstaller::PackageManagerCore*)
+Q_DECLARE_METATYPE(QInstaller::PackageManagerCore::Status)
#endif // PACKAGEMANAGERCORE_H
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index fea032ab1..f4670c738 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -459,6 +459,7 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash<QString, Component*> &c
clearInstallerCalculator();
if (installerCalculator()->appendComponentsToInstall(components.values()) == false) {
+ setStatus(PackageManagerCore::Failure, installerCalculator()->componentsToInstallError());
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), QLatin1String("Error"),
tr("Unresolved dependencies"), installerCalculator()->componentsToInstallError());
return false;
diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp
index c3e1eff57..550f45da2 100644
--- a/tests/auto/installer/cliinterface/tst_cliinterface.cpp
+++ b/tests/auto/installer/cliinterface/tst_cliinterface.cpp
@@ -103,24 +103,24 @@ private slots:
QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download...");
QTest::ignoreMessage(QtDebugMsg, "Cannot install component A. Component is installed only as automatic dependency to autoDep.\n");
- QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("A")));
QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download...");
QTest::ignoreMessage(QtDebugMsg, "Cannot install component AB. Component is not checkable meaning you have to select one of the subcomponents.\n");
- QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("AB")));
QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download...");
QTest::ignoreMessage(QtDebugMsg, "Cannot install B. Component is virtual.\n");
- QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("B")));
QTest::ignoreMessage(QtDebugMsg, "Preparing meta information download...");
QTest::ignoreMessage(QtDebugMsg, "Cannot install MissingComponent. Component not found.\n");
- QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
+ QCOMPARE(PackageManagerCore::Canceled, core->installSelectedComponentsSilently(QStringList()
<< QLatin1String("MissingComponent")));
- QCOMPARE(PackageManagerCore::Success, core->status());
+ QCOMPARE(PackageManagerCore::Canceled, core->status());
}
void testUninstallPackageFails()
diff --git a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
index 5a25bbb39..07dad9d31 100644
--- a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
+++ b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
@@ -171,20 +171,13 @@ private slots:
void testUpdateNoUpdatesForSelectedPackage()
{
setRepository(":///data/installPackagesRepositoryUpdate");
- // Succeeds as no updates available for component so nothing to do
- QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()
+ // No updates available for component so nothing to do
+ QCOMPARE(PackageManagerCore::Canceled, core->updateComponentsSilently(QStringList()
<< "componentInvalid"));
}
void testUpdateTwoPackageSilently()
{
- setRepository(":///data/installPackagesRepository");
- QCOMPARE(PackageManagerCore::Success, core->installSelectedComponentsSilently(QStringList()
- << "componentA" << "componentB" << "componentG"));
- VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt");
- VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt");
- core->commitSessionOperations();
-
setRepository(":///data/installPackagesRepositoryUpdate");
QCOMPARE(PackageManagerCore::Success, core->updateComponentsSilently(QStringList()
<< "componentB" << "componentG"));
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
new file mode 100644
index 000000000..31ffc5764
--- /dev/null
+++ b/tests/auto/installer/createoffline/data/repository-bothmeta-license/2020-12-01-1511_meta.7z
Binary files differ
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
new 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
Binary files differ
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
new 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
Binary files differ
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
new file mode 100644
index 000000000..93f95c1d7
--- /dev/null
+++ b/tests/auto/installer/createoffline/data/repository-bothmeta-userinteface/2020-12-01-1524_meta.7z
Binary files differ
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
new 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
Binary files differ
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
new 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
Binary files differ
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
new 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
Binary files differ
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
new 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
Binary files differ
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
new file mode 100644
index 000000000..e96ed9ec0
--- /dev/null
+++ b/tests/auto/installer/createoffline/data/repository-unifiedmeta-script/2020-12-01-1519_meta.7z
Binary files differ
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
new 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
Binary files differ
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"
diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro
index 2f65d607e..114c43d7a 100644
--- a/tests/auto/installer/installer.pro
+++ b/tests/auto/installer/installer.pro
@@ -38,7 +38,8 @@ SUBDIRS += \
licenseagreement \
globalsettingsoperation \
elevatedexecuteoperation \
- treename
+ treename \
+ createoffline
win32 {
SUBDIRS += registerfiletypeoperation \
diff --git a/tests/auto/installer/shared/packagemanager.h b/tests/auto/installer/shared/packagemanager.h
index d5260ef5e..4cc5426ad 100644
--- a/tests/auto/installer/shared/packagemanager.h
+++ b/tests/auto/installer/shared/packagemanager.h
@@ -39,6 +39,8 @@
using namespace QInstaller;
+void silentTestMessageHandler(QtMsgType, const QMessageLogContext &, const QString &) {}
+
struct PackageManager
{
static PackageManagerCore *getPackageManager(const QString &targetDir, const QString &repository = QString())