summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
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 /rbutil/rbutilqt
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
Diffstat (limited to 'rbutil/rbutilqt')
-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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2012 Dominik Riebeling
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QObject>
+#include "rockboxinfo.h"
+
+
+class TestRockboxInfo : public QObject
+{
+ Q_OBJECT
+ private slots:
+ void testVersion();
+ void testMemory();
+ void testTarget();
+ void testFeatures();
+};
+
+
+void TestRockboxInfo::testVersion()
+{
+ struct testvector {
+ const char* versionline;
+ const char* revisionstring;
+ const char* versionstring;
+ const char* releasestring;
+ };
+
+ const struct testvector testdata[] =
+ {
+ { "Version: r29629-110321", "29629", "r29629-110321", "" },
+ { "Version: r29629M-110321", "29629M", "r29629M-110321", "" },
+ { "Version: 3.10", "", "3.10", "3.10" },
+ { "Version:\t3.10", "", "3.10", "3.10" },
+ };
+
+
+ unsigned int i;
+ for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(testdata[i].versionline);
+ tf.write("\n");
+ tf.close();
+
+ RockboxInfo info("", filename);
+ QCOMPARE(info.version(), QString(testdata[i].versionstring));
+ QCOMPARE(info.revision(), QString(testdata[i].revisionstring));
+ }
+}
+
+
+void TestRockboxInfo::testTarget()
+{
+ unsigned int i, j;
+ QStringList targets;
+ targets << "sansae200" << "gigabeats" << "iriverh100" << "unknown";
+ QStringList prefix;
+ prefix << "Target: "; // << "Target:\t" << "Target: ";
+ for(j = 0; j < prefix.size(); ++j) {
+ for(i = 0; i < targets.size(); i++) {
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(prefix.at(j).toLocal8Bit());
+ tf.write(targets.at(i).toLocal8Bit());
+ tf.write("\n");
+ tf.close();
+
+ RockboxInfo info("", filename);
+ QCOMPARE(info.target(), targets.at(i));
+ }
+ }
+}
+
+
+void TestRockboxInfo::testMemory()
+{
+ unsigned int i, j;
+ QStringList memsizes;
+ memsizes << "8" << "16" << "32" << "64";
+ QStringList prefix;
+ prefix << "Memory: " << "Memory:\t" << "Memory: ";
+ for(j = 0; j < prefix.size(); ++j) {
+ for(i = 0; i < memsizes.size(); i++) {
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(prefix.at(j).toLocal8Bit());
+ tf.write(memsizes.at(i).toLocal8Bit());
+ tf.write("\n");
+ tf.close();
+
+ RockboxInfo info("", filename);
+ QCOMPARE(info.ram(), memsizes.at(i).toInt());
+ }
+ }
+}
+
+
+void TestRockboxInfo::testFeatures()
+{
+ unsigned int i, j;
+ QStringList features;
+ features << "backlight_brightness:button_light:dircache:flash_storage"
+ << "pitchscreen:multivolume:multidrive_usb:quickscreen";
+ QStringList prefix;
+ prefix << "Features: " << "Features:\t" << "Features: ";
+ for(j = 0; j < prefix.size(); ++j) {
+ for(i = 0; i < features.size(); i++) {
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(prefix.at(j).toLocal8Bit());
+ tf.write(features.at(i).toLocal8Bit());
+ tf.write("\n");
+ tf.close();
+
+ RockboxInfo info("", filename);
+ QCOMPARE(info.features(), features.at(i));
+ }
+ }
+}
+
+QTEST_MAIN(TestRockboxInfo)
+
+// this include is needed because we don't use a separate header file for the
+// test class. It also needs to be at the end.
+#include "test-rockboxinfo.moc"
+
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 @@
+#
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+#
+# All files in this archive are subject to the GNU General Public License.
+# See the file COPYING in the source tree root for full license agreement.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+
+#
+include(tests.pri)
+
+TEMPLATE = app
+TARGET = test-rockboxinfo
+INCLUDEPATH += . ../base
+
+# Input
+SOURCES += \
+ test-rockboxinfo.cpp \
+ ../base/rockboxinfo.cpp
+
+HEADERS += \
+ ../base/rockboxinfo.h
+