summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer')
-rw-r--r--tests/auto/installer/installer.pro4
-rw-r--r--tests/auto/installer/settings/data/malformed_config.xml8
-rw-r--r--tests/auto/installer/settings/data/tutorial_config.xml9
-rw-r--r--tests/auto/installer/settings/settings.pro8
-rw-r--r--tests/auto/installer/settings/settings.qrc6
-rw-r--r--tests/auto/installer/settings/tst_settings.cpp89
6 files changed, 124 insertions, 0 deletions
diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro
new file mode 100644
index 000000000..c01c4125c
--- /dev/null
+++ b/tests/auto/installer/installer.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ settings
diff --git a/tests/auto/installer/settings/data/malformed_config.xml b/tests/auto/installer/settings/data/malformed_config.xml
new file mode 100644
index 000000000..ebac3027c
--- /dev/null
+++ b/tests/auto/installer/settings/data/malformed_config.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <Title>Your application Installer</Title>
+ <Publisher>Your vendor</Publisher>
+ <StartMenuDir>Super App</StartMenuDir>
+ <TargetDir>@rootDir@InstallationDirectory</TargetDir>
diff --git a/tests/auto/installer/settings/data/tutorial_config.xml b/tests/auto/installer/settings/data/tutorial_config.xml
new file mode 100644
index 000000000..235434776
--- /dev/null
+++ b/tests/auto/installer/settings/data/tutorial_config.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Installer>
+ <Name>Your application</Name>
+ <Version>1.2.3</Version>
+ <Title>Your application Installer</Title>
+ <Publisher>Your vendor</Publisher>
+ <StartMenuDir>Super App</StartMenuDir>
+ <TargetDir>@rootDir@InstallationDirectory</TargetDir>
+</Installer>
diff --git a/tests/auto/installer/settings/settings.pro b/tests/auto/installer/settings/settings.pro
new file mode 100644
index 000000000..a1932af06
--- /dev/null
+++ b/tests/auto/installer/settings/settings.pro
@@ -0,0 +1,8 @@
+include(../../qttest.pri)
+
+QT += network
+
+SOURCES += tst_settings.cpp
+
+RESOURCES += \
+ settings.qrc
diff --git a/tests/auto/installer/settings/settings.qrc b/tests/auto/installer/settings/settings.qrc
new file mode 100644
index 000000000..eaa92b93e
--- /dev/null
+++ b/tests/auto/installer/settings/settings.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>data/tutorial_config.xml</file>
+ <file>data/malformed_config.xml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/installer/settings/tst_settings.cpp b/tests/auto/installer/settings/tst_settings.cpp
new file mode 100644
index 000000000..2fcd6bf3f
--- /dev/null
+++ b/tests/auto/installer/settings/tst_settings.cpp
@@ -0,0 +1,89 @@
+#include <QTest>
+#include "settings.h"
+#include "errors.h"
+#include "repository.h"
+
+#include <QFile>
+
+using namespace QInstaller;
+
+class tst_Settings : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void loadConfig();
+ void loadNotExistingConfig();
+ void loadMalformedConfig();
+};
+
+void tst_Settings::loadConfig()
+{
+ Settings settings =
+ Settings::fromFileAndPrefix(":///data/tutorial_config.xml", ":///data");
+
+ // specified values
+ QCOMPARE(settings.applicationName(), QLatin1String("Your application"));
+ QCOMPARE(settings.applicationVersion(), QLatin1String("1.2.3"));
+ QCOMPARE(settings.title(), QLatin1String("Your application Installer"));
+ QCOMPARE(settings.publisher(), QLatin1String("Your vendor"));
+ QCOMPARE(settings.startMenuDir(), QLatin1String("Super App"));
+ QCOMPARE(settings.targetDir(), QLatin1String("@rootDir@InstallationDirectory"));
+
+ // default values
+ QCOMPARE(settings.logo(), QLatin1String(":///data/"));
+ QCOMPARE(settings.logoSmall(), QLatin1String(":///data/"));
+ QCOMPARE(settings.url(), QString());
+ QCOMPARE(settings.watermark(), QLatin1String(":///data/"));
+ QCOMPARE(settings.background(), QLatin1String(":///data/"));
+ QCOMPARE(settings.icon(), QLatin1String(":/installer.png"));
+ QCOMPARE(settings.runProgram(), QString());
+ QCOMPARE(settings.runProgramDescription(), QString());
+ QCOMPARE(settings.adminTargetDir(), QString());
+ QCOMPARE(settings.removeTargetDir(), QLatin1String("true"));
+ QCOMPARE(settings.uninstallerName(), QLatin1String("uninstall"));
+ QCOMPARE(settings.uninstallerIniFile(), QLatin1String("uninstall.ini"));
+ QCOMPARE(settings.configurationFileName(), QLatin1String("components.xml"));
+ QCOMPARE(settings.dependsOnLocalInstallerBinary(), false);
+ QCOMPARE(settings.repositorySettingsPageVisible(), true);
+ QCOMPARE(settings.hasReplacementRepos(), false);
+ QCOMPARE(settings.allowSpaceInPath(), false);
+ QCOMPARE(settings.certificateFiles(), QStringList());
+ QCOMPARE(settings.allowNonAsciiCharacters(), false);
+
+ QCOMPARE(settings.hasReplacementRepos(), false);
+ QCOMPARE(settings.repositories(), QSet<Repository>());
+ QCOMPARE(settings.defaultRepositories(), QSet<Repository>());
+ QCOMPARE(settings.temporaryRepositories(), QSet<Repository>());
+ QCOMPARE(settings.userRepositories(), QSet<Repository>());
+
+ QCOMPARE(settings.proxyType(), Settings::NoProxy);
+ QCOMPARE(settings.ftpProxy(), QNetworkProxy());
+ QCOMPARE(settings.httpProxy(), QNetworkProxy());
+}
+
+void tst_Settings::loadNotExistingConfig()
+{
+ try {
+ Settings::fromFileAndPrefix(":/data/inexisting_config.xml", ":/data");
+ } catch (const Error &error) {
+ QVERIFY(error.message() == ("Could not open settings file :/data/inexisting_config.xml for reading: Unknown error"));
+ return;
+ }
+ QFAIL("No exception thrown");
+}
+
+void tst_Settings::loadMalformedConfig()
+{
+ try {
+ Settings::fromFileAndPrefix(":/data/malformed_config.xml", ":/data");
+ } catch (const Error &error) {
+ QVERIFY(error.message().startsWith("Xml parse error"));
+ return;
+ }
+ QFAIL("No exception thrown");
+}
+
+QTEST_MAIN(tst_Settings)
+
+#include "tst_settings.moc"