diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-15 21:04:28 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2021-12-24 18:05:53 +0100 |
commit | c876d3bbefe0dc00c27ca0c12d29da5874946962 (patch) | |
tree | 69f468a185a369b01998314bc3ecc19b70f4fcaa /utils/rbutilqt/test/test-rockboxinfo.cpp | |
parent | 6c6f0757d7a902feb293be165d1490c42bc8e7ad (diff) | |
download | rockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.tar.gz rockbox-c876d3bbefe0dc00c27ca0c12d29da5874946962.zip |
rbutil: Merge rbutil with utils folder.
rbutil uses several components from the utils folder, and can be
considered part of utils too. Having it in a separate folder is an
arbitrary split that doesn't help anymore these days, so merge them.
This also allows other utils to easily use libtools.make without the
need to navigate to a different folder.
Change-Id: I3fc2f4de19e3e776553efb5dea5f779dfec0dc21
Diffstat (limited to 'utils/rbutilqt/test/test-rockboxinfo.cpp')
-rw-r--r-- | utils/rbutilqt/test/test-rockboxinfo.cpp | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/utils/rbutilqt/test/test-rockboxinfo.cpp b/utils/rbutilqt/test/test-rockboxinfo.cpp new file mode 100644 index 0000000000..9d2b53b3ab --- /dev/null +++ b/utils/rbutilqt/test/test-rockboxinfo.cpp | |||
@@ -0,0 +1,187 @@ | |||
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 "rockboxinfo.h" | ||
24 | |||
25 | |||
26 | class TestRockboxInfo : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | private slots: | ||
30 | void testVersion(); | ||
31 | void testVersion_data(); | ||
32 | void testMemory(); | ||
33 | void testMemory_data(); | ||
34 | void testTarget(); | ||
35 | void testTarget_data(); | ||
36 | void testFeatures(); | ||
37 | void testFeatures_data(); | ||
38 | }; | ||
39 | |||
40 | |||
41 | void TestRockboxInfo::testVersion_data() | ||
42 | { | ||
43 | struct { | ||
44 | const char* input; | ||
45 | const char* revision; | ||
46 | const char* version; | ||
47 | const char* release; | ||
48 | } const testdata[] = | ||
49 | { | ||
50 | /* Input string revision full version release version */ | ||
51 | { "Version: r29629-110321", "29629", "r29629-110321", "" }, | ||
52 | { "Version: r29629M-110321", "29629M", "r29629M-110321", "" }, | ||
53 | { "Version: 3.10", "", "3.10", "3.10" }, | ||
54 | { "Version:\t3.10", "", "3.10", "3.10" }, | ||
55 | { "#Version: r29629-110321", "", "", "" }, | ||
56 | { "Version: e5b1b0f-120218", "e5b1b0f", "e5b1b0f-120218", "" }, | ||
57 | { "Version: e5b1b0fM-120218", "e5b1b0fM", "e5b1b0fM-120218", "" }, | ||
58 | { "#Version: e5b1b0f-120218", "", "", "" }, | ||
59 | { "Version: 3448f5b-120310", "3448f5b", "3448f5b-120310", "" }, | ||
60 | }; | ||
61 | |||
62 | |||
63 | QTest::addColumn<QString>("input"); | ||
64 | QTest::addColumn<QString>("revision"); | ||
65 | QTest::addColumn<QString>("version"); | ||
66 | QTest::addColumn<QString>("release"); | ||
67 | unsigned int i; | ||
68 | for(i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) { | ||
69 | for (size_t i = 0; i < sizeof(testdata) / sizeof(testdata[0]); i++) { | ||
70 | QTest::newRow(testdata[i].input) | ||
71 | << testdata[i].input << testdata[i].revision | ||
72 | << testdata[i].version << testdata[i].release; | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | |||
78 | void TestRockboxInfo::testVersion() | ||
79 | { | ||
80 | QFETCH(QString, input); | ||
81 | QFETCH(QString, revision); | ||
82 | QFETCH(QString, version); | ||
83 | QFETCH(QString, release); | ||
84 | QTemporaryFile tf(this); | ||
85 | tf.open(); | ||
86 | QString filename = tf.fileName(); | ||
87 | tf.write(input.toLatin1()); | ||
88 | tf.write("\n"); | ||
89 | tf.close(); | ||
90 | |||
91 | RockboxInfo info("", filename); | ||
92 | QCOMPARE(info.version(), QString(version)); | ||
93 | QCOMPARE(info.revision(), QString(revision)); | ||
94 | QCOMPARE(info.release(), QString(release)); | ||
95 | } | ||
96 | |||
97 | void TestRockboxInfo::testTarget_data() | ||
98 | { | ||
99 | QTest::addColumn<QString>("target"); | ||
100 | QTest::newRow("sansae200") << "sansae200"; | ||
101 | QTest::newRow("gigabeats") << "gigabeats"; | ||
102 | QTest::newRow("iriverh100") << "iriverh100"; | ||
103 | QTest::newRow("unknown") << "unknown"; | ||
104 | } | ||
105 | |||
106 | void TestRockboxInfo::testTarget() | ||
107 | { | ||
108 | int j; | ||
109 | QStringList prefix; | ||
110 | prefix << "Target: "; // << "Target:\t" << "Target: "; | ||
111 | for(j = 0; j < prefix.size(); ++j) { | ||
112 | QFETCH(QString, target); | ||
113 | QTemporaryFile tf(this); | ||
114 | tf.open(); | ||
115 | QString filename = tf.fileName(); | ||
116 | tf.write(prefix.at(j).toLatin1()); | ||
117 | tf.write(target.toLatin1()); | ||
118 | tf.write("\n"); | ||
119 | tf.close(); | ||
120 | |||
121 | RockboxInfo info("", filename); | ||
122 | QCOMPARE(info.target(), target); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | void TestRockboxInfo::testMemory_data() | ||
127 | { | ||
128 | QTest::addColumn<QString>("memory"); | ||
129 | QTest::newRow("8") << "8"; | ||
130 | QTest::newRow("16") << "16"; | ||
131 | QTest::newRow("32") << "32"; | ||
132 | QTest::newRow("64") << "64"; | ||
133 | } | ||
134 | |||
135 | void TestRockboxInfo::testMemory() | ||
136 | { | ||
137 | int j; | ||
138 | QStringList prefix; | ||
139 | prefix << "Memory: " << "Memory:\t" << "Memory: "; | ||
140 | for(j = 0; j < prefix.size(); ++j) { | ||
141 | QFETCH(QString, memory); | ||
142 | QTemporaryFile tf(this); | ||
143 | tf.open(); | ||
144 | QString filename = tf.fileName(); | ||
145 | tf.write(prefix.at(j).toLatin1()); | ||
146 | tf.write(memory.toLatin1()); | ||
147 | tf.write("\n"); | ||
148 | tf.close(); | ||
149 | |||
150 | RockboxInfo info("", filename); | ||
151 | QCOMPARE(info.ram(), memory.toInt()); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void TestRockboxInfo::testFeatures_data() | ||
156 | { | ||
157 | QTest::addColumn<QString>("features"); | ||
158 | QTest::newRow("1") << "backlight_brightness:button_light:dircache:flash_storage"; | ||
159 | QTest::newRow("2") << "pitchscreen:multivolume:multidrive_usb:quickscreen"; | ||
160 | } | ||
161 | |||
162 | void TestRockboxInfo::testFeatures() | ||
163 | { | ||
164 | int j; | ||
165 | QStringList prefix; | ||
166 | prefix << "Features: " << "Features:\t" << "Features: "; | ||
167 | for(j = 0; j < prefix.size(); ++j) { | ||
168 | QFETCH(QString, features); | ||
169 | QTemporaryFile tf(this); | ||
170 | tf.open(); | ||
171 | QString filename = tf.fileName(); | ||
172 | tf.write(prefix.at(j).toLatin1()); | ||
173 | tf.write(features.toLatin1()); | ||
174 | tf.write("\n"); | ||
175 | tf.close(); | ||
176 | |||
177 | RockboxInfo info("", filename); | ||
178 | QCOMPARE(info.features(), features); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | QTEST_MAIN(TestRockboxInfo) | ||
183 | |||
184 | // this include is needed because we don't use a separate header file for the | ||
185 | // test class. It also needs to be at the end. | ||
186 | #include "test-rockboxinfo.moc" | ||
187 | |||