summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/replaceoperation/tst_replaceoperation.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-04-01 11:37:03 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2020-04-03 09:24:40 +0300
commit13231b60b21da042dd9285c43c9cf2fd310cf144 (patch)
treeda0e31bd611531b19a2c7dccd2c94758e2f70203 /tests/auto/installer/replaceoperation/tst_replaceoperation.cpp
parent6d7e9850da3cac9702d7acdb569cf5ec865966e0 (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/auto/installer/replaceoperation/tst_replaceoperation.cpp')
-rw-r--r--tests/auto/installer/replaceoperation/tst_replaceoperation.cpp31
1 files changed, 30 insertions, 1 deletions
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;