diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-02-12 07:18:18 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-02-13 11:46:03 +0000 |
commit | 817a2d41c9d506b7bb5fe3ba17e0a62cb8d59421 (patch) | |
tree | 29de3aea3d26182352b86422d8ad7cb2cb0853f4 /tests/auto | |
parent | 3594bb0d1958d4f69d316738232b713fa4fe5925 (diff) |
Add unit tests for CLI option listPackages
Also remove extra space and quotation marks around printed component
values.
Task-number: QTIFW-1577
Change-Id: If2c81609e32ee40b81a70106b2e9bf8ac536c089
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'tests/auto')
17 files changed, 184 insertions, 1 deletions
diff --git a/tests/auto/installer/cliinterface/cliinterface.pro b/tests/auto/installer/cliinterface/cliinterface.pro new file mode 100644 index 000000000..5387a73a3 --- /dev/null +++ b/tests/auto/installer/cliinterface/cliinterface.pro @@ -0,0 +1,8 @@ +include(../../qttest.pri) + +QT += qml + +SOURCES += tst_cliinterface.cpp + +RESOURCES += \ + settings.qrc diff --git a/tests/auto/installer/cliinterface/data/config.xml b/tests/auto/installer/cliinterface/data/config.xml new file mode 100644 index 000000000..041ce5062 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/config.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Installer> + <Name>Your application</Name> + <Version>1.2.3</Version> + <MaintenanceToolName></MaintenanceToolName> + <MaintenanceToolIniFile></MaintenanceToolIniFile> + <TargetConfigurationFile></TargetConfigurationFile> +</Installer> diff --git a/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z Binary files differnew file mode 100644 index 000000000..5a9383e7e --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z diff --git a/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z.sha1 b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z.sha1 new file mode 100644 index 000000000..fd0bc548c --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1content.7z.sha1 @@ -0,0 +1 @@ +643cb71b2337d5a49d57a5bc3c636ee9b84c0802
\ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1meta.7z b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1meta.7z Binary files differnew file mode 100644 index 000000000..6ef0b7959 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/A/1.0.2-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/repository/AB/1.0.2-1meta.7z b/tests/auto/installer/cliinterface/data/repository/AB/1.0.2-1meta.7z Binary files differnew file mode 100644 index 000000000..6b5e5ac91 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/AB/1.0.2-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..dfe41ad15 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z diff --git a/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z.sha1 b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..50a632b49 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +c7b9ab370efe036171dda7b71cd95021747cb101
\ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1meta.7z b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1meta.7z Binary files differnew file mode 100644 index 000000000..12d54f94c --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/B/1.0.0-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z Binary files differnew file mode 100644 index 000000000..7d03dca9c --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z diff --git a/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z.sha1 b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z.sha1 new file mode 100644 index 000000000..91ead97f0 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1content.7z.sha1 @@ -0,0 +1 @@ +c8b7076fabaaf6b9d27f27350c577118c24f426b
\ No newline at end of file diff --git a/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1meta.7z b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1meta.7z Binary files differnew file mode 100644 index 000000000..46bae0179 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/C/1.0.0-1meta.7z diff --git a/tests/auto/installer/cliinterface/data/repository/Updates.xml b/tests/auto/installer/cliinterface/data/repository/Updates.xml new file mode 100644 index 000000000..c7b11dc03 --- /dev/null +++ b/tests/auto/installer/cliinterface/data/repository/Updates.xml @@ -0,0 +1,48 @@ +<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="222" OS="Any" UncompressedSize="72"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9d54e3a5adf3563913feee8ba23a99fb80d46590</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>B</Name> + <DisplayName>B</DisplayName> + <Description>Example component B</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile CompressedSize="222" OS="Any" UncompressedSize="72"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>9170d55a6af81c1a6a63d708a4ab6ed359775cd9</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>C</Name> + <DisplayName>C</DisplayName> + <Description>Example component C</Description> + <Version>1.0.0-1</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile CompressedSize="222" OS="Any" UncompressedSize="72"/> + <DownloadableArchives>content.7z</DownloadableArchives> + <SHA1>5b3939da1af492382c68388fc796837e4c36b876</SHA1> + </PackageUpdate> + <PackageUpdate> + <Name>AB</Name> + <DisplayName>AB</DisplayName> + <Description>Example component AB</Description> + <Version>1.0.2-1</Version> + <ReleaseDate>2015-01-01</ReleaseDate> + <Default>true</Default> + <UpdateFile UncompressedSize="0" OS="Any" CompressedSize="0"/> + <SHA1>f75e65b1a0f68abb77fc41da08fc26dda5409a18</SHA1> + </PackageUpdate> +</Updates> diff --git a/tests/auto/installer/cliinterface/installer-config/config.xml b/tests/auto/installer/cliinterface/installer-config/config.xml new file mode 100644 index 000000000..adc24631b --- /dev/null +++ b/tests/auto/installer/cliinterface/installer-config/config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Installer> + <Name>test</Name> + <Version>1.0.0</Version> +</Installer> diff --git a/tests/auto/installer/cliinterface/settings.qrc b/tests/auto/installer/cliinterface/settings.qrc new file mode 100644 index 000000000..614c01e3e --- /dev/null +++ b/tests/auto/installer/cliinterface/settings.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>data/config.xml</file> + <file>data/repository/Updates.xml</file> + </qresource> + <qresource prefix="/metadata"> + <file>installer-config/config.xml</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/cliinterface/tst_cliinterface.cpp b/tests/auto/installer/cliinterface/tst_cliinterface.cpp new file mode 100644 index 000000000..7f7e45724 --- /dev/null +++ b/tests/auto/installer/cliinterface/tst_cliinterface.cpp @@ -0,0 +1,101 @@ +/************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include "metadatajob.h" +#include "settings.h" + +#include <binarycontent.h> +#include <component.h> +#include <errors.h> +#include <fileutils.h> +#include <packagemanagercore.h> +#include <progresscoordinator.h> + +#include <QLoggingCategory> +#include <QTest> + +using namespace QInstaller; + +class tst_CLIInterface : public QObject +{ + Q_OBJECT + +private: + void setIgnoreMessage() + { + QTest::ignoreMessage(QtDebugMsg, "Id: A"); + QTest::ignoreMessage(QtDebugMsg, "Id: B"); + QTest::ignoreMessage(QtDebugMsg, "Id: C"); + QTest::ignoreMessage(QtDebugMsg, "Id: AB"); + } + +private slots: + void testListAvailablePackages() + { + QString loggingRules = (QLatin1String("ifw.* = false\n" + "ifw.package.name = true\n")); + Settings settings = Settings::fromFileAndPrefix(":///data/config.xml", ":///data"); + const QList<OperationBlob> ops; + + QTest::ignoreMessage(QtDebugMsg, "Operations sanity check succeeded."); + PackageManagerCore *core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, ops); + QSet<Repository> repoList; + Repository repo = Repository::fromUserInput(":///data/repository"); + repoList.insert(repo); + + core->settings().setDefaultRepositories(repoList); + + QLoggingCategory::setFilterRules(loggingRules); + + setIgnoreMessage(); + core->listAvailablePackages(QLatin1String(".")); + + QTest::ignoreMessage(QtDebugMsg, "Id: A"); + QTest::ignoreMessage(QtDebugMsg, "Id: AB"); + core->listAvailablePackages(QLatin1String("A")); + + QTest::ignoreMessage(QtDebugMsg, "Id: A"); + QTest::ignoreMessage(QtDebugMsg, "Id: AB"); + core->listAvailablePackages(QLatin1String("A.*")); + + + QTest::ignoreMessage(QtDebugMsg, "Id: B"); + core->listAvailablePackages(QLatin1String("^B")); + + QTest::ignoreMessage(QtDebugMsg, "Id: B"); + core->listAvailablePackages(QLatin1String("^B.*")); + + QTest::ignoreMessage(QtDebugMsg, "Id: C"); + core->listAvailablePackages(QLatin1String("^C")); + } +}; + + +QTEST_MAIN(tst_CLIInterface) + +#include "tst_cliinterface.moc" diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 89f59c6f7..8528f599a 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -24,7 +24,8 @@ SUBDIRS += \ clientserver \ factory \ replaceoperation \ - brokeninstaller + brokeninstaller \ + cliinterface win32 { SUBDIRS += registerfiletypeoperation |