summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-02-19 14:09:38 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-02-19 14:12:22 +0100
commit2dbb17d0d6230194b3373c9e61bb70cacd29a972 (patch)
tree1196dfca729e1ba902c4bbcdbcc6e890f4c6ffe7
parent557451a183940eb7ccf1147e0ace449a2a1bcc03 (diff)
downloadrockbox-2dbb17d0d6230194b3373c9e61bb70cacd29a972.tar.gz
rockbox-2dbb17d0d6230194b3373c9e61bb70cacd29a972.zip
Initial unit test of RockboxInfo class.
This tests the original (svn revision number based) functionality. Change-Id: I69a121d751d2358c1e7594032f8f8193af59e103
-rwxr-xr-xrbutil/rbutilqt/test/test-rockboxinfobin0 -> 568151 bytes
-rw-r--r--rbutil/rbutilqt/test/test-rockboxinfo.cpp148
-rw-r--r--rbutil/rbutilqt/test/test-rockboxinfo.pro30
3 files changed, 178 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/test/test-rockboxinfo b/rbutil/rbutilqt/test/test-rockboxinfo
new file mode 100755
index 0000000000..f881e68015
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-rockboxinfo
Binary files differ
diff --git a/rbutil/rbutilqt/test/test-rockboxinfo.cpp b/rbutil/rbutilqt/test/test-rockboxinfo.cpp
new file mode 100644
index 0000000000..541d1c18ee
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-rockboxinfo.cpp
@@ -0,0 +1,148 @@
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
26class TestRockboxInfo : public QObject
27{
28 Q_OBJECT
29 private slots:
30 void testVersion();
31 void testMemory();
32 void testTarget();
33 void testFeatures();
34};
35
36
37void TestRockboxInfo::testVersion()
38{
39 struct testvector {
40 const char* versionline;
41 const char* revisionstring;
42 const char* versionstring;
43 const char* releasestring;
44 };
45
46 const struct testvector testdata[] =
47 {
48 { "Version: r29629-110321", "29629", "r29629-110321", "" },
49 { "Version: r29629M-110321", "29629M", "r29629M-110321", "" },
50 { "Version: 3.10", "", "3.10", "3.10" },
51 { "Version:\t3.10", "", "3.10", "3.10" },
52 };
53
54
55 unsigned int i;
56 for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
57 QTemporaryFile tf(this);
58 tf.open();
59 QString filename = tf.fileName();
60 tf.write(testdata[i].versionline);
61 tf.write("\n");
62 tf.close();
63
64 RockboxInfo info("", filename);
65 QCOMPARE(info.version(), QString(testdata[i].versionstring));
66 QCOMPARE(info.revision(), QString(testdata[i].revisionstring));
67 }
68}
69
70
71void TestRockboxInfo::testTarget()
72{
73 unsigned int i, j;
74 QStringList targets;
75 targets << "sansae200" << "gigabeats" << "iriverh100" << "unknown";
76 QStringList prefix;
77 prefix << "Target: "; // << "Target:\t" << "Target: ";
78 for(j = 0; j < prefix.size(); ++j) {
79 for(i = 0; i < targets.size(); i++) {
80 QTemporaryFile tf(this);
81 tf.open();
82 QString filename = tf.fileName();
83 tf.write(prefix.at(j).toLocal8Bit());
84 tf.write(targets.at(i).toLocal8Bit());
85 tf.write("\n");
86 tf.close();
87
88 RockboxInfo info("", filename);
89 QCOMPARE(info.target(), targets.at(i));
90 }
91 }
92}
93
94
95void TestRockboxInfo::testMemory()
96{
97 unsigned int i, j;
98 QStringList memsizes;
99 memsizes << "8" << "16" << "32" << "64";
100 QStringList prefix;
101 prefix << "Memory: " << "Memory:\t" << "Memory: ";
102 for(j = 0; j < prefix.size(); ++j) {
103 for(i = 0; i < memsizes.size(); i++) {
104 QTemporaryFile tf(this);
105 tf.open();
106 QString filename = tf.fileName();
107 tf.write(prefix.at(j).toLocal8Bit());
108 tf.write(memsizes.at(i).toLocal8Bit());
109 tf.write("\n");
110 tf.close();
111
112 RockboxInfo info("", filename);
113 QCOMPARE(info.ram(), memsizes.at(i).toInt());
114 }
115 }
116}
117
118
119void TestRockboxInfo::testFeatures()
120{
121 unsigned int i, j;
122 QStringList features;
123 features << "backlight_brightness:button_light:dircache:flash_storage"
124 << "pitchscreen:multivolume:multidrive_usb:quickscreen";
125 QStringList prefix;
126 prefix << "Features: " << "Features:\t" << "Features: ";
127 for(j = 0; j < prefix.size(); ++j) {
128 for(i = 0; i < features.size(); i++) {
129 QTemporaryFile tf(this);
130 tf.open();
131 QString filename = tf.fileName();
132 tf.write(prefix.at(j).toLocal8Bit());
133 tf.write(features.at(i).toLocal8Bit());
134 tf.write("\n");
135 tf.close();
136
137 RockboxInfo info("", filename);
138 QCOMPARE(info.features(), features.at(i));
139 }
140 }
141}
142
143QTEST_MAIN(TestRockboxInfo)
144
145// this include is needed because we don't use a separate header file for the
146// test class. It also needs to be at the end.
147#include "test-rockboxinfo.moc"
148
diff --git a/rbutil/rbutilqt/test/test-rockboxinfo.pro b/rbutil/rbutilqt/test/test-rockboxinfo.pro
new file mode 100644
index 0000000000..896669cefe
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-rockboxinfo.pro
@@ -0,0 +1,30 @@
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-rockboxinfo
21INCLUDEPATH += . ../base
22
23# Input
24SOURCES += \
25 test-rockboxinfo.cpp \
26 ../base/rockboxinfo.cpp
27
28HEADERS += \
29 ../base/rockboxinfo.h
30