From 3d971b71bfff2bd8afd243151beb45ad944fbfdf Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 7 Apr 2020 14:00:12 +0300 Subject: Add CLI test for SettingsOperation Task-number: QTIFW-1711 Change-Id: Iccdeb5938c0034466bd1018a0beda415dd40da2e Reviewed-by: Iikka Eklund --- .../data/repository/A/1.0.2-1meta.7z | Bin 0 -> 947 bytes .../settingsoperation/data/repository/Updates.xml | 13 +++++++ .../auto/installer/settingsoperation/settings.qrc | 6 +++ .../settingsoperation/settingsoperation.pro | 3 ++ .../settingsoperation/tst_settingsoperation.cpp | 41 +++++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7z create mode 100644 tests/auto/installer/settingsoperation/data/repository/Updates.xml create mode 100644 tests/auto/installer/settingsoperation/settings.qrc 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 Binary files /dev/null and b/tests/auto/installer/settingsoperation/data/repository/A/1.0.2-1meta.7z 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 @@ + + {AnyApplication} + 1.0.0 + + A + A + Example component A + 1.0.2-1 + 2015-01-01 + true + + + 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 @@ + + + data/repository/Updates.xml + data/repository/A/1.0.2-1meta.7z + + 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 #include #include +#include +#include +#include +#include +#include #include #include @@ -280,6 +285,42 @@ private slots: } } + void testPerformingFromCLI() + { + QInstaller::init(); //This will eat debug output + PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList ()); + + core->setAllowedRunningProcesses(QStringList() << QCoreApplication::applicationFilePath()); + QSet 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() { -- cgit v1.2.3