summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7zbin0 -> 144 bytes
-rw-r--r--tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z.sha11
-rw-r--r--tests/auto/installer/messageboxhandler/data/invalidhash/Updates.xml15
-rw-r--r--tests/auto/installer/messageboxhandler/data/invalidoperation/A/1.0.2-1meta.7zbin0 -> 841 bytes
-rw-r--r--tests/auto/installer/messageboxhandler/data/invalidoperation/Updates.xml13
-rw-r--r--tests/auto/installer/messageboxhandler/data/missingarchive/C/1.0.0content.7z.sha11
-rw-r--r--tests/auto/installer/messageboxhandler/data/missingarchive/Updates.xml16
-rw-r--r--tests/auto/installer/messageboxhandler/messageboxhandler.pro4
-rw-r--r--tests/auto/installer/messageboxhandler/settings.qrc11
-rw-r--r--tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp119
10 files changed, 173 insertions, 7 deletions
diff --git a/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z b/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z
new file mode 100644
index 000000000..4663e2b7c
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z
Binary files differ
diff --git a/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z.sha1 b/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z.sha1
new file mode 100644
index 000000000..281381b97
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/invalidhash/B/1.0.0-1content.7z.sha1
@@ -0,0 +1 @@
+1c99fe9980cb71dde6a8468c9aa09b4153bc3bff \ No newline at end of file
diff --git a/tests/auto/installer/messageboxhandler/data/invalidhash/Updates.xml b/tests/auto/installer/messageboxhandler/data/invalidhash/Updates.xml
new file mode 100644
index 000000000..2dd2ca2d5
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/invalidhash/Updates.xml
@@ -0,0 +1,15 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>true</Checksum>
+ <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 UncompressedSize="74" OS="Any" CompressedSize="224"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/messageboxhandler/data/invalidoperation/A/1.0.2-1meta.7z b/tests/auto/installer/messageboxhandler/data/invalidoperation/A/1.0.2-1meta.7z
new file mode 100644
index 000000000..3653317c6
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/invalidoperation/A/1.0.2-1meta.7z
Binary files differ
diff --git a/tests/auto/installer/messageboxhandler/data/invalidoperation/Updates.xml b/tests/auto/installer/messageboxhandler/data/invalidoperation/Updates.xml
new file mode 100644
index 000000000..77b5a9956
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/invalidoperation/Updates.xml
@@ -0,0 +1,13 @@
+<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>
+ <Script>script.qs</Script>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/messageboxhandler/data/missingarchive/C/1.0.0content.7z.sha1 b/tests/auto/installer/messageboxhandler/data/missingarchive/C/1.0.0content.7z.sha1
new file mode 100644
index 000000000..281381b97
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/missingarchive/C/1.0.0content.7z.sha1
@@ -0,0 +1 @@
+1c99fe9980cb71dde6a8468c9aa09b4153bc3bff \ No newline at end of file
diff --git a/tests/auto/installer/messageboxhandler/data/missingarchive/Updates.xml b/tests/auto/installer/messageboxhandler/data/missingarchive/Updates.xml
new file mode 100644
index 000000000..0c5f7e211
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/data/missingarchive/Updates.xml
@@ -0,0 +1,16 @@
+<Updates>
+ <ApplicationName>{AnyApplication}</ApplicationName>
+ <ApplicationVersion>1.0.0</ApplicationVersion>
+ <Checksum>true</Checksum>
+ <PackageUpdate>
+ <Name>C</Name>
+ <DisplayName>C</DisplayName>
+ <Description>Example component C</Description>
+ <Version>1.0.0</Version>
+ <ReleaseDate>2015-01-01</ReleaseDate>
+ <Default>true</Default>
+ <UpdateFile CompressedSize="224" OS="Any" UncompressedSize="74"/>
+ <DownloadableArchives>content.7z</DownloadableArchives>
+ <SHA1>3c940d54a1643ae8020162797860e827f8d246ca</SHA1>
+ </PackageUpdate>
+</Updates>
diff --git a/tests/auto/installer/messageboxhandler/messageboxhandler.pro b/tests/auto/installer/messageboxhandler/messageboxhandler.pro
index c63b2e35b..3bb0f7b64 100644
--- a/tests/auto/installer/messageboxhandler/messageboxhandler.pro
+++ b/tests/auto/installer/messageboxhandler/messageboxhandler.pro
@@ -3,3 +3,7 @@ include(../../qttest.pri)
QT += qml widgets
SOURCES += tst_messageboxhandler.cpp
+
+RESOURCES += \
+ settings.qrc \
+ ..\shared\config.qrc
diff --git a/tests/auto/installer/messageboxhandler/settings.qrc b/tests/auto/installer/messageboxhandler/settings.qrc
new file mode 100644
index 000000000..51e4bba19
--- /dev/null
+++ b/tests/auto/installer/messageboxhandler/settings.qrc
@@ -0,0 +1,11 @@
+<RCC>
+ <qresource prefix="/">
+ <file>data/invalidhash/Updates.xml</file>
+ <file>data/invalidhash/B/1.0.0-1content.7z</file>
+ <file>data/invalidhash/B/1.0.0-1content.7z.sha1</file>
+ <file>data/invalidoperation/Updates.xml</file>
+ <file>data/invalidoperation/A/1.0.2-1meta.7z</file>
+ <file>data/missingarchive/Updates.xml</file>
+ <file>data/missingarchive/C/1.0.0content.7z.sha1</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
index dd127f626..1c819fa7c 100644
--- a/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
+++ b/tests/auto/installer/messageboxhandler/tst_messageboxhandler.cpp
@@ -1,7 +1,42 @@
+/**************************************************************************
+**
+** 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 <messageboxhandler.h>
#include <qinstallerglobal.h>
#include <scriptengine.h>
#include <packagemanagercore.h>
+#include <component.h>
+#include <utils.h>
+#include <fileutils.h>
+#include <binarycontent.h>
+#include <packagemanagercore.h>
+#include <settings.h>
+#include <init.h>
#include <QTest>
#include <QMetaEnum>
@@ -26,7 +61,15 @@ QT_END_NAMESPACE
class tst_MessageBoxHandler : public QObject
{
Q_OBJECT
-public:
+private:
+ void setRepository(const QString &repository) {
+ core->cancelMetaInfoJob();
+ QSet<Repository> repoList;
+ Repository repo = Repository::fromUserInput(repository);
+ repoList.insert(repo);
+ core->settings().setDefaultRepositories(repoList);
+ }
+
private slots:
void initTestCase()
{
@@ -46,12 +89,21 @@ private slots:
if (enumValue == QMessageBox::LastButton)
break;
}
+
+ QInstaller::init(); //This will eat debug output
+
+ core = new PackageManagerCore(BinaryContent::MagicInstallerMarker, QList<OperationBlob> (),
+ QString(), Protocol::DefaultAuthorizationKey, Protocol::Mode::Production,
+ QHash<QString, QString>(), true);
+ core->setAllowedRunningProcesses(QStringList() << QCoreApplication::applicationFilePath());
+ m_installDir = QInstaller::generateTemporaryFileName();
+ QDir().mkpath(m_installDir);
+ core->setValue(scTargetDir, m_installDir);
}
void testScriptButtonValues()
{
- PackageManagerCore core;
- ScriptEngine *scriptEngine = new ScriptEngine(&core);
+ ScriptEngine *scriptEngine = new ScriptEngine(core);
QMapIterator<QMessageBox::StandardButton, QString> i(m_standardButtonValueMap);
while (i.hasNext()) {
i.next();
@@ -67,8 +119,6 @@ private slots:
void testDefaultAction()
{
- const char ignoreMessage[] = "Created critical message box \"TestError\": \"A test error\", "
- "\"This is a test error message.\"";
srand(time(0)); /* initialize random seed: */
int standardButtons = QMessageBox::NoButton;
@@ -82,8 +132,6 @@ private slots:
// use only every 5th run to reduce the time which it takes to run this test
if (iSecret > 2)
continue;
-
- QTest::ignoreMessage(QtDebugMsg, ignoreMessage);
int returnButton = MessageBoxHandler::instance()->critical(QLatin1String("TestError"),
QLatin1String("A test error"), QLatin1String("This is a test error message."),
static_cast<QMessageBox::StandardButton>(standardButtons));
@@ -101,9 +149,66 @@ private slots:
} while (standardButtons < m_maxStandardButtons);
}
+ void invalidOperationAutoReject()
+ {
+ setRepository(":///data/invalidoperation");
+ core->autoRejectMessageBoxes();
+ core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Canceled, core->status());
+ }
+
+ void invalidOperationAutoAccept()
+ {
+ setRepository(":///data/invalidoperation");
+ core->autoAcceptMessageBoxes();
+ core->installDefaultComponentsSilently();
+ QCOMPARE(PackageManagerCore::Running, core->status());
+ }
+
+ void invalidHashAutoReject()
+ {
+ setRepository(":///data/invalidhash");
+ core->autoRejectMessageBoxes();
+ core->installSelectedComponentsSilently(QStringList () << "B");
+ QCOMPARE(PackageManagerCore::Failure, core->status());
+ }
+
+ void invalidHashAutoAccept()
+ {
+ setRepository(":///data/invalidhash");
+ core->autoAcceptMessageBoxes();
+ core->installSelectedComponentsSilently(QStringList () << "B");
+ QCOMPARE(PackageManagerCore::Failure, core->status());
+ }
+
+ void missingArchiveAutoReject()
+ {
+ setRepository(":///data/missingarchive");
+ core->autoRejectMessageBoxes();
+ core->installSelectedComponentsSilently(QStringList () << "C");
+ QCOMPARE(PackageManagerCore::Canceled, core->status());
+ }
+
+ void missingArchiveAutoAccept()
+ {
+ setRepository(":///data/missingarchive");
+ core->autoAcceptMessageBoxes();
+ core->installSelectedComponentsSilently(QStringList () << "C");
+ QCOMPARE(PackageManagerCore::Canceled, core->status());
+ }
+
+ void cleanupTestCase()
+ {
+ core->deleteLater();
+ QDir dir(m_installDir);
+ QVERIFY(dir.removeRecursively());
+ }
+
private:
QMap<QMessageBox::StandardButton, QString> m_standardButtonValueMap;
int m_maxStandardButtons;
+ PackageManagerCore *core;
+ QString m_installDir;
};
QTEST_MAIN(tst_MessageBoxHandler)