summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-14 16:02:51 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-14 16:02:51 +0100
commita02e62f17f7b51c489e209ab6937ad717fbcfb07 (patch)
tree56b99fd6099dfbfdeebc561edc717eb1bcdb3832 /tests
parentac2721e954142e534e3acced8a90ef6cf876efa7 (diff)
downloadMultiMC-a02e62f17f7b51c489e209ab6937ad717fbcfb07.tar
MultiMC-a02e62f17f7b51c489e209ab6937ad717fbcfb07.tar.gz
MultiMC-a02e62f17f7b51c489e209ab6937ad717fbcfb07.tar.lz
MultiMC-a02e62f17f7b51c489e209ab6937ad717fbcfb07.tar.xz
MultiMC-a02e62f17f7b51c489e209ab6937ad717fbcfb07.zip
Tests for parsing of channel lists in UpdateChecker
Diffstat (limited to 'tests')
-rw-r--r--tests/data/channels.json23
-rw-r--r--tests/data/noChannels.json5
-rw-r--r--tests/data/oneChannel.json11
-rw-r--r--tests/tst_UpdateChecker.cpp69
4 files changed, 107 insertions, 1 deletions
diff --git a/tests/data/channels.json b/tests/data/channels.json
new file mode 100644
index 00000000..dd99fd27
--- /dev/null
+++ b/tests/data/channels.json
@@ -0,0 +1,23 @@
+{
+ "format_version": 0,
+ "channels": [
+ {
+ "id": "develop",
+ "name": "Develop",
+ "description": "The channel called \"develop\"",
+ "url": "http://example.org/stuff"
+ },
+ {
+ "id": "stable",
+ "name": "Stable",
+ "description": "It's stable at least",
+ "url": "ftp://username@host/path/to/stuff"
+ },
+ {
+ "id": "42",
+ "name": "The Channel",
+ "description": "This is the channel that is going to answer all of your questions",
+ "url": "https://dent.me/tea"
+ }
+ ]
+}
diff --git a/tests/data/noChannels.json b/tests/data/noChannels.json
new file mode 100644
index 00000000..bbb2cb70
--- /dev/null
+++ b/tests/data/noChannels.json
@@ -0,0 +1,5 @@
+{
+ "format_version": 0,
+ "channels": [
+ ]
+}
diff --git a/tests/data/oneChannel.json b/tests/data/oneChannel.json
new file mode 100644
index 00000000..84727ac7
--- /dev/null
+++ b/tests/data/oneChannel.json
@@ -0,0 +1,11 @@
+{
+ "format_version": 0,
+ "channels": [
+ {
+ "id": "develop",
+ "name": "Develop",
+ "description": "The channel called \"develop\"",
+ "url": "http://example.org/stuff"
+ }
+ ]
+}
diff --git a/tests/tst_UpdateChecker.cpp b/tests/tst_UpdateChecker.cpp
index dd31f253..a73dc1fd 100644
--- a/tests/tst_UpdateChecker.cpp
+++ b/tests/tst_UpdateChecker.cpp
@@ -1,6 +1,18 @@
#include <QTest>
+#include <QSignalSpy>
#include "TestUtil.h"
+#include "logic/updater/UpdateChecker.h"
+
+Q_DECLARE_METATYPE(UpdateChecker::ChannelListEntry)
+
+bool operator==(const UpdateChecker::ChannelListEntry &e1, const UpdateChecker::ChannelListEntry &e2)
+{
+ return e1.id == e2.id &&
+ e1.name == e2.name &&
+ e1.description == e2.description &&
+ e1.url == e2.url;
+}
class UpdateCheckerTest : public QObject
{
@@ -15,8 +27,63 @@ slots:
{
}
+
+ static QString findTestDataUrl(const char *file)
+ {
+ return QUrl::fromLocalFile(QFINDTESTDATA(file)).toString();
+ }
+ void tst_ChannelListParsing_data()
+ {
+ QTest::addColumn<QString>("channel");
+ QTest::addColumn<QString>("channelUrl");
+ QTest::addColumn<bool>("hasChannels");
+ QTest::addColumn<QList<UpdateChecker::ChannelListEntry> >("result");
+
+ QTest::newRow("no channels")
+ << QString()
+ << findTestDataUrl("tests/data/noChannels.json")
+ << false
+ << QList<UpdateChecker::ChannelListEntry>();
+ QTest::newRow("one channel")
+ << QString("develop")
+ << findTestDataUrl("tests/data/oneChannel.json")
+ << true
+ << (QList<UpdateChecker::ChannelListEntry>() << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", "http://example.org/stuff"});
+ QTest::newRow("several channels")
+ << QString("develop")
+ << findTestDataUrl("tests/data/channels.json")
+ << true
+ << (QList<UpdateChecker::ChannelListEntry>()
+ << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", "http://example.org/stuff"}
+ << UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", "ftp://username@host/path/to/stuff"}
+ << UpdateChecker::ChannelListEntry{"42", "The Channel", "This is the channel that is going to answer all of your questions", "https://dent.me/tea"});
+ }
+ void tst_ChannelListParsing()
+ {
+ QFETCH(QString, channel);
+ QFETCH(QString, channelUrl);
+ QFETCH(bool, hasChannels);
+ QFETCH(QList<UpdateChecker::ChannelListEntry>, result);
+
+ UpdateChecker checker;
+
+ QSignalSpy spy(&checker, SIGNAL(channelListLoaded()));
+ QVERIFY(spy.isValid());
+
+ checker.setCurrentChannel(channel);
+ checker.setChannelListUrl(channelUrl);
+
+ checker.updateChanList();
+
+ QVERIFY(spy.wait());
+
+ QCOMPARE(spy.size(), 1);
+
+ QCOMPARE(checker.hasChannels(), hasChannels);
+ QCOMPARE(checker.getChannelList(), result);
+ }
};
-QTEST_GUILESS_MAIN(UpdateCheckerTest)
+QTEST_GUILESS_MAIN_MULTIMC(UpdateCheckerTest)
#include "tst_UpdateChecker.moc"