diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2020-04-01 11:37:03 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2020-04-03 09:24:40 +0300 |
commit | 13231b60b21da042dd9285c43c9cf2fd310cf144 (patch) | |
tree | da0e31bd611531b19a2c7dccd2c94758e2f70203 /tests | |
parent | 6d7e9850da3cac9702d7acdb569cf5ec865966e0 (diff) |
Add CLI test for ReplaceOperation
Task-number: QTIFW-1720
Change-Id: I2b4f1c7fd83bdb50a8eeba55f9dc632219e7c3c7
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1content.7z | bin | 0 -> 185 bytes | |||
-rw-r--r-- | tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1meta.7z | bin | 0 -> 912 bytes | |||
-rw-r--r-- | tests/auto/installer/replaceoperation/data/repository/Updates.xml | 15 | ||||
-rw-r--r-- | tests/auto/installer/replaceoperation/replaceoperation.pro | 4 | ||||
-rw-r--r-- | tests/auto/installer/replaceoperation/settings.qrc | 7 | ||||
-rw-r--r-- | tests/auto/installer/replaceoperation/tst_replaceoperation.cpp | 31 |
6 files changed, 56 insertions, 1 deletions
diff --git a/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1content.7z b/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1content.7z Binary files differnew file mode 100644 index 000000000..8ba90b13b --- /dev/null +++ b/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1content.7z diff --git a/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1meta.7z b/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1meta.7z Binary files differnew file mode 100644 index 000000000..b50c31cbd --- /dev/null +++ b/tests/auto/installer/replaceoperation/data/repository/A/1.0.2-1meta.7z diff --git a/tests/auto/installer/replaceoperation/data/repository/Updates.xml b/tests/auto/installer/replaceoperation/data/repository/Updates.xml new file mode 100644 index 000000000..a0ade298c --- /dev/null +++ b/tests/auto/installer/replaceoperation/data/repository/Updates.xml @@ -0,0 +1,15 @@ +<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> + <UpdateFile CompressedSize="225" UncompressedSize="75" OS="Any"/> + <DownloadableArchives>content.7z</DownloadableArchives> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/replaceoperation/replaceoperation.pro b/tests/auto/installer/replaceoperation/replaceoperation.pro index d2756d153..bc558c32e 100644 --- a/tests/auto/installer/replaceoperation/replaceoperation.pro +++ b/tests/auto/installer/replaceoperation/replaceoperation.pro @@ -4,3 +4,7 @@ QT -= gui QT += testlib SOURCES += tst_replaceoperation.cpp + +RESOURCES += \ + settings.qrc \ + ..\shared\config.qrc diff --git a/tests/auto/installer/replaceoperation/settings.qrc b/tests/auto/installer/replaceoperation/settings.qrc new file mode 100644 index 000000000..10cc3c3bb --- /dev/null +++ b/tests/auto/installer/replaceoperation/settings.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>data/repository/Updates.xml</file> + <file>data/repository/A/1.0.2-1content.7z</file> + <file>data/repository/A/1.0.2-1meta.7z</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/replaceoperation/tst_replaceoperation.cpp b/tests/auto/installer/replaceoperation/tst_replaceoperation.cpp index 9afd91875..88a3350a7 100644 --- a/tests/auto/installer/replaceoperation/tst_replaceoperation.cpp +++ b/tests/auto/installer/replaceoperation/tst_replaceoperation.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -29,6 +29,10 @@ #include <fileutils.h> #include <replaceoperation.h> #include <qinstallerglobal.h> +#include <packagemanagercore.h> +#include <binarycontent.h> +#include <settings.h> +#include <init.h> #include <QObject> #include <QDir> @@ -174,6 +178,31 @@ private slots: QVERIFY(QDir().rmdir(m_testDirectory)); } + void testPerformingFromCLI() + { + QInstaller::init(); //This will eat debug output + PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, + QList<OperationBlob> ()); + QSet<Repository> repoList; + Repository repo = Repository::fromUserInput(":///data/repository"); + repoList.insert(repo); + core->settings().setDefaultRepositories(repoList); + + QVERIFY(QDir().mkpath(m_testDirectory)); + core->setValue(scTargetDir, m_testDirectory); + core->installDefaultComponentsSilently(); + + QFile file(m_testDirectory + QDir::separator() + "A.txt"); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); + QTextStream stream(&file); + QCOMPARE(stream.readLine(), QLatin1String("text to replace.")); + QCOMPARE(stream.readLine(), QLatin1String("Another text.")); + file.close(); + QDir dir(m_testDirectory); + QVERIFY(dir.removeRecursively()); + core->deleteLater(); + } + private: QString m_testDirectory; QString m_testFilePath; |