1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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>
23 #include "rockboxinfo.h"
26 class TestRockboxInfo
: public QObject
37 void TestRockboxInfo::testVersion()
40 const char* versionline
;
41 const char* revisionstring
;
42 const char* versionstring
;
43 const char* releasestring
;
46 const struct testvector testdata
[] =
48 /* Input string revision full version release version */
49 { "Version: r29629-110321", "29629", "r29629-110321", "" },
50 { "Version: r29629M-110321", "29629M", "r29629M-110321", "" },
51 { "Version: 3.10", "", "3.10", "3.10" },
52 { "Version:\t3.10", "", "3.10", "3.10" },
53 { "#Version: r29629-110321", "", "", "" },
54 { "Version: e5b1b0f-120218", "e5b1b0f", "e5b1b0f-120218", "" },
55 { "Version: e5b1b0fM-120218", "e5b1b0fM", "e5b1b0fM-120218", "" },
56 { "#Version: e5b1b0f-120218", "", "", "" },
57 { "Version: 3448f5b-120310", "3448f5b", "3448f5b-120310", "" },
62 for(i
= 0; i
< sizeof(testdata
) / sizeof(struct testvector
); i
++) {
63 QTemporaryFile
tf(this);
65 QString filename
= tf
.fileName();
66 tf
.write(testdata
[i
].versionline
);
70 RockboxInfo
info("", filename
);
71 QCOMPARE(info
.version(), QString(testdata
[i
].versionstring
));
72 QCOMPARE(info
.revision(), QString(testdata
[i
].revisionstring
));
73 QCOMPARE(info
.release(), QString(testdata
[i
].releasestring
));
78 void TestRockboxInfo::testTarget()
82 targets
<< "sansae200" << "gigabeats" << "iriverh100" << "unknown";
84 prefix
<< "Target: "; // << "Target:\t" << "Target: ";
85 for(j
= 0; j
< prefix
.size(); ++j
) {
86 for(i
= 0; i
< targets
.size(); i
++) {
87 QTemporaryFile
tf(this);
89 QString filename
= tf
.fileName();
90 tf
.write(prefix
.at(j
).toLocal8Bit());
91 tf
.write(targets
.at(i
).toLocal8Bit());
95 RockboxInfo
info("", filename
);
96 QCOMPARE(info
.target(), targets
.at(i
));
102 void TestRockboxInfo::testMemory()
105 QStringList memsizes
;
106 memsizes
<< "8" << "16" << "32" << "64";
108 prefix
<< "Memory: " << "Memory:\t" << "Memory: ";
109 for(j
= 0; j
< prefix
.size(); ++j
) {
110 for(i
= 0; i
< memsizes
.size(); i
++) {
111 QTemporaryFile
tf(this);
113 QString filename
= tf
.fileName();
114 tf
.write(prefix
.at(j
).toLocal8Bit());
115 tf
.write(memsizes
.at(i
).toLocal8Bit());
119 RockboxInfo
info("", filename
);
120 QCOMPARE(info
.ram(), memsizes
.at(i
).toInt());
126 void TestRockboxInfo::testFeatures()
129 QStringList features
;
130 features
<< "backlight_brightness:button_light:dircache:flash_storage"
131 << "pitchscreen:multivolume:multidrive_usb:quickscreen";
133 prefix
<< "Features: " << "Features:\t" << "Features: ";
134 for(j
= 0; j
< prefix
.size(); ++j
) {
135 for(i
= 0; i
< features
.size(); i
++) {
136 QTemporaryFile
tf(this);
138 QString filename
= tf
.fileName();
139 tf
.write(prefix
.at(j
).toLocal8Bit());
140 tf
.write(features
.at(i
).toLocal8Bit());
144 RockboxInfo
info("", filename
);
145 QCOMPARE(info
.features(), features
.at(i
));
150 QTEST_MAIN(TestRockboxInfo
)
152 // this include is needed because we don't use a separate header file for the
153 // test class. It also needs to be at the end.
154 #include "test-rockboxinfo.moc"