diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-11-28 20:47:28 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-03 22:25:12 +0100 |
commit | b064a6cbb58a0db1a70fbac2e82242ce0c7509b1 (patch) | |
tree | c9090d367d237cbd408afbd24d5809e55a1a2653 /rbutil/rbutilqt/test/test-serverinfo.cpp | |
parent | 78a01db47cac5fa67aeee6f1c5134f89c3e4944a (diff) | |
download | rockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.tar.gz rockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.zip |
rbutil: Rework and merge player and build server info handling.
Handling the data for players from rbutil.ini and the build-info data
from the server is closely related. Splitting things up into different
classes only creates tightly coupling, which is unnecessary, and the
need to differentiate between them in the application.
Merge both classes into a single one and rework handling so the
application doesn't have to deal with two separate classes anymore.
Furthermore, change URL templates to use new values from build-info
instead of hard coding them.
Change-Id: Ica550973ce23d1559110782add52bc214eba552d
Diffstat (limited to 'rbutil/rbutilqt/test/test-serverinfo.cpp')
-rw-r--r-- | rbutil/rbutilqt/test/test-serverinfo.cpp | 124 |
1 files changed, 0 insertions, 124 deletions
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 | |||