summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-04-07 14:00:12 +0300
committerKatja Marttila <katja.marttila@qt.io>2020-04-08 07:00:03 +0300
commit3d971b71bfff2bd8afd243151beb45ad944fbfdf (patch)
treec670c7877362d25254016f1cd6c0683e5004a361
parent21aef7e78341b1931ca029dda5e5118172bdaafa (diff)
Add CLI test for SettingsOperation
Task-number: QTIFW-1711 Change-Id: Iccdeb5938c0034466bd1018a0beda415dd40da2e Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7zbin0 -> 947 bytes
-rw-r--r--tests/auto/installer/settingsoperation/data/repository/Updates.xml13
-rw-r--r--tests/auto/installer/settingsoperation/settings.qrc6
-rw-r--r--tests/auto/installer/settingsoperation/settingsoperation.pro3
-rw-r--r--tests/auto/installer/settingsoperation/tst_settingsoperation.cpp41
5 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7z b/tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7z
new file mode 100644
index 000000000..fb1e30f49
--- /dev/null
+++ b/tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7z
Binary files differ
diff --git a/tests/auto/installer/settingsoperation/data/repository/Updates.xml b/tests/auto/installer/settingsoperation/data/repository/Updates.xml
new file mode 100644
index 000000000..77b5a9956
--- /dev/null
+++ b/tests/auto/installer/settingsoperation/data/repository/Updates.xml
@@ -0,0 +1,13 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <PackageUpdate>
+ <Name>A</Name>
+ <DisplayName>A</DisplayName>
+ <Description>Example component A</Description>
+ <Version>1.0.2-1</Version>
+ <ReleaseDate>2015-01-01</ReleaseDate>
+ <Default>true</Default>
+ <Script>script.qs</Script>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/settingsoperation/settings.qrc b/tests/auto/installer/settingsoperation/settings.qrc
new file mode 100644
index 000000000..d030220ab
--- /dev/null
+++ b/tests/auto/installer/settingsoperation/settings.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>data/repository/Updates.xml</file>
+ <file>data/repository/A/1.0.2-1meta.7z</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/installer/settingsoperation/settingsoperation.pro b/tests/auto/installer/settingsoperation/settingsoperation.pro
index 60ddd329b..b5faa933e 100644
--- a/tests/auto/installer/settingsoperation/settingsoperation.pro
+++ b/tests/auto/installer/settingsoperation/settingsoperation.pro
@@ -4,3 +4,6 @@ QT -= gui
QT += testlib
SOURCES += tst_settingsoperation.cpp
+
+RESOURCES += settings.qrc\
+ ..\shared\config.qrc
diff --git a/tests/auto/installer/settingsoperation/tst_settingsoperation.cpp b/tests/auto/installer/settingsoperation/tst_settingsoperation.cpp
index ced0e6f36..3832b1c59 100644
--- a/tests/auto/installer/settingsoperation/tst_settingsoperation.cpp
+++ b/tests/auto/installer/settingsoperation/tst_settingsoperation.cpp
@@ -28,6 +28,11 @@
#include <utils.h>
#include <settingsoperation.h>
#include <qinstallerglobal.h>
+#include <packagemanagercore.h>
+#include <binarycontent.h>
+#include <settings.h>
+#include <fileutils.h>
+#include <init.h>
#include <QObject>
#include <QTest>
@@ -280,6 +285,42 @@ private slots:
}
}
+ void testPerformingFromCLI()
+ {
+ QInstaller::init(); //This will eat debug output
+ PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList<OperationBlob> ());
+
+ core->setAllowedRunningProcesses(QStringList() << QCoreApplication::applicationFilePath());
+ QSet<Repository> repoList;
+ Repository repo = Repository::fromUserInput(":///data/repository");
+ repoList.insert(repo);
+ core->settings().setDefaultRepositories(repoList);
+
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QDir().mkpath(installDir);
+ core->setValue(scTargetDir, installDir);
+
+ QSettings testSettings(QDir(m_testSettingsDirPath).filePath(m_testSettingsFilename),
+ QSettings::IniFormat);
+ QCOMPARE(testSettings.value("testcategory/categoryarrayvalue1"), QStringList() << "value1" <<
+ "value2" << "value3");
+
+ core->installDefaultComponentsSilently();
+
+ QCOMPARE(testSettings.value("testcategory/categoryarrayvalue1"), QStringList() << "value1" <<
+ "value2" << "value3" << "valueFromScript");
+
+ core->commitSessionOperations();
+ core->setPackageManager();
+ core->uninstallComponentsSilently(QStringList() << "A");
+
+ QCOMPARE(testSettings.value("testcategory/categoryarrayvalue1"), QStringList() << "value1" <<
+ "value2" << "value3");
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+ }
+
// called after all tests
void cleanupTestCase()
{