diff options
Diffstat (limited to 'rbutil/rbutilqt/test')
-rw-r--r-- | rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp | 36 | ||||
-rw-r--r-- | rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp | 105 | ||||
-rw-r--r-- | rbutil/rbutilqt/test/test-playerbuildinfo.cpp | 237 | ||||
-rw-r--r-- | rbutil/rbutilqt/test/test-playerbuildinfo.pro (renamed from rbutil/rbutilqt/test/test-serverinfo.pro) | 9 | ||||
-rw-r--r-- | rbutil/rbutilqt/test/test-serverinfo.cpp | 124 |
5 files changed, 277 insertions, 234 deletions
diff --git a/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp b/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp new file mode 100644 index 0000000000..8856645e89 --- /dev/null +++ b/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp | |||
@@ -0,0 +1,36 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2020 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 | // Stubs for PlayerBuildInfo unit test. | ||
22 | |||
23 | #include "rbsettings.h" | ||
24 | |||
25 | static QMap<RbSettings::UserSettings, QVariant> stubUserSettings; | ||
26 | |||
27 | void RbSettings::setValue(UserSettings setting, QVariant value) | ||
28 | { | ||
29 | stubUserSettings[setting] = value; | ||
30 | } | ||
31 | |||
32 | QVariant RbSettings::value(UserSettings setting) | ||
33 | { | ||
34 | return stubUserSettings[setting]; | ||
35 | } | ||
36 | |||
diff --git a/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp b/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp deleted file mode 100644 index f0fcaf6613..0000000000 --- a/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2020 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 | // Stubs for ServerInfo unit test. | ||
22 | |||
23 | #include "rbsettings.h" | ||
24 | #include "systeminfo.h" | ||
25 | |||
26 | QVariant SystemInfo::platformValue(SystemInfo::PlatformInfo info, QString platform) | ||
27 | { | ||
28 | switch(info) { | ||
29 | case SystemInfo::Manual: | ||
30 | if (platform == "iriverh120") return "iriverh100"; | ||
31 | if (platform == "ipodmini2g") return "ipodmini1g"; | ||
32 | break; | ||
33 | case SystemInfo::BuildserverModel: | ||
34 | return platform.split('.').at(0); | ||
35 | default: | ||
36 | return QString(); | ||
37 | } | ||
38 | return QString(); | ||
39 | } | ||
40 | |||
41 | QVariant SystemInfo::value(SystemInfo::SystemInfos info, SystemInfo::BuildType type) | ||
42 | { | ||
43 | (void)info; // test is currently only using BuildUrl. | ||
44 | switch(type) { | ||
45 | case SystemInfo::BuildCurrent: | ||
46 | return QString("https://unittest/dev/rockbox-%MODEL%.zip"); | ||
47 | case SystemInfo::BuildDaily: | ||
48 | return QString("https://unittest/daily/rockbox-%MODEL%-%RELVERSION%.zip"); | ||
49 | case SystemInfo::BuildRelease: | ||
50 | return QString("https://unittest/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip"); | ||
51 | case SystemInfo::BuildCandidate: | ||
52 | return QString("https://unittest/rc/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip"); | ||
53 | default: | ||
54 | break; | ||
55 | } | ||
56 | return QString(); | ||
57 | } | ||
58 | |||
59 | QStringList SystemInfo::platforms(SystemInfo::PlatformType type, QString variant) | ||
60 | { | ||
61 | // stub implementation: we have a fixed list of players, and only iaudiox5 | ||
62 | // has variant iaudiox5.v | ||
63 | QStringList result; | ||
64 | result << "iriverh100" << "iriverh120" << "iriverh300" | ||
65 | << "ipodmini2g" << "archosrecorder" << "archosfmrecorder" | ||
66 | << "gigabeatfx" << "iaudiom3" << "sansae200" << "iriverh10"; | ||
67 | switch (type) | ||
68 | { | ||
69 | case SystemInfo::PlatformBaseDisabled: | ||
70 | // return base platforms only, i.e. return iaudiox5 for iaudiox5.v | ||
71 | result << "iaudiox5"; | ||
72 | break; | ||
73 | case SystemInfo::PlatformVariantDisabled: | ||
74 | // return variants for the passed variant | ||
75 | if (variant == "iaudiox5") { | ||
76 | result.clear(); | ||
77 | result << "iaudiox5" << "iaudiox5.v"; | ||
78 | } | ||
79 | else { | ||
80 | result.clear(); | ||
81 | result << variant; | ||
82 | } | ||
83 | break; | ||
84 | case SystemInfo::PlatformAllDisabled: | ||
85 | // return all, both with and without variant. | ||
86 | result << "iaudiox5" << "iaudiox5.v"; | ||
87 | break; | ||
88 | default: | ||
89 | break; | ||
90 | } | ||
91 | return result; | ||
92 | } | ||
93 | |||
94 | |||
95 | QVariant RbSettings::value(UserSettings setting) | ||
96 | { | ||
97 | switch (setting) | ||
98 | { | ||
99 | case RbSettings::CurrentPlatform: | ||
100 | return QString("ipodmini2g"); | ||
101 | default: | ||
102 | return QString(""); | ||
103 | } | ||
104 | } | ||
105 | |||
diff --git a/rbutil/rbutilqt/test/test-playerbuildinfo.cpp b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp new file mode 100644 index 0000000000..fe07ba8348 --- /dev/null +++ b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp | |||
@@ -0,0 +1,237 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2020 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> | ||
22 | #include <QObject> | ||
23 | #include "playerbuildinfo.h" | ||
24 | #include "rbsettings.h" | ||
25 | |||
26 | class TestPlayerBuildInfo : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | |||
30 | private slots: | ||
31 | void testBuildInfo(); | ||
32 | void testBuildInfo_data(); | ||
33 | void testPlayerInfo(); | ||
34 | void testPlayerInfo_data(); | ||
35 | }; | ||
36 | |||
37 | const char* testinfo = | ||
38 | "[release]\n" | ||
39 | "build_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n" | ||
40 | "voice_url=https://buildurl/release/%VERSION%/voice-%TARGET%-%VERSION%.zip\n" | ||
41 | "manual_url=https://buildurl/release/%VERSION%/manual-%TARGET%-%VERSION%.zip\n" | ||
42 | "source_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-src-%VERSION%.zip\n" | ||
43 | "font_url=https://buildurl/release/%VERSION%/fonts-%VERSION%.zip\n" | ||
44 | "archosfmrecorder=3.11.2\n" | ||
45 | "iaudiom3=3.11.2,http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n" | ||
46 | "sansae200 = 3.15\n" | ||
47 | "iriverh100 = 3.11.2, http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n" | ||
48 | "iriverh120 = 3.3\n" | ||
49 | "iriverh300 = \n" | ||
50 | "[release-candidate]\n" | ||
51 | "build_url=https://buildurl/rc/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n" | ||
52 | "gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n" | ||
53 | "archosfmrecorder=f9dce96\n" | ||
54 | "archosrecorder = f9dce96\n" | ||
55 | "iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n" | ||
56 | "[development]\n" | ||
57 | "build_url=https://buildurl/dev/rockbox-%TARGET%.zip\n" | ||
58 | "iriverh100 = be1be79\n" | ||
59 | "iaudiox5 = be1be76\n" | ||
60 | "[dailies]\n" | ||
61 | "timestamp = 20201113\n" | ||
62 | "rev = 362f7a3\n" | ||
63 | "[daily]\n" | ||
64 | "build_url=https://buildurl/daily/rockbox-%TARGET%-%VERSION%.zip\n" | ||
65 | "iriverh100 = f9dce00\n" | ||
66 | "[bleeding]\n" | ||
67 | "timestamp = 20201114T105723Z\n" | ||
68 | "rev = be1be79\n" | ||
69 | "[status]\n" | ||
70 | "archosfmrecorder=3\n" | ||
71 | "iriverh100=2\n" | ||
72 | "iriverh300=1\n" | ||
73 | "iriverh10=0\n" | ||
74 | "[voices]\n" | ||
75 | "3.15=english,francais\n" | ||
76 | "3.11.2=english\n" | ||
77 | "daily=deutsch,english,francais\n" | ||
78 | ; | ||
79 | |||
80 | Q_DECLARE_METATYPE(PlayerBuildInfo::BuildInfo); | ||
81 | Q_DECLARE_METATYPE(PlayerBuildInfo::BuildType); | ||
82 | Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo); | ||
83 | |||
84 | struct { | ||
85 | QString target; | ||
86 | PlayerBuildInfo::BuildInfo item; | ||
87 | PlayerBuildInfo::BuildType type; | ||
88 | QString expected; | ||
89 | } testdataBuild[] = | ||
90 | { | ||
91 | // release builds | ||
92 | { "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeRelease, "english" }, | ||
93 | { "iriverh300", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" }, | ||
94 | { "iriverh300", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" }, | ||
95 | { "iriverh10", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" }, | ||
96 | { "iriverh10", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" }, | ||
97 | { "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" }, | ||
98 | { "iaudiom3", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" }, | ||
99 | { "iaudiom3", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" }, | ||
100 | { "sansae200", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.15" }, | ||
101 | { "sansae200", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.15/rockbox-sansae200-3.15.zip" }, | ||
102 | { "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" }, | ||
103 | { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" }, | ||
104 | { "iriverh100", PlayerBuildInfo::BuildVoiceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/voice-iriverh100-3.11.2.zip" }, | ||
105 | { "iriverh100", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/manual-iriverh100-3.11.2.zip" }, | ||
106 | { "iriverh100", PlayerBuildInfo::BuildSourceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/rockbox-iriverh100-src-3.11.2.zip" }, | ||
107 | // h120 uses the same manual as h100. | ||
108 | { "iriverh120", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.3/manual-iriverh100-3.3.zip" }, | ||
109 | { "iriverh100", PlayerBuildInfo::BuildFontUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/fonts-3.11.2.zip" }, | ||
110 | |||
111 | // rc builds | ||
112 | { "gigabeatfx", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" }, | ||
113 | { "gigabeatfx", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" }, | ||
114 | { "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" }, | ||
115 | { "archosfmrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" }, | ||
116 | { "archosrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" }, | ||
117 | { "archosrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" }, | ||
118 | { "iaudiox5", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" }, | ||
119 | { "iaudiox5", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" }, | ||
120 | { "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" }, | ||
121 | { "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" }, | ||
122 | |||
123 | // devel builds | ||
124 | { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iriverh100.zip" }, | ||
125 | { "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDevel, "be1be76" }, | ||
126 | { "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iaudiox5.zip" }, | ||
127 | |||
128 | // daily builds | ||
129 | { "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeDaily, "deutsch,english,francais" }, | ||
130 | { "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDaily, "f9dce00" }, | ||
131 | { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDaily, "https://buildurl/daily/rockbox-iriverh100-f9dce00.zip" }, | ||
132 | }; | ||
133 | |||
134 | struct { | ||
135 | QString target; | ||
136 | PlayerBuildInfo::DeviceInfo item; | ||
137 | QString expected; | ||
138 | } testdataPlayer[] = | ||
139 | { | ||
140 | {"archosfmrecorder", PlayerBuildInfo::BuildStatus, "3"}, | ||
141 | { "iriverh10", PlayerBuildInfo::BuildStatus, "0" }, | ||
142 | { "iriverh100", PlayerBuildInfo::BuildStatus, "2" }, | ||
143 | { "iriverh300", PlayerBuildInfo::BuildStatus, "1" }, | ||
144 | { "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" }, | ||
145 | {"archosfmrecorder", PlayerBuildInfo::DisplayName, "Jukebox Recorder FM"}, | ||
146 | {"archosfmrecorder", PlayerBuildInfo::BootloaderMethod, "none"}, | ||
147 | {"archosfmrecorder", PlayerBuildInfo::BootloaderName, ""}, | ||
148 | {"archosfmrecorder", PlayerBuildInfo::BootloaderFile, ""}, | ||
149 | {"archosfmrecorder", PlayerBuildInfo::BootloaderFilter, ""}, | ||
150 | {"archosfmrecorder", PlayerBuildInfo::Encoder, "lame"}, | ||
151 | {"archosfmrecorder", PlayerBuildInfo::Brand, "Archos"}, | ||
152 | {"archosfmrecorder", PlayerBuildInfo::PlayerPicture, "archosfmrecorder"}, | ||
153 | {"iriverh100", PlayerBuildInfo::BuildStatus, "2"}, | ||
154 | {"iriverh100", PlayerBuildInfo::BootloaderMethod, "hex"}, | ||
155 | {"iriverh100", PlayerBuildInfo::BootloaderFilter, "*.hex *.zip"}, | ||
156 | {"ipodmini2g", PlayerBuildInfo::Encoder, "rbspeex"}, | ||
157 | }; | ||
158 | |||
159 | void TestPlayerBuildInfo::testBuildInfo_data() | ||
160 | { | ||
161 | QTest::addColumn<QString>("target"); | ||
162 | QTest::addColumn<PlayerBuildInfo::BuildInfo>("item"); | ||
163 | QTest::addColumn<PlayerBuildInfo::BuildType>("type"); | ||
164 | QTest::addColumn<QString>("expected"); | ||
165 | for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++) | ||
166 | QTest::newRow("") << testdataBuild[i].target << testdataBuild[i].item | ||
167 | << testdataBuild[i].type << testdataBuild[i].expected; | ||
168 | } | ||
169 | |||
170 | |||
171 | void TestPlayerBuildInfo::testBuildInfo() | ||
172 | { | ||
173 | // create a temporary file for test input. Do not use QSettings() to allow | ||
174 | // creating different format variations. | ||
175 | QTemporaryFile tf(this); | ||
176 | tf.open(); | ||
177 | QString filename = tf.fileName(); | ||
178 | tf.write(testinfo); | ||
179 | tf.close(); | ||
180 | |||
181 | PlayerBuildInfo::instance()->setBuildInfo(filename); | ||
182 | |||
183 | QFETCH(QString, target); | ||
184 | QFETCH(PlayerBuildInfo::BuildInfo, item); | ||
185 | QFETCH(PlayerBuildInfo::BuildType, type); | ||
186 | QFETCH(QString, expected); | ||
187 | |||
188 | RbSettings::setValue(RbSettings::CurrentPlatform, target); | ||
189 | QVariant result = PlayerBuildInfo::instance()->value(item, type); | ||
190 | if(result.canConvert(QMetaType::QString)) | ||
191 | QCOMPARE(result.toString(), QString(expected)); | ||
192 | else | ||
193 | QCOMPARE(result.toStringList().join(","), QString(expected)); | ||
194 | } | ||
195 | |||
196 | |||
197 | // NOTE: These tests rely on rbutil.ini | ||
198 | void TestPlayerBuildInfo::testPlayerInfo_data() | ||
199 | { | ||
200 | QTest::addColumn<QString>("target"); | ||
201 | QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item"); | ||
202 | QTest::addColumn<QString>("expected"); | ||
203 | for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++) | ||
204 | QTest::newRow("") << testdataPlayer[i].target << testdataPlayer[i].item | ||
205 | << testdataPlayer[i].expected; | ||
206 | } | ||
207 | |||
208 | void TestPlayerBuildInfo::testPlayerInfo() | ||
209 | { | ||
210 | // create a temporary file for test input. Do not use QSettings() to allow | ||
211 | // creating different format variations. | ||
212 | QTemporaryFile tf(this); | ||
213 | tf.open(); | ||
214 | QString filename = tf.fileName(); | ||
215 | tf.write(testinfo); | ||
216 | tf.close(); | ||
217 | |||
218 | PlayerBuildInfo::instance()->setBuildInfo(filename); | ||
219 | |||
220 | QFETCH(QString, target); | ||
221 | QFETCH(PlayerBuildInfo::DeviceInfo, item); | ||
222 | QFETCH(QString, expected); | ||
223 | |||
224 | QVariant result = PlayerBuildInfo::instance()->value(item, target); | ||
225 | if(result.canConvert(QMetaType::QString)) | ||
226 | QCOMPARE(result.toString(), QString(expected)); | ||
227 | else | ||
228 | QCOMPARE(result.toStringList().join(","), QString(expected)); | ||
229 | } | ||
230 | |||
231 | |||
232 | QTEST_MAIN(TestPlayerBuildInfo) | ||
233 | |||
234 | // this include is needed because we don't use a separate header file for the | ||
235 | // test class. It also needs to be at the end. | ||
236 | #include "test-playerbuildinfo.moc" | ||
237 | |||
diff --git a/rbutil/rbutilqt/test/test-serverinfo.pro b/rbutil/rbutilqt/test/test-playerbuildinfo.pro index 903d5a6b07..724da59162 100644 --- a/rbutil/rbutilqt/test/test-serverinfo.pro +++ b/rbutil/rbutilqt/test/test-playerbuildinfo.pro | |||
@@ -18,19 +18,18 @@ | |||
18 | QT += testlib | 18 | QT += testlib |
19 | 19 | ||
20 | TEMPLATE = app | 20 | TEMPLATE = app |
21 | TARGET = test-serverinfo | 21 | TARGET = test-playerbuildinfo |
22 | INCLUDEPATH += . ../base stubs | 22 | INCLUDEPATH += . ../base stubs |
23 | 23 | ||
24 | # Input | 24 | # Input |
25 | SOURCES += \ | 25 | SOURCES += \ |
26 | test-serverinfo.cpp \ | 26 | test-playerbuildinfo.cpp \ |
27 | stubs/stubs-serverinfo.cpp \ | 27 | stubs/stubs-playerbuildinfo.cpp \ |
28 | ../base/serverinfo.cpp | 28 | ../base/playerbuildinfo.cpp |
29 | 29 | ||
30 | HEADERS += \ | 30 | HEADERS += \ |
31 | ../base/rbsettings.h \ | 31 | ../base/rbsettings.h \ |
32 | ../base/rockboxinfo.h \ | 32 | ../base/rockboxinfo.h \ |
33 | ../base/systeminfo.h \ | 33 | ../base/systeminfo.h \ |
34 | ../base/serverinfo.h \ | ||
35 | 34 | ||
36 | RESOURCES += ../rbutilqt.qrc | 35 | RESOURCES += ../rbutilqt.qrc |
diff --git a/rbutil/rbutilqt/test/test-serverinfo.cpp b/rbutil/rbutilqt/test/test-serverinfo.cpp deleted file mode 100644 index b999624c78..0000000000 --- a/rbutil/rbutilqt/test/test-serverinfo.cpp +++ /dev/null | |||
@@ -1,124 +0,0 @@ | |||
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 | |||
25 | class TestServerInfo : public QObject | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | private slots: | ||
29 | void testMain(); | ||
30 | }; | ||
31 | |||
32 | const char* testinfo = | ||
33 | "[release]\n" | ||
34 | "archosfmrecorder=3.11.2\n" | ||
35 | "iaudiom3=3.11.2,http://dl.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://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n" | ||
38 | "iriverh300 = \n" | ||
39 | "[release-candidate]\n" | ||
40 | "gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n" | ||
41 | "archosfmrecorder=f9dce96\n" | ||
42 | "archosrecorder = f9dce96\n" | ||
43 | "iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n" | ||
44 | "[dailies]\n" | ||
45 | "timestamp = 20201113\n" | ||
46 | "rev = 362f7a3\n" | ||
47 | "[bleeding]\n" | ||
48 | "timestamp = 20201114T105723Z\n" | ||
49 | "rev = be1be79\n" | ||
50 | "[status]\n" | ||
51 | "archosfmrecorder=3\n" | ||
52 | "iriverh100=2\n" | ||
53 | "iriverh300=1\n" | ||
54 | "iriverh10=0\n" | ||
55 | ; | ||
56 | |||
57 | |||
58 | struct testvector { | ||
59 | const char* target; | ||
60 | ServerInfo::ServerInfos entry; | ||
61 | const char* expected; | ||
62 | }; | ||
63 | |||
64 | |||
65 | const struct testvector testdata[] = | ||
66 | { | ||
67 | { "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" }, | ||
68 | { "archosfmrecorder", ServerInfo::CurStatus, "3" }, | ||
69 | { "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" }, | ||
70 | { "iaudiom3", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" }, | ||
71 | { "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" }, | ||
72 | { "sansae200", ServerInfo::CurReleaseUrl, "https://unittest/release/3.11.2/rockbox-sansae200-3.11.2.zip" }, | ||
73 | { "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" }, | ||
74 | { "iriverh100", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" }, | ||
75 | { "iriverh100", ServerInfo::CurStatus, "2" }, | ||
76 | { "iriverh100", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iriverh100.zip" }, | ||
77 | { "iriverh300", ServerInfo::CurReleaseVersion, "" }, | ||
78 | { "iriverh300", ServerInfo::CurReleaseUrl, "" }, | ||
79 | { "iriverh300", ServerInfo::CurStatus, "1" }, | ||
80 | { "iriverh10", ServerInfo::CurReleaseVersion, "" }, | ||
81 | { "iriverh10", ServerInfo::CurReleaseUrl, "" }, | ||
82 | { "iriverh10", ServerInfo::CurStatus, "0" }, | ||
83 | { "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" }, | ||
84 | { "gigabeatfx", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" }, | ||
85 | { "archosfmrecorder", ServerInfo::RelCandidateVersion, "f9dce96" }, | ||
86 | { "archosfmrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" }, | ||
87 | { "archosrecorder", ServerInfo::RelCandidateVersion, "f9dce96" }, | ||
88 | { "archosrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" }, | ||
89 | { "iaudiox5", ServerInfo::RelCandidateVersion, "f9dce96" }, | ||
90 | { "iaudiox5", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" }, | ||
91 | { "iaudiox5.v", ServerInfo::RelCandidateVersion, "f9dce96" }, | ||
92 | { "iaudiox5.v", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" }, | ||
93 | { "iaudiox5.v", ServerInfo::BleedingRevision, "be1be79" }, | ||
94 | { "iaudiox5.v", ServerInfo::BleedingDate, "2020-11-14T10:57:23" }, | ||
95 | { "iaudiox5.v", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iaudiox5.zip" }, | ||
96 | }; | ||
97 | |||
98 | |||
99 | void TestServerInfo::testMain() | ||
100 | { | ||
101 | // create a temporary file for test input. Do not use QSettings() to allow | ||
102 | // creating different format variations. | ||
103 | QTemporaryFile tf(this); | ||
104 | tf.open(); | ||
105 | QString filename = tf.fileName(); | ||
106 | tf.write(testinfo); | ||
107 | tf.close(); | ||
108 | |||
109 | ServerInfo::instance()->readBuildInfo(filename); | ||
110 | |||
111 | unsigned int i; | ||
112 | for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) { | ||
113 | QString result = ServerInfo::instance()->platformValue(testdata[i].entry, testdata[i].target).toString(); | ||
114 | QCOMPARE(result, QString(testdata[i].expected)); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | |||
119 | QTEST_MAIN(TestServerInfo) | ||
120 | |||
121 | // this include is needed because we don't use a separate header file for the | ||
122 | // test class. It also needs to be at the end. | ||
123 | #include "test-serverinfo.moc" | ||
124 | |||