diff options
Diffstat (limited to 'tests')
45 files changed, 642 insertions, 241 deletions
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 Binary files differnew file mode 100644 index 000000000..90b958cdb --- /dev/null +++ b/tests/auto/installer/appendfileoperation/data/xmloperationrepository/A/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..920ed1d99 --- /dev/null +++ b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1content.7z 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 Binary files differnew file mode 100644 index 000000000..7449d052b --- /dev/null +++ b/tests/auto/installer/copydirectoryoperation/data/xmloperationrepository/A/1.0.2-1meta.7z 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 Binary files differnew file mode 100644 index 000000000..8ba90b13b --- /dev/null +++ b/tests/auto/installer/copyoperationtest/data/xmloperationrepository/A/1.0.2-1content.7z 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 Binary files differnew file mode 100644 index 000000000..8ba90b13b --- /dev/null +++ b/tests/auto/installer/createshortcutoperation/data/xmloperationrepository/A/1.0.2-1content.7z 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 Binary files differnew file mode 100644 index 000000000..949b50689 --- /dev/null +++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0anothercontent.7z 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 Binary files differnew file mode 100644 index 000000000..585f58296 --- /dev/null +++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0content.7z 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 Binary files differnew file mode 100644 index 000000000..1c0c5ccfb --- /dev/null +++ b/tests/auto/installer/extractarchiveoperationtest/data/xmloperationrepository/A/1.0.0default.7z 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 Binary files differnew file mode 100644 index 000000000..9d58b172e --- /dev/null +++ b/tests/auto/installer/installiconsoperation/data/xmloperationrepository/A/1.0.2-1content.7z 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 Binary files differnew file mode 100644 index 000000000..8ba90b13b --- /dev/null +++ b/tests/auto/installer/linereplaceoperation/data/xmloperationrepository/A/1.0.2-1content.7z 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() |