summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-03-25 14:44:35 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-03-31 06:35:34 +0000
commit8d025e5dcd841939bdf44fc4705dffe429bca5b5 (patch)
treedd21ddf29cbefe4c7a0dcad3b0553a77ce85b143 /tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
parent3ed160565686da90f98c23918b57528dfcb6000e (diff)
Fix bug in command line option update
Update was working only for latter component if several was given as arguments. Added also unit tests for cli option update Also created common functions which are used by several command line test. Task-number: QTIFW-1695 Change-Id: I472e1c34bcfb1b60cda110353068f2cec64c468f Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp')
-rw-r--r--tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
new file mode 100644
index 000000000..1736a2f6c
--- /dev/null
+++ b/tests/auto/installer/commandlineupdate/tst_commandlineupdate.cpp
@@ -0,0 +1,144 @@
+/**************************************************************************
+**
+** 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 "init.h"
+#include "../shared/commonfunctions.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_CommandLineUpdate : public QObject
+{
+ Q_OBJECT
+
+private:
+ void setRepository(const QString &repository)
+ {
+ core->reset();
+ core->cancelMetaInfoJob(); //Call cancel to reset metadata so that update repositories are fetched
+
+ QSet<Repository> repoList;
+ Repository repo = Repository::fromUserInput(repository);
+ repoList.insert(repo);
+ core->settings().setDefaultRepositories(repoList);
+ }
+
+private slots:
+ void initTestCase()
+ {
+ core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList<OperationBlob> ());
+ m_installDir = QInstaller::generateTemporaryFileName();
+ QDir().mkpath(m_installDir);
+ core->setValue(scTargetDir, m_installDir);
+ }
+
+ void testUpdatePackageSilently()
+ {
+ QInstaller::init(); //This will eat debug output
+ setRepository(":///data/installPackagesRepository");
+ core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontent.txt"
+ << "installcontentA.txt" << "installcontentE.txt" << "installcontentG.txt"
+ << "installcontentB.txt" << "installcontentD.txt");
+ core->commitSessionOperations();
+
+ setRepository(":///data/installPackagesRepositoryUpdate");
+ core->updateComponentsSilently(QStringList() << "componentA");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentA", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentA", "1.0.0content.txt");
+ VerifyInstaller::verifyFileExistence(m_installDir, QStringList() << "components.xml" << "installcontentA_update.txt"
+ << "installcontentE.txt" << "installcontentG.txt"
+ << "installcontentB.txt" << "installcontentD.txt");
+ }
+
+ void testUpdateTwoPackageSilently()
+ {
+ QInstaller::init(); //This will eat debug output
+ setRepository(":///data/installPackagesRepository");
+ core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB" << "componentG");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "1.0.0content.txt");
+ core->commitSessionOperations();
+
+ setRepository(":///data/installPackagesRepositoryUpdate");
+ core->updateComponentsSilently(QStringList() << "componentB" << "componentG");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentB", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentG", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentB", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentG", "1.0.0content.txt");
+ }
+
+ void testUpdateAllPackagesSilently()
+ {
+ QInstaller::init(); //This will eat debug output
+ setRepository(":///data/installPackagesRepository");
+ core->installSelectedComponentsSilently(QStringList() << "componentA" << "componentB" << "componentG" << "componentF");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent1.subsubcomponent1", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2", "1.0.0content.txt");
+ core->commitSessionOperations();
+
+ setRepository(":///data/installPackagesRepositoryUpdate");
+ core->updateComponentsSilently(QStringList());
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResources(m_installDir, "componentF.subcomponent2", "2.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentF", "1.0.0content.txt");
+ VerifyInstaller::verifyInstallerResourceFileDeletion(m_installDir, "componentF.subcomponent2", "1.0.0content.txt");
+ }
+
+ void cleanupTestCase()
+ {
+ QDir dir(m_installDir);
+ QVERIFY(dir.removeRecursively());
+ delete core;
+ }
+
+private:
+ QString m_installDir;
+ PackageManagerCore *core;
+};
+
+
+QTEST_MAIN(tst_CommandLineUpdate)
+
+#include "tst_commandlineupdate.moc"