Extend ServerInfo unit test for manual URL.
[maemo-rb.git] / rbutil / rbutilqt / test / test-serverinfo.cpp
blobe29470c90963138e8eaef901198a4bb81d5fe5d0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2012 Dominik Riebeling
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
21 #include <QtTest/QtTest>
22 #include <QObject>
23 #include "serverinfo.h"
25 class TestServerInfo : public QObject
27 Q_OBJECT
28 private slots:
29 void testMain();
32 const char* testinfo =
33 "[release]\n"
34 "archosfmrecorder=3.11.2\n"
35 "iaudiom3=3.11.2,http://download.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n"
36 "sansae200 = 3.11.2\n"
37 "iriverh100 = 3.11.2, http://download.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n"
38 "iriverh300 = \n"
39 "[release-candidate]\n"
40 "gigabeatfx=f9dce96,http://download.rockbox.org/release-candidate/f9dce96/rockbox-gigabeatfx.zip\n"
41 "archosfmrecorder=f9dce96\n"
42 "archosrecorder = f9dce96\n"
43 "iaudiox5=f9dce96,http://download.rockbox.org/release-candidate/f9dce96/rockbox-iaudiox5.zip\n";
46 struct testvector {
47 const char* target;
48 ServerInfo::ServerInfos entry;
49 const char* expected;
53 const struct testvector testdata[] =
55 { "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" },
56 { "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" },
57 { "iaudiom3", ServerInfo::CurReleaseUrl, "http://download.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" },
58 { "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" },
59 { "sansae200", ServerInfo::CurReleaseUrl, "http://download.rockbox.org/release/3.11.2/rockbox-sansae200-3.11.2.zip" },
60 { "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" },
61 { "iriverh100", ServerInfo::CurReleaseUrl, "http://download.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" },
62 { "iriverh300", ServerInfo::CurReleaseVersion, "" },
63 { "iriverh300", ServerInfo::CurReleaseUrl, "" },
64 { "iriverh10", ServerInfo::CurReleaseVersion, "" },
65 { "iriverh10", ServerInfo::CurReleaseUrl, "" },
66 { "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" },
67 { "gigabeatfx", ServerInfo::RelCandidateUrl, "http://download.rockbox.org/release-candidate/f9dce96/rockbox-gigabeatfx.zip" },
68 { "archosfmrecorder", ServerInfo::RelCandidateVersion, "" },
69 { "archosfmrecorder", ServerInfo::RelCandidateUrl, "" },
70 { "archosrecorder", ServerInfo::RelCandidateVersion, "" },
71 { "archosrecorder", ServerInfo::RelCandidateUrl, "" },
72 { "iaudiox5", ServerInfo::RelCandidateVersion, "f9dce96" },
73 { "iaudiox5", ServerInfo::RelCandidateUrl, "http://download.rockbox.org/release-candidate/f9dce96/rockbox-iaudiox5.zip" },
74 { "iaudiox5.v", ServerInfo::RelCandidateVersion, "f9dce96" },
75 { "iaudiox5.v", ServerInfo::RelCandidateUrl, "http://download.rockbox.org/release-candidate/f9dce96/rockbox-iaudiox5.zip" },
76 { "iaudiox5.v", ServerInfo::ManualPdfUrl, "http://download.rockbox.org/manual/rockbox-iaudiox5.pdf" },
77 { "iriverh100", ServerInfo::ManualHtmlUrl, "http://download.rockbox.org/manual/rockbox-iriverh100/rockbox-build.html" },
78 { "iriverh120", ServerInfo::ManualZipUrl, "http://download.rockbox.org/manual/rockbox-iriverh100-html.zip" },
82 void TestServerInfo::testMain()
84 // create a temporary file for test input. Do not use QSettings() to allow
85 // creating different format variations.
86 QTemporaryFile tf(this);
87 tf.open();
88 QString filename = tf.fileName();
89 tf.write(testinfo);
90 tf.close();
92 ServerInfo::readBuildInfo(filename);
94 unsigned int i;
95 for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
96 QString result = ServerInfo::platformValue(testdata[i].target, testdata[i].entry).toString();
97 QCOMPARE(result, QString(testdata[i].expected));
102 QTEST_MAIN(TestServerInfo)
104 // this include is needed because we don't use a separate header file for the
105 // test class. It also needs to be at the end.
106 #include "test-serverinfo.moc"