summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/test/test-serverinfo.cpp104
-rw-r--r--rbutil/rbutilqt/test/test-serverinfo.pro37
2 files changed, 141 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/test/test-serverinfo.cpp b/rbutil/rbutilqt/test/test-serverinfo.cpp
new file mode 100644
index 0000000000..243dc561f9
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-serverinfo.cpp
@@ -0,0 +1,104 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2012 Dominik Riebeling
10 *
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.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include <QtTest/QtTest>
22#include <QObject>
23#include "serverinfo.h"
24
25class TestServerInfo : public QObject
26{
27 Q_OBJECT
28 private slots:
29 void testMain();
30};
31
32const 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";
44
45
46struct testvector {
47 const char* target;
48 ServerInfo::ServerInfos entry;
49 const char* expected;
50};
51
52
53const struct testvector testdata[] =
54{
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};
77
78
79void TestServerInfo::testMain()
80{
81 // create a temporary file for test input. Do not use QSettings() to allow
82 // creating different format variations.
83 QTemporaryFile tf(this);
84 tf.open();
85 QString filename = tf.fileName();
86 tf.write(testinfo);
87 tf.close();
88
89 ServerInfo::readBuildInfo(filename);
90
91 unsigned int i;
92 for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
93 QString result = ServerInfo::platformValue(testdata[i].target, testdata[i].entry).toString();
94 QCOMPARE(result, QString(testdata[i].expected));
95 }
96}
97
98
99QTEST_MAIN(TestServerInfo)
100
101// this include is needed because we don't use a separate header file for the
102// test class. It also needs to be at the end.
103#include "test-serverinfo.moc"
104
diff --git a/rbutil/rbutilqt/test/test-serverinfo.pro b/rbutil/rbutilqt/test/test-serverinfo.pro
new file mode 100644
index 0000000000..1f6b1c1409
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-serverinfo.pro
@@ -0,0 +1,37 @@
1#
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8#
9# All files in this archive are subject to the GNU General Public License.
10# See the file COPYING in the source tree root for full license agreement.
11#
12# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
13# KIND, either express or implied.
14#
15
16#
17include(tests.pri)
18
19TEMPLATE = app
20TARGET = test-serverinfo
21INCLUDEPATH += . ../base
22
23# Input
24SOURCES += \
25 test-serverinfo.cpp \
26 ../base/rbsettings.cpp \
27 ../base/rockboxinfo.cpp \
28 ../base/systeminfo.cpp \
29 ../base/serverinfo.cpp
30
31HEADERS += \
32 ../base/rbsettings.h \
33 ../base/rockboxinfo.h \
34 ../base/systeminfo.h \
35 ../base/serverinfo.h \
36
37RESOURCES += ../rbutilqt.qrc