summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-11-19 07:25:01 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-12-07 07:36:36 +0200
commite82ab45ed71d9b807dc23eae559c759f4584b79d (patch)
tree1ff8a7379a7c0fbd1908783404babd9b83e4d414
parentb43ab89a64c6484a8af4be424ab695b956d7f7bc (diff)
Add option to define operations in component.xml
Operations can from now on be declared also in component.xml. The operations are performed, backuped and rollbacked the same way as they would be when defined from scripting api. Task-number: QTIFW-507 Change-Id: Ia509219b94737136c3de25db0cb0c72076b48380 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--doc/examples/package.xml13
-rw-r--r--doc/installerfw.qdoc10
-rw-r--r--doc/operations.qdoc20
-rw-r--r--doc/scripting.qdoc2
-rw-r--r--src/libs/ifwtools/repositorygen.cpp4
-rw-r--r--src/libs/installer/component.cpp47
-rw-r--r--src/libs/installer/component.h5
-rw-r--r--src/libs/installer/extractarchiveoperation.cpp16
-rw-r--r--src/libs/kdtools/updatesinfo.cpp30
-rw-r--r--src/libs/kdtools/updatesinfodata_p.h2
-rw-r--r--tests/auto/installer/appendfileoperation/data/xmloperationrepository/A/1.0.0content.7zbin0 -> 133 bytes
-rw-r--r--tests/auto/installer/appendfileoperation/data/xmloperationrepository/Updates.xml20
-rw-r--r--tests/auto/installer/appendfileoperation/settings.qrc2
-rw-r--r--tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp55
-rw-r--r--tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1content.7zbin0 -> 340 bytes
-rw-r--r--tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1meta.7zbin0 -> 901 bytes
-rw-r--r--tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/Updates.xml22
-rw-r--r--tests/auto/installer/copydirectoryoperation/settings.qrc2
-rw-r--r--tests/auto/installer/copydirectoryoperation/tst_copydirectoryoperation.cpp65
-rw-r--r--tests/auto/installer/copyoperationtest/data/xmloperationrepository/A/1.0.2-1content.7zbin0 -> 185 bytes
-rw-r--r--tests/auto/installer/copyoperationtest/data/xmloperationrepository/Updates.xml25
-rw-r--r--tests/auto/installer/copyoperationtest/settings.qrc2
-rw-r--r--tests/auto/installer/copyoperationtest/tst_copyoperationtest.cpp56
-rw-r--r--tests/auto/installer/createdesktopentryoperation/data/xmloperationrepository/Updates.xml18
-rw-r--r--tests/auto/installer/createdesktopentryoperation/settings.qrc1
-rw-r--r--tests/auto/installer/createdesktopentryoperation/tst_createdesktopentryoperation.cpp94
-rw-r--r--tests/auto/installer/createshortcutoperation/data/xmloperationrepository/A/1.0.2-1content.7zbin0 -> 185 bytes
-rw-r--r--tests/auto/installer/createshortcutoperation/data/xmloperationrepository/Updates.xml26
-rw-r--r--tests/auto/installer/createshortcutoperation/settings.qrc2
-rw-r--r--tests/auto/installer/createshortcutoperation/tst_createshortcutoperation.cpp46
-rw-r--r--tests/auto/installer/deleteoperation/data/xmloperationrepository/Updates.xml17
-rw-r--r--tests/auto/installer/deleteoperation/settings.qrc1
-rw-r--r--tests/auto/installer/deleteoperation/tst_deleteoperation.cpp50
-rw-r--r--tests/auto/installer/environmentvariableoperation/data/xmloperationrepository/Updates.xml25
-rw-r--r--tests/auto/installer/environmentvariableoperation/settings.qrc1
-rw-r--r--tests/auto/installer/environmentvariableoperation/tst_environmentvariableoperation.cpp54
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/data.qrc4
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0anothercontent.7zbin0 -> 114 bytes
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0content.7zbin0 -> 98 bytes
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0default.7zbin0 -> 98 bytes
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/Updates.xml26
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/extractarchiveoperationtest.pro3
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp34
-rw-r--r--tests/auto/installer/installiconsoperation/data/xmloperationrepository/A/1.0.2-1content.7zbin0 -> 384 bytes
-rw-r--r--tests/auto/installer/installiconsoperation/data/xmloperationrepository/Updates.xml18
-rw-r--r--tests/auto/installer/installiconsoperation/settings.qrc2
-rw-r--r--tests/auto/installer/installiconsoperation/tst_installiconsoperation.cpp77
-rw-r--r--tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7zbin0 -> 185 bytes
-rw-r--r--tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z.sha11
-rw-r--r--tests/auto/installer/linereplaceoperation/data/xmloperationrepository/Updates.xml23
-rw-r--r--tests/auto/installer/linereplaceoperation/settings.qrc3
-rw-r--r--tests/auto/installer/linereplaceoperation/tst_linereplaceoperation.cpp40
-rw-r--r--tests/auto/installer/moveoperation/data/xmloperationrepository/Updates.xml22
-rw-r--r--tests/auto/installer/moveoperation/settings.qrc1
-rw-r--r--tests/auto/installer/moveoperation/tst_moveoperation.cpp45
55 files changed, 780 insertions, 252 deletions
diff --git a/doc/examples/package.xml b/doc/examples/package.xml
index 118adcf73..4248a7e83 100644
--- a/doc/examples/package.xml
+++ b/doc/examples/package.xml
@@ -28,4 +28,17 @@
<ForcedInstallation>false</ForcedInstallation>
<Essential>false</Essential>
<Replaces>com.vendor.root.component2old</Replaces>
+ <Operations>
+ <Operation name="AppendFile">
+ <Argument>@TargetDir@/A.txt</Argument>
+ <Argument>lorem ipsum</Argument>
+ </Operation>
+ <Operation name="Extract">
+ <Argument>@TargetDir@/Folder1</Argument>
+ <Argument>content.7z</Argument>
+ </Operation>
+ <Operation name="Extract">
+ <Argument>@TargetDir@/Folder2</Argument>
+ </Operation>
+ </Operations>
</Package>
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc
index bbdbff09e..22407e17d 100644
--- a/doc/installerfw.qdoc
+++ b/doc/installerfw.qdoc
@@ -918,6 +918,16 @@
\li ExpandedByDefault
\li Set to \c true if you want this item to be expanded by default. Optional.
+ \row
+ \li Operations
+ \li List of operations that are performed when component is installed. To add
+ several operations, specify several \c <Operation> child elements that each
+ specify the operation \c name. \c Operation can have several \c <Argument>
+ child elements depending on the operation to be run. Adding \c <Operations>
+ is an alternative way of defining operations to defining them in scripts.
+ For more information, see \l{Adding Operations}. For a
+ summary of available operations, see \l {Operations}.
+
\endtable
\section2 Component Dependencies
diff --git a/doc/operations.qdoc b/doc/operations.qdoc
index 1fc3c00b8..983985dc7 100644
--- a/doc/operations.qdoc
+++ b/doc/operations.qdoc
@@ -33,8 +33,8 @@
\title Operations
- The operations are prepared by component and controller scripts and performed by the
- installer.
+ The operations are prepared by component and controller scripts or component.xml
+ and performed by the installer.
\note Operations are performed threaded.
Internally, each operation has a \e DO step that contains instructions for
@@ -43,7 +43,19 @@
\section1 Summary of Operations
- The following table summarizes the available operations and their syntax.
+ The following table summarizes the available operations and their syntax in component
+ and controller scripts. Syntax for operations in component.xml is:
+ \code
+ <Operations>
+ <Operation name="operation">
+ <Argument>argument1</Argument>
+ <Argument>argument2</Argument>
+ </Operation>
+ </Operations>
+ \endcode
+ \note The argument order in component.xml is the same as in scripting, except for
+ \c Extract operation where the argument \c archive is optional, and must be defined
+ as the last argument.
\table
\header
@@ -163,6 +175,8 @@
\li Extract
\li "Extract" \c archive \c targetdirectory
\li Extracts \c archive to \c targetdirectory.
+ Extract operations are called before other operations. Note that in component.xml
+ argument \c archive is optional and thus must be defined as the last parameter.
\row
\li GlobalConfig
diff --git a/doc/scripting.qdoc b/doc/scripting.qdoc
index ae90c62c7..ea29e9956 100644
--- a/doc/scripting.qdoc
+++ b/doc/scripting.qdoc
@@ -120,6 +120,8 @@
update operations to the installation from within a script using
component::addOperation(). If you need to run an operation that requires
administrative rights, use component::addElevatedOperation() instead.
+ Alternative way of adding custom operations is to use \c component.xml, see
+ \l{Package Directory}
Operations need to be added before the actual installation step. Override
\l component::createOperations() to register custom operations for a
diff --git a/src/libs/ifwtools/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp
index 819ab1ac8..5b7ec44a9 100644
--- a/src/libs/ifwtools/repositorygen.cpp
+++ b/src/libs/ifwtools/repositorygen.cpp
@@ -190,7 +190,7 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
// list of current unused or later transformed tags
QStringList blackList;
blackList << QLatin1String("UserInterfaces") << QLatin1String("Translations") <<
- QLatin1String("Licenses") << QLatin1String("Name");
+ QLatin1String("Licenses") << QLatin1String("Name") << QLatin1String("Operations");
bool foundDefault = false;
bool foundVirtual = false;
@@ -379,6 +379,8 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
}
update.appendChild(package.firstChildElement(QLatin1String("Licenses")).cloneNode());
}
+ // operations
+ update.appendChild(package.firstChildElement(QLatin1String("Operations")).cloneNode());
} else {
// Extract metadata from archive
if (!info.metaFile.isEmpty()){
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index e8f036ccd..cb028b940 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -237,6 +237,7 @@ static const QLatin1String scUnstable("Unstable");
*/
Component::Component(PackageManagerCore *core)
: d(new ComponentPrivate(core, this))
+ , m_defaultArchivePath(QLatin1String("@TargetDir@"))
{
setPrivate(d);
@@ -342,6 +343,9 @@ void Component::loadDataFromPackage(const Package &package)
QHash<QString, QVariant> licenseHash = package.data(QLatin1String("Licenses")).toHash();
if (!licenseHash.isEmpty())
loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash);
+ QVariant operationsVariant = package.data(QLatin1String("Operations"));
+ if (operationsVariant.canConvert<QList<QPair<QString, QVariant>>>())
+ m_operationsList = operationsVariant.value<QList<QPair<QString, QVariant>>>();
}
/*!
@@ -688,6 +692,39 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
}
}
+/*!
+ Loads all operations defined in the component.xml except Extract operation.
+ Operations are added to the list of operations needed to install this component.
+*/
+void Component::loadXMLOperations()
+{
+ for (auto operation: m_operationsList) {
+ if (operation.first != QLatin1String("Extract"))
+ addOperation(operation.first, operation.second.toStringList());
+ }
+}
+
+/*!
+ Loads all Extract operations defined in the component.xml.
+ Operations are overwriting the default implementation of Extract operation.
+*/
+void Component::loadXMLExtractOperations()
+{
+ for (auto operation: m_operationsList) {
+ if (operation.first == QLatin1String("Extract")) {
+ // Create hash for Extract operations. Operation has a mandatory extract folder as
+ // first argument and optional archive name as second argument.
+ const QStringList &operationArgs = operation.second.toStringList();
+ if (operationArgs.count() == 2) {
+ const QString archiveName = value(scVersion) + operationArgs.at(1);
+ const QString archivePath = QString::fromLatin1("installer://%1/%2").arg(name()).arg(archiveName);
+ m_archivesHash.insert(archivePath, operationArgs.at(0));
+ } else if (operationArgs.count() == 1) {
+ m_defaultArchivePath = operationArgs.at(0);
+ }
+ }
+ }
+}
/*!
\property QInstaller::Component::userInterfaces
@@ -796,8 +833,11 @@ void Component::createOperationsForArchive(const QString &archive)
const bool isZip = Lib7z::isSupportedArchive(archive);
if (isZip) {
- // archives get completely extracted per default (if the script isn't doing other stuff)
- addOperation(QLatin1String("Extract"), QStringList() << archive << QLatin1String("@TargetDir@"));
+ // component.xml can override this value
+ if (m_archivesHash.contains(archive))
+ addOperation(QLatin1String("Extract"), QStringList() << archive << m_archivesHash.value(archive));
+ else
+ addOperation(QLatin1String("Extract"), QStringList() << archive << m_defaultArchivePath);
} else {
createOperationsForPath(archive);
}
@@ -824,10 +864,11 @@ void Component::createOperations()
d->m_operationsCreated = true;
return;
}
-
+ loadXMLExtractOperations();
foreach (const QString &archive, archives())
createOperationsForArchive(archive);
+ loadXMLOperations();
d->m_operationsCreated = true;
}
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 6ff5c8c38..494d79b13 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -121,6 +121,8 @@ public:
void loadTranslations(const QDir &directory, const QStringList &qms);
void loadUserInterfaces(const QDir &directory, const QStringList &uis);
void loadLicenses(const QString &directory, const QHash<QString, QVariant> &hash);
+ void loadXMLOperations();
+ void loadXMLExtractOperations();
void markAsPerformedInstallation();
QStringList userInterfaces() const;
@@ -227,6 +229,9 @@ private:
private:
QString validatorCallbackName;
ComponentPrivate *d;
+ QList<QPair<QString, QVariant>> m_operationsList;
+ QHash<QString, QString> m_archivesHash;
+ QString m_defaultArchivePath;
};
QDebug operator<<(QDebug dbg, Component *component);
diff --git a/src/libs/installer/extractarchiveoperation.cpp b/src/libs/installer/extractarchiveoperation.cpp
index 99dd88a7e..5b13b1f25 100644
--- a/src/libs/installer/extractarchiveoperation.cpp
+++ b/src/libs/installer/extractarchiveoperation.cpp
@@ -122,9 +122,15 @@ bool ExtractArchiveOperation::performOperation()
QStringList files = callback.extractedFiles();
- const QString resourcesPath = targetDir + QLatin1Char('/') + QLatin1String("installerResources");
- QString fileDirectory = resourcesPath + QLatin1Char('/') +
- archivePath.section(QLatin1Char('/'), 1, 1, QString::SectionSkipEmpty) + QLatin1Char('/');
+ QString installDir = targetDir;
+ // If we have package manager in use (normal installer run) then use
+ // TargetDir for saving filenames, otherwise those would be saved to
+ // extracted folder.
+ if (packageManager())
+ installDir = packageManager()->value(QLatin1String("TargetDir"));
+ const QString resourcesPath = installDir + QLatin1Char('/') + QLatin1String("installerResources");
+ QString fileDirectory = resourcesPath + QLatin1Char('/') + archivePath.section(QLatin1Char('/'), 1, 1,
+ QString::SectionSkipEmpty) + QLatin1Char('/');
QString archiveFileName = archivePath.section(QLatin1Char('/'), 2, 2, QString::SectionSkipEmpty);
QFileInfo fileInfo2(archiveFileName);
QString suffix = fileInfo2.suffix();
@@ -145,7 +151,7 @@ bool ExtractArchiveOperation::performOperation()
setDefaultFilePermissions(file.fileName(), DefaultFilePermissions::NonExecutable);
QDataStream out (&file);
for (int i = 0; i < files.count(); ++i) {
- files[i] = replacePath(files.at(i), targetDir, QLatin1String(scRelocatable));
+ files[i] = replacePath(files.at(i), installDir, QLatin1String(scRelocatable));
}
out << files;
setValue(QLatin1String("files"), file.fileName());
@@ -176,6 +182,8 @@ bool ExtractArchiveOperation::undoOperation()
// If yes, files are listed in .dat instead of in a separate file.
bool useStringListType(value(QLatin1String("files")).type() == QVariant::StringList);
QString targetDir = arguments().at(1);
+ if (packageManager())
+ targetDir = packageManager()->value(QLatin1String("TargetDir"));
QStringList files;
if (useStringListType) {
files = value(QLatin1String("files")).toStringList();
diff --git a/src/libs/kdtools/updatesinfo.cpp b/src/libs/kdtools/updatesinfo.cpp
index 2d7e001ea..3119b6240 100644
--- a/src/libs/kdtools/updatesinfo.cpp
+++ b/src/libs/kdtools/updatesinfo.cpp
@@ -154,6 +154,10 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
} else if (childE.tagName() == QLatin1String("UpdateFile")) {
info.data[QLatin1String("CompressedSize")] = childE.attribute(QLatin1String("CompressedSize"));
info.data[QLatin1String("UncompressedSize")] = childE.attribute(QLatin1String("UncompressedSize"));
+ } else if (childE.tagName() == QLatin1String("Operations")) {
+ const QDomNodeList operationNodes = childE.childNodes();
+ QVariant operationListVariant = parseOperations(childE.childNodes());
+ info.data.insert(QLatin1String("Operations"), operationListVariant);
} else {
info.data[childE.tagName()] = childE.text();
}
@@ -197,6 +201,32 @@ void UpdatesInfoData::processLocalizedTag(const QDomElement &childE, QHash<QStri
info[childE.tagName()] = childE.text();
}
+QVariant UpdatesInfoData::parseOperations(const QDomNodeList &operationNodes)
+{
+ QVariant operationListVariant;
+ QList<QPair<QString, QVariant>> operationsList;
+ for (int i = 0; i < operationNodes.count(); ++i) {
+ const QDomNode operationNode = operationNodes.at(i);
+ if (operationNode.nodeName() == QLatin1String("Operation")) {
+ const QDomNodeList argumentNodes = operationNode.childNodes();
+ QStringList attributes;
+ for (int i = 0; i < argumentNodes.count(); ++i) {
+ const QDomNode argumentNode = argumentNodes.at(i);
+ if (argumentNode.nodeName() == QLatin1String("Argument")) {
+ QDomElement argumentElement = argumentNode.toElement();
+ attributes.append(argumentElement.text());
+ }
+ }
+ QPair<QString, QVariant> pair;
+ pair.first = operationNode.toElement().attributeNode(QLatin1String("name")).value();
+ pair.second = attributes;
+ operationsList.append(pair);
+ }
+ }
+ operationListVariant.setValue(operationsList);
+ return operationListVariant;
+}
+
//
// UpdatesInfo
diff --git a/src/libs/kdtools/updatesinfodata_p.h b/src/libs/kdtools/updatesinfodata_p.h
index 69b004bc3..07da6fcf0 100644
--- a/src/libs/kdtools/updatesinfodata_p.h
+++ b/src/libs/kdtools/updatesinfodata_p.h
@@ -33,6 +33,7 @@
#include <QSharedData>
QT_FORWARD_DECLARE_CLASS(QDomElement)
+QT_FORWARD_DECLARE_CLASS(QDomNodeList)
namespace KDUpdater {
@@ -60,6 +61,7 @@ public:
private:
void processLocalizedTag(const QDomElement &childE, QHash<QString, QVariant> &info) const;
+ QVariant parseOperations(const QDomNodeList &operationNodes);
};
} // namespace KDUpdater
diff --git a/tests/auto/installer/appendfileoperation/data/xmloperationrepository/A/1.0.0content.7z b/tests/auto/installer/appendfileoperation/data/xmloperationrepository/A/1.0.0content.7z
new file mode 100644
index 000000000..90b958cdb
--- /dev/null
+++ b/tests/auto/installer/appendfileoperation/data/xmloperationrepository/A/1.0.0content.7z
Binary files differ
diff --git a/tests/auto/installer/appendfileoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/appendfileoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..708ba6539
--- /dev/null
+++ b/tests/auto/installer/appendfileoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,20 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <PackageUpdate>
+ <Name>A</Name>
+ <DisplayName>A</DisplayName>
+ <Description>Example component A</Description>
+ <Version>1.0.0</Version>
+ <ReleaseDate>2020-01-01</ReleaseDate>
+ <Default>true</Default>
+ <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <Operations>
+ <Operation name="AppendFile">
+ <Argument>@TargetDir@/A.txt</Argument>
+ <Argument>lorem ipsum</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/appendfileoperation/settings.qrc b/tests/auto/installer/appendfileoperation/settings.qrc
index 10cc3c3bb..66d0c8da1 100644
--- a/tests/auto/installer/appendfileoperation/settings.qrc
+++ b/tests/auto/installer/appendfileoperation/settings.qrc
@@ -3,5 +3,7 @@
<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>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.0content.7z</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
index 1b2d63fd7..9fbfb08e7 100644
--- a/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
+++ b/tests/auto/installer/appendfileoperation/tst_appendfileoperation.cpp
@@ -40,6 +40,33 @@ class tst_appendfileoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+ core->installDefaultComponentsSilently();
+
+ QFile file(installDir + QDir::separator() + "A.txt");
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QTextStream stream(&file);
+ QCOMPARE(stream.readAll(), QLatin1String("Appended text: lorem ipsum"));
+ file.close();
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+ // We cannot check the file contents here as it will be deleted on
+ // undo Extract, but at least check that the uninstallation succeeds.
+ QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently
+ (QStringList()<< "A"));
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+ }
+
private slots:
void initTestCase()
{
@@ -109,30 +136,14 @@ private slots:
QVERIFY(file.remove());
}
- void testPerformingFromCLI()
+ void testApppendFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
- core->installDefaultComponentsSilently();
-
- QFile file(installDir + QDir::separator() + "A.txt");
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
- QTextStream stream(&file);
- QCOMPARE(stream.readAll(), QLatin1String("Appended text: lorem ipsum"));
- file.close();
-
- core->setPackageManager();
- core->commitSessionOperations();
- // We cannot check the file contents here as it will be deleted on
- // undo Extract, but at least check that the uninstallation succeeds.
- QCOMPARE(PackageManagerCore::Success, core->uninstallComponentsSilently
- (QStringList()<< "A"));
+ installFromCLI(":///data/repository");
+ }
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testAppendFromComponentXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
private:
diff --git a/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1content.7z b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1content.7z
new file mode 100644
index 000000000..920ed1d99
--- /dev/null
+++ b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1content.7z
Binary files differ
diff --git a/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1meta.7z b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1meta.7z
new file mode 100644
index 000000000..7449d052b
--- /dev/null
+++ b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1meta.7z
Binary files differ
diff --git a/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..90b26a387
--- /dev/null
+++ b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,22 @@
+<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>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <Operations>
+ <Operation name="Mkdir">
+ <Argument>@TargetDir@/destination/directory</Argument>
+ </Operation>
+ <Operation name="CopyDirectory">
+ <Argument>@TargetDir@/directory</Argument>
+ <Argument>@TargetDir@/destination/directory</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/copydirectoryoperation/settings.qrc b/tests/auto/installer/copydirectoryoperation/settings.qrc
index 10cc3c3bb..094bd449b 100644
--- a/tests/auto/installer/copydirectoryoperation/settings.qrc
+++ b/tests/auto/installer/copydirectoryoperation/settings.qrc
@@ -3,5 +3,7 @@
<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>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/copydirectoryoperation/tst_copydirectoryoperation.cpp b/tests/auto/installer/copydirectoryoperation/tst_copydirectoryoperation.cpp
index 19a8b36b7..bf95f635d 100644
--- a/tests/auto/installer/copydirectoryoperation/tst_copydirectoryoperation.cpp
+++ b/tests/auto/installer/copydirectoryoperation/tst_copydirectoryoperation.cpp
@@ -43,6 +43,38 @@ class tst_copydirectoryoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+
+ core->setValue(scTargetDir, installDir);
+ core->installDefaultComponentsSilently();
+
+ // Matches path in component install script
+ QFileInfo targetInfo(installDir + QDir::toNativeSeparators("/directory"));
+ QMap<QString, QByteArray> targetMap;
+ VerifyInstaller::addToFileMap(QDir(targetInfo.absoluteFilePath()), targetInfo, targetMap);
+
+ QFileInfo destinationInfo(installDir + QDir::toNativeSeparators("/destination/directory"));
+ QMap<QString, QByteArray> destinationMap;
+ VerifyInstaller::addToFileMap(QDir(destinationInfo.absoluteFilePath()), destinationInfo, destinationMap);
+
+ QVERIFY(targetMap == destinationMap);
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY(!destinationInfo.exists());
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+ }
+
private slots:
void initTestCase()
{
@@ -140,35 +172,14 @@ private slots:
QVERIFY2(op.performOperation(), op.errorString().toLatin1());
}
- void testPerformingFromCLI()
+ void testCopyDirectoryFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
-
- core->setValue(scTargetDir, installDir);
- core->installDefaultComponentsSilently();
-
- // Matches path in component install script
- QFileInfo targetInfo(installDir + QDir::toNativeSeparators("/directory"));
- QMap<QString, QByteArray> targetMap;
- VerifyInstaller::addToFileMap(QDir(targetInfo.absoluteFilePath()), targetInfo, targetMap);
-
- QFileInfo destinationInfo(installDir + QDir::toNativeSeparators("/destination/directory"));
- QMap<QString, QByteArray> destinationMap;
- VerifyInstaller::addToFileMap(QDir(destinationInfo.absoluteFilePath()), destinationInfo, destinationMap);
-
- QVERIFY(targetMap == destinationMap);
-
- core->setPackageManager();
- core->commitSessionOperations();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY(!destinationInfo.exists());
+ installFromCLI(":///data/repository");
+ }
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testCopyDirectoryFromComponentXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
private:
diff --git a/tests/auto/installer/copyoperationtest/data/xmloperationrepository/A/1.0.2-1content.7z b/tests/auto/installer/copyoperationtest/data/xmloperationrepository/A/1.0.2-1content.7z
new file mode 100644
index 000000000..8ba90b13b
--- /dev/null
+++ b/tests/auto/installer/copyoperationtest/data/xmloperationrepository/A/1.0.2-1content.7z
Binary files differ
diff --git a/tests/auto/installer/copyoperationtest/data/xmloperationrepository/Updates.xml b/tests/auto/installer/copyoperationtest/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..4ad1e243b
--- /dev/null
+++ b/tests/auto/installer/copyoperationtest/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,25 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>false</Checksum>
+ <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>
+ <UpdateFile CompressedSize="225" UncompressedSize="75" OS="Any"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <SHA1>6d7a3e15d11a4d94b81452fc2aa18e705a01c922</SHA1>
+ <Operations>
+ <Operation name="Mkdir">
+ <Argument>@TargetDir@/AnotherFolder</Argument>
+ </Operation>
+ <Operation name="Copy">
+ <Argument>@TargetDir@/A.txt</Argument>
+ <Argument>@TargetDir@/AnotherFolder/A.txt</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/copyoperationtest/settings.qrc b/tests/auto/installer/copyoperationtest/settings.qrc
index 10cc3c3bb..094bd449b 100644
--- a/tests/auto/installer/copyoperationtest/settings.qrc
+++ b/tests/auto/installer/copyoperationtest/settings.qrc
@@ -3,5 +3,7 @@
<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>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/copyoperationtest/tst_copyoperationtest.cpp b/tests/auto/installer/copyoperationtest/tst_copyoperationtest.cpp
index aee192400..d41853eee 100644
--- a/tests/auto/installer/copyoperationtest/tst_copyoperationtest.cpp
+++ b/tests/auto/installer/copyoperationtest/tst_copyoperationtest.cpp
@@ -40,6 +40,33 @@ class tst_copyoperationtest : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit(installDir, repository);
+ core->installDefaultComponentsSilently();
+
+ QFile copiedFile(installDir + QDir::separator() + "AnotherFolder/A.txt");
+ QVERIFY(copiedFile.exists());
+ QFile originalFile(installDir + QDir::separator() + "A.txt");
+ QVERIFY(originalFile.exists());
+
+ QByteArray destinationFileHash = QInstaller::calculateHash(copiedFile.fileName(), QCryptographicHash::Sha1);
+ QByteArray testFileHash = QInstaller::calculateHash(originalFile.fileName(), QCryptographicHash::Sha1);
+ QVERIFY(testFileHash == destinationFileHash);
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY(!copiedFile.exists());
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+ }
+
private slots:
void initTestCase()
{
@@ -132,30 +159,13 @@ private slots:
QVERIFY(testFileHash == currentFileHash);
}
- void testPerformingFromCLI()
+ void testCopyFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit(installDir, ":///data/repository");
- core->installDefaultComponentsSilently();
-
- QFile copiedFile(installDir + QDir::separator() + "AnotherFolder/A.txt");
- QVERIFY(copiedFile.exists());
- QFile originalFile(installDir + QDir::separator() + "A.txt");
- QVERIFY(originalFile.exists());
-
- QByteArray destinationFileHash = QInstaller::calculateHash(copiedFile.fileName(), QCryptographicHash::Sha1);
- QByteArray testFileHash = QInstaller::calculateHash(originalFile.fileName(), QCryptographicHash::Sha1);
- QVERIFY(testFileHash == destinationFileHash);
-
- core->setPackageManager();
- core->commitSessionOperations();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY(!copiedFile.exists());
-
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ installFromCLI(":///data/repository");
+ }
+ void testCopyFromComponentXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
void init()
diff --git a/tests/auto/installer/createdesktopentryoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/createdesktopentryoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..a5131552d
--- /dev/null
+++ b/tests/auto/installer/createdesktopentryoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,18 @@
+<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>
+ <Operations>
+ <Operation name="CreateDesktopEntry">
+ <Argument>org.qtproject.ifw-test.desktop</Argument>
+ <Argument>Type=Application\nName=Test\nVersion=1.0</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/createdesktopentryoperation/settings.qrc b/tests/auto/installer/createdesktopentryoperation/settings.qrc
index d030220ab..04a7daf71 100644
--- a/tests/auto/installer/createdesktopentryoperation/settings.qrc
+++ b/tests/auto/installer/createdesktopentryoperation/settings.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>data/repository/Updates.xml</file>
<file>data/repository/A/1.0.2-1meta.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/createdesktopentryoperation/tst_createdesktopentryoperation.cpp b/tests/auto/installer/createdesktopentryoperation/tst_createdesktopentryoperation.cpp
index a1297e5a2..ac3fffbe1 100644
--- a/tests/auto/installer/createdesktopentryoperation/tst_createdesktopentryoperation.cpp
+++ b/tests/auto/installer/createdesktopentryoperation/tst_createdesktopentryoperation.cpp
@@ -48,6 +48,53 @@ class tst_createdesktopentryoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+
+ core->installDefaultComponentsSilently();
+
+ CreateDesktopEntryOperation *createDesktopEntryOp = nullptr;
+ OperationList operations = core->componentByName("A")->operations();
+ foreach (Operation *op, operations) {
+ if (op->name() == QLatin1String("CreateDesktopEntry"))
+ createDesktopEntryOp = dynamic_cast<CreateDesktopEntryOperation *>(op);
+ }
+ QVERIFY(createDesktopEntryOp);
+
+ QString entryFileName = createDesktopEntryOp->absoluteFileName();
+ QVERIFY(QFileInfo(entryFileName).exists());
+ if (QFileInfo(createDesktopEntryOp->arguments().first()).isRelative()) {
+ QStringList directories = QString::fromLocal8Bit(qgetenv("XDG_DATA_HOME"))
+ .split(QLatin1Char(':'), QString::SkipEmptyParts);
+ // Default path if XDG_DATA_HOME is not set
+ directories.append(QDir::home().absoluteFilePath(QLatin1String(".local/share")));
+ bool validPath = false;
+ foreach (const QString &dir, directories) {
+ // Desktop entry should be in one of the expected locations
+ if (QFileInfo(entryFileName).absolutePath() == QDir(dir).absoluteFilePath("applications")) {
+ validPath = true;
+ break;
+ }
+ }
+ QVERIFY(validPath);
+ }
+ core->setPackageManager();
+ core->commitSessionOperations();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY2(!QFileInfo(entryFileName).exists(), "Please make sure there "
+ "does not exist a desktop entry with the same name.");
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+
+ }
+
private slots:
void initTestCase()
{
@@ -111,49 +158,14 @@ private slots:
QVERIFY(QFile(filename).remove());
}
- void testPerformingFromCLI()
+ void testDesktopEntryFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
-
- core->installDefaultComponentsSilently();
-
- CreateDesktopEntryOperation *createDesktopEntryOp = nullptr;
- OperationList operations = core->componentByName("A")->operations();
- foreach (Operation *op, operations) {
- if (op->name() == QLatin1String("CreateDesktopEntry"))
- createDesktopEntryOp = dynamic_cast<CreateDesktopEntryOperation *>(op);
- }
- QVERIFY(createDesktopEntryOp);
-
- QString entryFileName = createDesktopEntryOp->absoluteFileName();
- QVERIFY(QFileInfo(entryFileName).exists());
- if (QFileInfo(createDesktopEntryOp->arguments().first()).isRelative()) {
- QStringList directories = QString::fromLocal8Bit(qgetenv("XDG_DATA_HOME"))
- .split(QLatin1Char(':'), QString::SkipEmptyParts);
- // Default path if XDG_DATA_HOME is not set
- directories.append(QDir::home().absoluteFilePath(QLatin1String(".local/share")));
- bool validPath = false;
- foreach (const QString &dir, directories) {
- // Desktop entry should be in one of the expected locations
- if (QFileInfo(entryFileName).absolutePath() == QDir(dir).absoluteFilePath("applications")) {
- validPath = true;
- break;
- }
- }
- QVERIFY(validPath);
- }
- core->setPackageManager();
- core->commitSessionOperations();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY2(!QFileInfo(entryFileName).exists(), "Please make sure there "
- "does not exist a desktop entry with the same name.");
+ installFromCLI(":///data/repository");
+ }
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testDesktopEntryFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
private:
diff --git a/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/A/1.0.2-1content.7z b/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/A/1.0.2-1content.7z
new file mode 100644
index 000000000..8ba90b13b
--- /dev/null
+++ b/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/A/1.0.2-1content.7z
Binary files differ
diff --git a/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..a7d287d4d
--- /dev/null
+++ b/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,26 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>false</Checksum>
+ <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>
+ <UpdateFile CompressedSize="225" UncompressedSize="75" OS="Any"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <SHA1>6d7a3e15d11a4d94b81452fc2aa18e705a01c922</SHA1>
+ <Operations>
+ <Operation name="CreateShortcut">
+ <Argument>@TargetDir@/A.txt</Argument>
+ <Argument>@StartMenuDir@/A.lnk</Argument>
+ <Argument>workingDirectory=@TargetDir@</Argument>
+ <Argument>iconPath=%SystemRoot%/system32/SHELL32.dl</Argument>
+ <Argument>iconId=2</Argument>
+ <Argument>description=Open A file</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/createshortcutoperation/settings.qrc b/tests/auto/installer/createshortcutoperation/settings.qrc
index 410fbf81a..d2365cab3 100644
--- a/tests/auto/installer/createshortcutoperation/settings.qrc
+++ b/tests/auto/installer/createshortcutoperation/settings.qrc
@@ -3,6 +3,8 @@
<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>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z</file>
</qresource>
<qresource prefix="/metadata">
<file>installer-config/config.xml</file>
diff --git a/tests/auto/installer/createshortcutoperation/tst_createshortcutoperation.cpp b/tests/auto/installer/createshortcutoperation/tst_createshortcutoperation.cpp
index 19fbee0a9..a57098d2a 100644
--- a/tests/auto/installer/createshortcutoperation/tst_createshortcutoperation.cpp
+++ b/tests/auto/installer/createshortcutoperation/tst_createshortcutoperation.cpp
@@ -48,22 +48,8 @@ class tst_createshortcutoperation : public QObject
{
Q_OBJECT
-private slots:
- void testMissingArguments()
- {
- CreateShortcutOperation op;
-
- QVERIFY(op.testOperation());
- QVERIFY(!op.performOperation());
-
- QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::InvalidArguments);
- QCOMPARE(op.errorString(), QString("Invalid arguments in CreateShortcut: 0 arguments given,"
- " 2 or 3 arguments expected in the form: <target> <link location> "
- "[target arguments] [\"workingDirectory=...\"] [\"iconPath=...\"] "
- "[\"iconId=...\"] [\"description=...\"]."));
- }
-
- void testCreateShortcutForCurrentUserFromCLI()
+private:
+ void installFromCLI(const QString &repository)
{
QInstaller::init();
PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList<OperationBlob> (),
@@ -73,7 +59,7 @@ private slots:
core->disableWriteMaintenanceTool();
core->setAutoConfirmCommand();
QSet<Repository> repoList;
- Repository repo = Repository::fromUserInput(":///data/repository");
+ Repository repo = Repository::fromUserInput(repository);
repoList.insert(repo);
core->settings().setDefaultRepositories(repoList);
@@ -98,7 +84,31 @@ private slots:
core->commitSessionOperations();
core->uninstallComponentsSilently(QStringList() << "A");
QVERIFY(!QFile::exists(linkLocation));
- core->deleteLater();
+ }
+
+private slots:
+ void testMissingArguments()
+ {
+ CreateShortcutOperation op;
+
+ QVERIFY(op.testOperation());
+ QVERIFY(!op.performOperation());
+
+ QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::InvalidArguments);
+ QCOMPARE(op.errorString(), QString("Invalid arguments in CreateShortcut: 0 arguments given,"
+ " 2 or 3 arguments expected in the form: <target> <link location> "
+ "[target arguments] [\"workingDirectory=...\"] [\"iconPath=...\"] "
+ "[\"iconId=...\"] [\"description=...\"]."));
+ }
+
+ void testCreateShortcutFromScript()
+ {
+ installFromCLI(":///data/repository");
+ }
+
+ void testCreateShortcutFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
};
diff --git a/tests/auto/installer/deleteoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/deleteoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..6856014b9
--- /dev/null
+++ b/tests/auto/installer/deleteoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,17 @@
+<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>
+ <Operations>
+ <Operation name="Delete">
+ <Argument>@TargetDir@/test</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/deleteoperation/settings.qrc b/tests/auto/installer/deleteoperation/settings.qrc
index d030220ab..04a7daf71 100644
--- a/tests/auto/installer/deleteoperation/settings.qrc
+++ b/tests/auto/installer/deleteoperation/settings.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>data/repository/Updates.xml</file>
<file>data/repository/A/1.0.2-1meta.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/deleteoperation/tst_deleteoperation.cpp b/tests/auto/installer/deleteoperation/tst_deleteoperation.cpp
index 72509f074..807d03498 100644
--- a/tests/auto/installer/deleteoperation/tst_deleteoperation.cpp
+++ b/tests/auto/installer/deleteoperation/tst_deleteoperation.cpp
@@ -41,6 +41,30 @@ using namespace QInstaller;
class tst_deleteoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit(installDir, repository);
+
+ // Matches filename in component install script
+ QFile file(installDir + QDir::toNativeSeparators("/test"));
+ QVERIFY(file.open(QIODevice::ReadWrite));
+ file.close();
+
+ core->installDefaultComponentsSilently();
+ QVERIFY(!file.exists());
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY(file.exists());
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ core->deleteLater();
+ }
private slots:
void testMissingArguments()
@@ -102,28 +126,14 @@ private slots:
QVERIFY(QFile(path).remove());
}
- void testPerformingFromCLI()
+ void testDeleteFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit(installDir, ":///data/repository");
-
- // Matches filename in component install script
- QFile file(installDir + QDir::toNativeSeparators("/test"));
- QVERIFY(file.open(QIODevice::ReadWrite));
- file.close();
-
- core->installDefaultComponentsSilently();
- QVERIFY(!file.exists());
-
- core->setPackageManager();
- core->commitSessionOperations();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY(file.exists());
+ installFromCLI(":///data/repository");
+ }
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testDeleteFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
};
diff --git a/tests/auto/installer/environmentvariableoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/environmentvariableoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..9c33caf6d
--- /dev/null
+++ b/tests/auto/installer/environmentvariableoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,25 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>false</Checksum>
+ <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>
+ <Operations>
+ <Operation name="EnvironmentVariable">
+ <Argument>IFW_UNIT_TEST_LOCAL</Argument>
+ <Argument>IFW_UNIT_TEST_VALUE</Argument>
+ <Argument>false</Argument>
+ </Operation>
+ <Operation name="EnvironmentVariable">
+ <Argument>IFW_UNIT_TEST_PERSISTENT</Argument>
+ <Argument>IFW_UNIT_TEST_PERSISTENT_VALUE</Argument>
+ <Argument>true</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/environmentvariableoperation/settings.qrc b/tests/auto/installer/environmentvariableoperation/settings.qrc
index d030220ab..04a7daf71 100644
--- a/tests/auto/installer/environmentvariableoperation/settings.qrc
+++ b/tests/auto/installer/environmentvariableoperation/settings.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>data/repository/Updates.xml</file>
<file>data/repository/A/1.0.2-1meta.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/environmentvariableoperation/tst_environmentvariableoperation.cpp b/tests/auto/installer/environmentvariableoperation/tst_environmentvariableoperation.cpp
index 6cddad2e5..d0ded4c58 100644
--- a/tests/auto/installer/environmentvariableoperation/tst_environmentvariableoperation.cpp
+++ b/tests/auto/installer/environmentvariableoperation/tst_environmentvariableoperation.cpp
@@ -42,6 +42,32 @@ class tst_environmentvariableoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+ core->installDefaultComponentsSilently();
+
+ QVERIFY(m_settings->value("IFW_UNIT_TEST_LOCAL").toString().isEmpty());
+
+ // Persistent is in settings in Windows platform only, otherwise it is written to local env.
+#ifdef Q_OS_WIN
+ QCOMPARE(m_settings->value("IFW_UNIT_TEST_PERSISTENT").toString(), QLatin1String("IFW_UNIT_TEST_PERSISTENT_VALUE"));
+#else
+ QCOMPARE(Environment::instance().value("IFW_UNIT_TEST_PERSISTENT"), QLatin1String("IFW_UNIT_TEST_PERSISTENT_VALUE"));
+#endif
+ QCOMPARE(Environment::instance().value("IFW_UNIT_TEST_LOCAL"), QLatin1String("IFW_UNIT_TEST_VALUE"));
+
+ core->commitSessionOperations();
+ core->setPackageManager();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY(m_settings->value("IFW_UNIT_TEST_PERSISTENT").toString().isEmpty());
+ QVERIFY(Environment::instance().value("IFW_UNIT_TEST_LOCAL").isEmpty());
+ }
+
private slots:
void initTestCase()
{
@@ -135,30 +161,14 @@ private slots:
QCOMPARE(m_oldValue, Environment::instance().value(m_key));
}
- void testPerformingFromCLI()
+ void testEnvVariableFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
- core->installDefaultComponentsSilently();
-
- QVERIFY(m_settings->value("IFW_UNIT_TEST_LOCAL").toString().isEmpty());
-
- // Persistent is in settings in Windows platform only, otherwise it is written to local env.
-#ifdef Q_OS_WIN
- QCOMPARE(QLatin1String("IFW_UNIT_TEST_PERSISTENT_VALUE"), m_settings->value("IFW_UNIT_TEST_PERSISTENT").toString());
-#else
- QCOMPARE(QLatin1String("IFW_UNIT_TEST_PERSISTENT_VALUE"), Environment::instance().value("IFW_UNIT_TEST_PERSISTENT"));
-#endif
- QCOMPARE(QLatin1String("IFW_UNIT_TEST_VALUE"), Environment::instance().value("IFW_UNIT_TEST_LOCAL"));
+ installFromCLI(":///data/repository");
+ }
- core->commitSessionOperations();
- core->setPackageManager();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY(m_settings->value("IFW_UNIT_TEST_PERSISTENT").toString().isEmpty());
- QVERIFY(Environment::instance().value("IFW_UNIT_TEST_LOCAL").isEmpty());
- core->deleteLater();
+ void testEnvVariableFromSXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
private:
diff --git a/tests/auto/installer/extractarchiveoperationtest/data.qrc b/tests/auto/installer/extractarchiveoperationtest/data.qrc
index d6453a9b3..d6eb2cf92 100644
--- a/tests/auto/installer/extractarchiveoperationtest/data.qrc
+++ b/tests/auto/installer/extractarchiveoperationtest/data.qrc
@@ -2,5 +2,9 @@
<qresource prefix="/">
<file>data/valid.7z</file>
<file>data/invalid.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.0content.7z</file>
+ <file>data/xmloperationrepository/A/1.0.0anothercontent.7z</file>
+ <file>data/xmloperationrepository/A/1.0.0default.7z</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0anothercontent.7z b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0anothercontent.7z
new file mode 100644
index 000000000..949b50689
--- /dev/null
+++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0anothercontent.7z
Binary files differ
diff --git a/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0content.7z b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0content.7z
new file mode 100644
index 000000000..585f58296
--- /dev/null
+++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0content.7z
Binary files differ
diff --git a/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0default.7z b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0default.7z
new file mode 100644
index 000000000..1c0c5ccfb
--- /dev/null
+++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0default.7z
Binary files differ
diff --git a/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/Updates.xml b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..3a8bdd018
--- /dev/null
+++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,26 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <PackageUpdate>
+ <Name>A</Name>
+ <DisplayName>A</DisplayName>
+ <Description>Example component A</Description>
+ <Version>1.0.0</Version>
+ <ReleaseDate>2015-01-01</ReleaseDate>
+ <Default>true</Default>
+ <DownloadableArchives>content.7z,anothercontent.7z,default.7z</DownloadableArchives>
+ <Operations>
+ <Operation name="Extract">
+ <Argument>@TargetDir@/FolderForContent</Argument>
+ <Argument>content.7z</Argument>
+ </Operation>
+ <Operation name="Extract">
+ <Argument>@TargetDir@/FolderForAnotherContent</Argument>
+ <Argument>anothercontent.7z</Argument>
+ </Operation>
+ <Operation name="Extract">
+ <Argument>@TargetDir@/FolderForDefault</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/extractarchiveoperationtest/extractarchiveoperationtest.pro b/tests/auto/installer/extractarchiveoperationtest/extractarchiveoperationtest.pro
index fb53c9a8a..2343f546e 100644
--- a/tests/auto/installer/extractarchiveoperationtest/extractarchiveoperationtest.pro
+++ b/tests/auto/installer/extractarchiveoperationtest/extractarchiveoperationtest.pro
@@ -3,5 +3,6 @@ include(../../qttest.pri)
QT -= gui
QT += testlib
-RESOURCES += data.qrc
+RESOURCES += data.qrc \
+ ..\shared\config.qrc
SOURCES = tst_extractarchiveoperationtest.cpp
diff --git a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
index a5f38e0ea..baaf58da2 100644
--- a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
+++ b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
@@ -26,6 +26,8 @@
**
**************************************************************************/
+#include "../shared/packagemanager.h"
+
#include "init.h"
#include "extractarchiveoperation.h"
@@ -40,6 +42,8 @@ class tst_extractarchiveoperationtest : public QObject
{
Q_OBJECT
+private:
+
private slots:
void initTestCase()
{
@@ -83,6 +87,36 @@ private slots:
QCOMPARE(op.errorString(), QString("Error while extracting archive \":///data/invalid.7z\": "
"Cannot open archive \":///data/invalid.7z\"."));
}
+
+ void testExtractArchiveFromXML()
+ {
+ m_testDirectory = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(m_testDirectory));
+ QVERIFY(QDir(m_testDirectory).exists());
+
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (m_testDirectory, ":///data/xmloperationrepository");
+ core->installDefaultComponentsSilently();
+
+ QFile extractedFile(m_testDirectory + QDir::separator() + "FolderForContent/content.txt");
+ QVERIFY(extractedFile.exists());
+
+ extractedFile.setFileName(m_testDirectory + QDir::separator() + "FolderForAnotherContent/anothercontent.txt");
+ QVERIFY(extractedFile.exists());
+
+ extractedFile.setFileName(m_testDirectory + QDir::separator() + "FolderForDefault/default.txt");
+ QVERIFY(extractedFile.exists());
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QDir dir(m_testDirectory);
+ QVERIFY(dir.removeRecursively());
+ }
+
+private:
+ QString m_testDirectory;
};
QTEST_MAIN(tst_extractarchiveoperationtest)
diff --git a/tests/auto/installer/installiconsoperation/data/xmloperationrepository/A/1.0.2-1content.7z b/tests/auto/installer/installiconsoperation/data/xmloperationrepository/A/1.0.2-1content.7z
new file mode 100644
index 000000000..9d58b172e
--- /dev/null
+++ b/tests/auto/installer/installiconsoperation/data/xmloperationrepository/A/1.0.2-1content.7z
Binary files differ
diff --git a/tests/auto/installer/installiconsoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/installiconsoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..5977964f2
--- /dev/null
+++ b/tests/auto/installer/installiconsoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,18 @@
+<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>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <Operations>
+ <Operation name="InstallIcons">
+ <Argument>@TargetDir@/icons</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/installiconsoperation/settings.qrc b/tests/auto/installer/installiconsoperation/settings.qrc
index 10cc3c3bb..094bd449b 100644
--- a/tests/auto/installer/installiconsoperation/settings.qrc
+++ b/tests/auto/installer/installiconsoperation/settings.qrc
@@ -3,5 +3,7 @@
<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>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/installiconsoperation/tst_installiconsoperation.cpp b/tests/auto/installer/installiconsoperation/tst_installiconsoperation.cpp
index cb95e49da..d1a9c680e 100644
--- a/tests/auto/installer/installiconsoperation/tst_installiconsoperation.cpp
+++ b/tests/auto/installer/installiconsoperation/tst_installiconsoperation.cpp
@@ -42,6 +42,43 @@ using namespace QInstaller;
class tst_installiconsoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+ core->installDefaultComponentsSilently();
+
+ InstallIconsOperation *installIconsOp = nullptr;
+ OperationList operations = core->componentByName("A")->operations();
+ foreach (Operation *op, operations) {
+ if (op->name() == QLatin1String("InstallIcons"))
+ installIconsOp = dynamic_cast<InstallIconsOperation *>(op);
+ }
+ QVERIFY(installIconsOp);
+
+ // As the original directory containing icons will be deleted by the operation,
+ // we will use a copy with the exact same contents.
+ QFileInfo fakeSourceInfo(installDir + "/icons_copy/test");
+ QMap<QString, QByteArray> fakeSourceMap;
+ VerifyInstaller::addToFileMap(QDir(fakeSourceInfo.absoluteFilePath()), fakeSourceInfo, fakeSourceMap);
+
+ QFileInfo destinationInfo(installIconsOp->value("directory").toString() + "/test");
+ QMap<QString, QByteArray> destinationMap;
+ VerifyInstaller::addToFileMap(QDir(destinationInfo.absoluteFilePath()), destinationInfo, destinationMap);
+
+ QVERIFY(fakeSourceMap == destinationMap);
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+ core->uninstallComponentsSilently(QStringList() << "A");
+ QVERIFY(!destinationInfo.exists());
+
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ }
private slots:
void initTestCase()
@@ -77,42 +114,14 @@ private slots:
QCOMPARE(op.errorString(), QString("Invalid Argument: source directory must not be empty."));
}
- void testPerformingFromCLI()
+ void testInstallIconsFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
- core->installDefaultComponentsSilently();
-
- InstallIconsOperation *installIconsOp = nullptr;
- OperationList operations = core->componentByName("A")->operations();
- foreach (Operation *op, operations) {
- if (op->name() == QLatin1String("InstallIcons"))
- installIconsOp = dynamic_cast<InstallIconsOperation *>(op);
- }
- QVERIFY(installIconsOp);
-
- // As the original directory containing icons will be deleted by the operation,
- // we will use a copy with the exact same contents.
- QFileInfo fakeSourceInfo(installDir + "/icons_copy/test");
- QMap<QString, QByteArray> fakeSourceMap;
- VerifyInstaller::addToFileMap(QDir(fakeSourceInfo.absoluteFilePath()), fakeSourceInfo, fakeSourceMap);
-
- QFileInfo destinationInfo(installIconsOp->value("directory").toString() + "/test");
- QMap<QString, QByteArray> destinationMap;
- VerifyInstaller::addToFileMap(QDir(destinationInfo.absoluteFilePath()), destinationInfo, destinationMap);
-
- QVERIFY(fakeSourceMap == destinationMap);
-
- core->setPackageManager();
- core->commitSessionOperations();
- core->uninstallComponentsSilently(QStringList() << "A");
- QVERIFY(!destinationInfo.exists());
+ installFromCLI(":///data/repository");
+ }
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testInstallIconsFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
void testInstallIconsWithUndo()
diff --git a/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z
new file mode 100644
index 000000000..8ba90b13b
--- /dev/null
+++ b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z
Binary files differ
diff --git a/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z.sha1 b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z.sha1
new file mode 100644
index 000000000..a5f4399b3
--- /dev/null
+++ b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z.sha1
@@ -0,0 +1 @@
+a0268f80fd2954271fe7d2eae584c13a6d143838 \ No newline at end of file
diff --git a/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..131a2d9ff
--- /dev/null
+++ b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,23 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>true</Checksum>
+ <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>
+ <UpdateFile CompressedSize="225" UncompressedSize="75" OS="Any"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <SHA1>6d7a3e15d11a4d94b81452fc2aa18e705a01c922</SHA1>
+ <Operations>
+ <Operation name="LineReplace">
+ <Argument>@TargetDir@/A.txt</Argument>
+ <Argument>Line to replace.</Argument>
+ <Argument>This line was replaced.</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/linereplaceoperation/settings.qrc b/tests/auto/installer/linereplaceoperation/settings.qrc
index 66969539d..15da313dd 100644
--- a/tests/auto/installer/linereplaceoperation/settings.qrc
+++ b/tests/auto/installer/linereplaceoperation/settings.qrc
@@ -4,5 +4,8 @@
<file>data/repository/A/1.0.2-1content.7z</file>
<file>data/repository/A/1.0.2-1content.7z.sha1</file>
<file>data/repository/A/1.0.2-1meta.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z</file>
+ <file>data/xmloperationrepository/A/1.0.2-1content.7z.sha1</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/linereplaceoperation/tst_linereplaceoperation.cpp b/tests/auto/installer/linereplaceoperation/tst_linereplaceoperation.cpp
index 0492bd104..762ef0211 100644
--- a/tests/auto/installer/linereplaceoperation/tst_linereplaceoperation.cpp
+++ b/tests/auto/installer/linereplaceoperation/tst_linereplaceoperation.cpp
@@ -40,6 +40,25 @@ class tst_linereplaceoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ QString installDir = QInstaller::generateTemporaryFileName();
+ QVERIFY(QDir().mkpath(installDir));
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (installDir, repository);
+ core->installDefaultComponentsSilently();
+
+ QFile file(installDir + QDir::separator() + "A.txt");
+ QVERIFY(file.open(QIODevice::ReadOnly) | QIODevice::Text);
+ QTextStream stream(&file);
+ QCOMPARE(stream.readLine(), QLatin1String("This line was replaced."));
+ QCOMPARE(stream.readLine(), QLatin1String("Another line."));
+ file.close();
+ QDir dir(installDir);
+ QVERIFY(dir.removeRecursively());
+ }
+
private slots:
void initTestCase()
{
@@ -115,23 +134,14 @@ private slots:
QVERIFY(file.remove());
}
- void testPerformingFromCLI()
+ void testLineReplaceFromScript()
{
- QString installDir = QInstaller::generateTemporaryFileName();
- QVERIFY(QDir().mkpath(installDir));
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (installDir, ":///data/repository");
- core->installDefaultComponentsSilently();
+ installFromCLI(":///data/repository");
+ }
- QFile file(installDir + QDir::separator() + "A.txt");
- QVERIFY(file.open(QIODevice::ReadOnly) | QIODevice::Text);
- QTextStream stream(&file);
- QCOMPARE(stream.readLine(), QLatin1String("This line was replaced."));
- QCOMPARE(stream.readLine(), QLatin1String("Another line."));
- file.close();
- QDir dir(installDir);
- QVERIFY(dir.removeRecursively());
- core->deleteLater();
+ void testLineReplaceFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
private:
diff --git a/tests/auto/installer/moveoperation/data/xmloperationrepository/Updates.xml b/tests/auto/installer/moveoperation/data/xmloperationrepository/Updates.xml
new file mode 100644
index 000000000..6707452d8
--- /dev/null
+++ b/tests/auto/installer/moveoperation/data/xmloperationrepository/Updates.xml
@@ -0,0 +1,22 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>false</Checksum>
+ <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>
+ <Operations>
+ <Operation name="Mkdir">
+ <Argument>@TargetDir@/DestinationFolder</Argument>
+ </Operation>
+ <Operation name="Move">
+ <Argument>@InstallerDirPath@/testFile.txt</Argument>
+ <Argument>@TargetDir@/DestinationFolder/testFile.txt</Argument>
+ </Operation>
+ </Operations>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/moveoperation/settings.qrc b/tests/auto/installer/moveoperation/settings.qrc
index d030220ab..04a7daf71 100644
--- a/tests/auto/installer/moveoperation/settings.qrc
+++ b/tests/auto/installer/moveoperation/settings.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>data/repository/Updates.xml</file>
<file>data/repository/A/1.0.2-1meta.7z</file>
+ <file>data/xmloperationrepository/Updates.xml</file>
</qresource>
</RCC>
diff --git a/tests/auto/installer/moveoperation/tst_moveoperation.cpp b/tests/auto/installer/moveoperation/tst_moveoperation.cpp
index f5b7bbcd9..6bc72242a 100644
--- a/tests/auto/installer/moveoperation/tst_moveoperation.cpp
+++ b/tests/auto/installer/moveoperation/tst_moveoperation.cpp
@@ -39,6 +39,27 @@ class tst_moveoperation : public QObject
{
Q_OBJECT
+private:
+ void installFromCLI(const QString &repository)
+ {
+ PackageManagerCore *core = PackageManager::getPackageManagerWithInit
+ (m_testDirectory, repository);
+ core->installDefaultComponentsSilently();
+
+ QFile movedFile(m_testDirectory + QDir::separator() + "DestinationFolder/testFile.txt");
+ QVERIFY(movedFile.exists());
+ QFile originalFile(m_sourceFile);
+ QVERIFY(!originalFile.exists());
+
+ core->setPackageManager();
+ core->commitSessionOperations();
+
+ core->uninstallComponentsSilently(QStringList() << "A");
+
+ QVERIFY(!movedFile.exists());
+ QVERIFY(originalFile.exists());
+ }
+
private slots:
void initTestCase()
{
@@ -101,26 +122,14 @@ private slots:
QVERIFY(QFile::exists(m_destinationFile));
}
- void testPerformingFromCLI()
+ void testMoveOperationFromScript()
{
- PackageManagerCore *core = PackageManager::getPackageManagerWithInit
- (m_testDirectory, ":///data/repository");
- core->installDefaultComponentsSilently();
-
- QFile movedFile(m_testDirectory + QDir::separator() + "DestinationFolder/testFile.txt");
- QVERIFY(movedFile.exists());
- QFile originalFile(m_sourceFile);
- QVERIFY(!originalFile.exists());
-
- core->setPackageManager();
- core->commitSessionOperations();
-
- core->uninstallComponentsSilently(QStringList() << "A");
-
- QVERIFY(!movedFile.exists());
- QVERIFY(originalFile.exists());
+ installFromCLI(":///data/repository");
+ }
- core->deleteLater();
+ void testMoveOperationFromXML()
+ {
+ installFromCLI(":///data/xmloperationrepository");
}
void cleanupTestCase()