summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-12-02 16:36:26 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-02-16 13:16:52 +0200
commit8997ec51b7603fafe5cd34dcff21ba1151c76f32 (patch)
tree0e07bb85141d742f2e3b327f410129685afade99 /src
parent5b55a71adb283d8e335cd724c2b7b66acf3551a5 (diff)
Add unit tests for offline generation
This also changes some of the return values in our CLI-related functions in PackageManagerCore class to better catch cases where we exit without failing but also without doing anything. Also adapt existing tests. Task-number: QTIFW-2028 Change-Id: I73c4ca1b20d439773d0e290195f137d0d7369d17 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-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
3 files changed, 9 insertions, 3 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;