summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/test
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/test')
-rw-r--r--rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp36
-rw-r--r--rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp105
-rw-r--r--rbutil/rbutilqt/test/test-playerbuildinfo.cpp237
-rw-r--r--rbutil/rbutilqt/test/test-playerbuildinfo.pro (renamed from rbutil/rbutilqt/test/test-serverinfo.pro)9
-rw-r--r--rbutil/rbutilqt/test/test-serverinfo.cpp124
5 files changed, 277 insertions, 234 deletions
diff --git a/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp b/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp
new file mode 100644
index 0000000000..8856645e89
--- /dev/null
+++ b/rbutil/rbutilqt/test/stubs/stubs-playerbuildinfo.cpp
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2020 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.
+ *
+ ****************************************************************************/
+
+// Stubs for PlayerBuildInfo unit test.
+
+#include "rbsettings.h"
+
+static QMap<RbSettings::UserSettings, QVariant> stubUserSettings;
+
+void RbSettings::setValue(UserSettings setting, QVariant value)
+{
+ stubUserSettings[setting] = value;
+}
+
+QVariant RbSettings::value(UserSettings setting)
+{
+ return stubUserSettings[setting];
+}
+
diff --git a/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp b/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp
deleted file mode 100644
index f0fcaf6613..0000000000
--- a/rbutil/rbutilqt/test/stubs/stubs-serverinfo.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2020 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.
- *
- ****************************************************************************/
-
-// Stubs for ServerInfo unit test.
-
-#include "rbsettings.h"
-#include "systeminfo.h"
-
-QVariant SystemInfo::platformValue(SystemInfo::PlatformInfo info, QString platform)
-{
- switch(info) {
- case SystemInfo::Manual:
- if (platform == "iriverh120") return "iriverh100";
- if (platform == "ipodmini2g") return "ipodmini1g";
- break;
- case SystemInfo::BuildserverModel:
- return platform.split('.').at(0);
- default:
- return QString();
- }
- return QString();
-}
-
-QVariant SystemInfo::value(SystemInfo::SystemInfos info, SystemInfo::BuildType type)
-{
- (void)info; // test is currently only using BuildUrl.
- switch(type) {
- case SystemInfo::BuildCurrent:
- return QString("https://unittest/dev/rockbox-%MODEL%.zip");
- case SystemInfo::BuildDaily:
- return QString("https://unittest/daily/rockbox-%MODEL%-%RELVERSION%.zip");
- case SystemInfo::BuildRelease:
- return QString("https://unittest/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
- case SystemInfo::BuildCandidate:
- return QString("https://unittest/rc/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
- default:
- break;
- }
- return QString();
-}
-
-QStringList SystemInfo::platforms(SystemInfo::PlatformType type, QString variant)
-{
- // stub implementation: we have a fixed list of players, and only iaudiox5
- // has variant iaudiox5.v
- QStringList result;
- result << "iriverh100" << "iriverh120" << "iriverh300"
- << "ipodmini2g" << "archosrecorder" << "archosfmrecorder"
- << "gigabeatfx" << "iaudiom3" << "sansae200" << "iriverh10";
- switch (type)
- {
- case SystemInfo::PlatformBaseDisabled:
- // return base platforms only, i.e. return iaudiox5 for iaudiox5.v
- result << "iaudiox5";
- break;
- case SystemInfo::PlatformVariantDisabled:
- // return variants for the passed variant
- if (variant == "iaudiox5") {
- result.clear();
- result << "iaudiox5" << "iaudiox5.v";
- }
- else {
- result.clear();
- result << variant;
- }
- break;
- case SystemInfo::PlatformAllDisabled:
- // return all, both with and without variant.
- result << "iaudiox5" << "iaudiox5.v";
- break;
- default:
- break;
- }
- return result;
-}
-
-
-QVariant RbSettings::value(UserSettings setting)
-{
- switch (setting)
- {
- case RbSettings::CurrentPlatform:
- return QString("ipodmini2g");
- default:
- return QString("");
- }
-}
-
diff --git a/rbutil/rbutilqt/test/test-playerbuildinfo.cpp b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp
new file mode 100644
index 0000000000..fe07ba8348
--- /dev/null
+++ b/rbutil/rbutilqt/test/test-playerbuildinfo.cpp
@@ -0,0 +1,237 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2020 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>
+#include <QObject>
+#include "playerbuildinfo.h"
+#include "rbsettings.h"
+
+class TestPlayerBuildInfo : public QObject
+{
+ Q_OBJECT
+
+ private slots:
+ void testBuildInfo();
+ void testBuildInfo_data();
+ void testPlayerInfo();
+ void testPlayerInfo_data();
+};
+
+const char* testinfo =
+ "[release]\n"
+ "build_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n"
+ "voice_url=https://buildurl/release/%VERSION%/voice-%TARGET%-%VERSION%.zip\n"
+ "manual_url=https://buildurl/release/%VERSION%/manual-%TARGET%-%VERSION%.zip\n"
+ "source_url=https://buildurl/release/%VERSION%/rockbox-%TARGET%-src-%VERSION%.zip\n"
+ "font_url=https://buildurl/release/%VERSION%/fonts-%VERSION%.zip\n"
+ "archosfmrecorder=3.11.2\n"
+ "iaudiom3=3.11.2,http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n"
+ "sansae200 = 3.15\n"
+ "iriverh100 = 3.11.2, http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n"
+ "iriverh120 = 3.3\n"
+ "iriverh300 = \n"
+ "[release-candidate]\n"
+ "build_url=https://buildurl/rc/%VERSION%/rockbox-%TARGET%-%VERSION%.zip\n"
+ "gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n"
+ "archosfmrecorder=f9dce96\n"
+ "archosrecorder = f9dce96\n"
+ "iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n"
+ "[development]\n"
+ "build_url=https://buildurl/dev/rockbox-%TARGET%.zip\n"
+ "iriverh100 = be1be79\n"
+ "iaudiox5 = be1be76\n"
+ "[dailies]\n"
+ "timestamp = 20201113\n"
+ "rev = 362f7a3\n"
+ "[daily]\n"
+ "build_url=https://buildurl/daily/rockbox-%TARGET%-%VERSION%.zip\n"
+ "iriverh100 = f9dce00\n"
+ "[bleeding]\n"
+ "timestamp = 20201114T105723Z\n"
+ "rev = be1be79\n"
+ "[status]\n"
+ "archosfmrecorder=3\n"
+ "iriverh100=2\n"
+ "iriverh300=1\n"
+ "iriverh10=0\n"
+ "[voices]\n"
+ "3.15=english,francais\n"
+ "3.11.2=english\n"
+ "daily=deutsch,english,francais\n"
+ ;
+
+Q_DECLARE_METATYPE(PlayerBuildInfo::BuildInfo);
+Q_DECLARE_METATYPE(PlayerBuildInfo::BuildType);
+Q_DECLARE_METATYPE(PlayerBuildInfo::DeviceInfo);
+
+struct {
+ QString target;
+ PlayerBuildInfo::BuildInfo item;
+ PlayerBuildInfo::BuildType type;
+ QString expected;
+} testdataBuild[] =
+{
+ // release builds
+ { "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeRelease, "english" },
+ { "iriverh300", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" },
+ { "iriverh300", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" },
+ { "iriverh10", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "" },
+ { "iriverh10", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "" },
+ { "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
+ { "iaudiom3", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
+ { "iaudiom3", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" },
+ { "sansae200", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.15" },
+ { "sansae200", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.15/rockbox-sansae200-3.15.zip" },
+ { "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeRelease, "3.11.2" },
+ { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeRelease, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" },
+ { "iriverh100", PlayerBuildInfo::BuildVoiceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/voice-iriverh100-3.11.2.zip" },
+ { "iriverh100", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/manual-iriverh100-3.11.2.zip" },
+ { "iriverh100", PlayerBuildInfo::BuildSourceUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/rockbox-iriverh100-src-3.11.2.zip" },
+ // h120 uses the same manual as h100.
+ { "iriverh120", PlayerBuildInfo::BuildManualUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.3/manual-iriverh100-3.3.zip" },
+ { "iriverh100", PlayerBuildInfo::BuildFontUrl, PlayerBuildInfo::TypeRelease, "https://buildurl/release/3.11.2/fonts-3.11.2.zip" },
+
+ // rc builds
+ { "gigabeatfx", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
+ { "gigabeatfx", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" },
+ { "archosfmrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
+ { "archosfmrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" },
+ { "archosrecorder", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
+ { "archosrecorder", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "https://buildurl/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" },
+ { "iaudiox5", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
+ { "iaudiox5", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
+ { "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeCandidate, "f9dce96" },
+ { "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeCandidate, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
+
+ // devel builds
+ { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iriverh100.zip" },
+ { "iaudiox5.v", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDevel, "be1be76" },
+ { "iaudiox5.v", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDevel, "https://buildurl/dev/rockbox-iaudiox5.zip" },
+
+ // daily builds
+ { "iriverh100", PlayerBuildInfo::BuildVoiceLangs, PlayerBuildInfo::TypeDaily, "deutsch,english,francais" },
+ { "iriverh100", PlayerBuildInfo::BuildVersion, PlayerBuildInfo::TypeDaily, "f9dce00" },
+ { "iriverh100", PlayerBuildInfo::BuildUrl, PlayerBuildInfo::TypeDaily, "https://buildurl/daily/rockbox-iriverh100-f9dce00.zip" },
+};
+
+struct {
+ QString target;
+ PlayerBuildInfo::DeviceInfo item;
+ QString expected;
+} testdataPlayer[] =
+{
+ {"archosfmrecorder", PlayerBuildInfo::BuildStatus, "3"},
+ { "iriverh10", PlayerBuildInfo::BuildStatus, "0" },
+ { "iriverh100", PlayerBuildInfo::BuildStatus, "2" },
+ { "iriverh300", PlayerBuildInfo::BuildStatus, "1" },
+ { "archosfmrecorder", PlayerBuildInfo::BuildStatus, "3" },
+ {"archosfmrecorder", PlayerBuildInfo::DisplayName, "Jukebox Recorder FM"},
+ {"archosfmrecorder", PlayerBuildInfo::BootloaderMethod, "none"},
+ {"archosfmrecorder", PlayerBuildInfo::BootloaderName, ""},
+ {"archosfmrecorder", PlayerBuildInfo::BootloaderFile, ""},
+ {"archosfmrecorder", PlayerBuildInfo::BootloaderFilter, ""},
+ {"archosfmrecorder", PlayerBuildInfo::Encoder, "lame"},
+ {"archosfmrecorder", PlayerBuildInfo::Brand, "Archos"},
+ {"archosfmrecorder", PlayerBuildInfo::PlayerPicture, "archosfmrecorder"},
+ {"iriverh100", PlayerBuildInfo::BuildStatus, "2"},
+ {"iriverh100", PlayerBuildInfo::BootloaderMethod, "hex"},
+ {"iriverh100", PlayerBuildInfo::BootloaderFilter, "*.hex *.zip"},
+ {"ipodmini2g", PlayerBuildInfo::Encoder, "rbspeex"},
+};
+
+void TestPlayerBuildInfo::testBuildInfo_data()
+{
+ QTest::addColumn<QString>("target");
+ QTest::addColumn<PlayerBuildInfo::BuildInfo>("item");
+ QTest::addColumn<PlayerBuildInfo::BuildType>("type");
+ QTest::addColumn<QString>("expected");
+ for (size_t i = 0; i < sizeof(testdataBuild) / sizeof(testdataBuild[0]); i++)
+ QTest::newRow("") << testdataBuild[i].target << testdataBuild[i].item
+ << testdataBuild[i].type << testdataBuild[i].expected;
+}
+
+
+void TestPlayerBuildInfo::testBuildInfo()
+{
+ // create a temporary file for test input. Do not use QSettings() to allow
+ // creating different format variations.
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(testinfo);
+ tf.close();
+
+ PlayerBuildInfo::instance()->setBuildInfo(filename);
+
+ QFETCH(QString, target);
+ QFETCH(PlayerBuildInfo::BuildInfo, item);
+ QFETCH(PlayerBuildInfo::BuildType, type);
+ QFETCH(QString, expected);
+
+ RbSettings::setValue(RbSettings::CurrentPlatform, target);
+ QVariant result = PlayerBuildInfo::instance()->value(item, type);
+ if(result.canConvert(QMetaType::QString))
+ QCOMPARE(result.toString(), QString(expected));
+ else
+ QCOMPARE(result.toStringList().join(","), QString(expected));
+}
+
+
+// NOTE: These tests rely on rbutil.ini
+void TestPlayerBuildInfo::testPlayerInfo_data()
+{
+ QTest::addColumn<QString>("target");
+ QTest::addColumn<PlayerBuildInfo::DeviceInfo>("item");
+ QTest::addColumn<QString>("expected");
+ for (size_t i = 0; i < sizeof(testdataPlayer) / sizeof(testdataPlayer[0]); i++)
+ QTest::newRow("") << testdataPlayer[i].target << testdataPlayer[i].item
+ << testdataPlayer[i].expected;
+}
+
+void TestPlayerBuildInfo::testPlayerInfo()
+{
+ // create a temporary file for test input. Do not use QSettings() to allow
+ // creating different format variations.
+ QTemporaryFile tf(this);
+ tf.open();
+ QString filename = tf.fileName();
+ tf.write(testinfo);
+ tf.close();
+
+ PlayerBuildInfo::instance()->setBuildInfo(filename);
+
+ QFETCH(QString, target);
+ QFETCH(PlayerBuildInfo::DeviceInfo, item);
+ QFETCH(QString, expected);
+
+ QVariant result = PlayerBuildInfo::instance()->value(item, target);
+ if(result.canConvert(QMetaType::QString))
+ QCOMPARE(result.toString(), QString(expected));
+ else
+ QCOMPARE(result.toStringList().join(","), QString(expected));
+}
+
+
+QTEST_MAIN(TestPlayerBuildInfo)
+
+// 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-playerbuildinfo.moc"
+
diff --git a/rbutil/rbutilqt/test/test-serverinfo.pro b/rbutil/rbutilqt/test/test-playerbuildinfo.pro
index 903d5a6b07..724da59162 100644
--- a/rbutil/rbutilqt/test/test-serverinfo.pro
+++ b/rbutil/rbutilqt/test/test-playerbuildinfo.pro
@@ -18,19 +18,18 @@
QT += testlib
TEMPLATE = app
-TARGET = test-serverinfo
+TARGET = test-playerbuildinfo
INCLUDEPATH += . ../base stubs
# Input
SOURCES += \
- test-serverinfo.cpp \
- stubs/stubs-serverinfo.cpp \
- ../base/serverinfo.cpp
+ test-playerbuildinfo.cpp \
+ stubs/stubs-playerbuildinfo.cpp \
+ ../base/playerbuildinfo.cpp
HEADERS += \
../base/rbsettings.h \
../base/rockboxinfo.h \
../base/systeminfo.h \
- ../base/serverinfo.h \
RESOURCES += ../rbutilqt.qrc
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 @@
-/***************************************************************************
- * __________ __ ___.
- * 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 "serverinfo.h"
-
-class TestServerInfo : public QObject
-{
- Q_OBJECT
- private slots:
- void testMain();
-};
-
-const char* testinfo =
- "[release]\n"
- "archosfmrecorder=3.11.2\n"
- "iaudiom3=3.11.2,http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip\n"
- "sansae200 = 3.11.2\n"
- "iriverh100 = 3.11.2, http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip\n"
- "iriverh300 = \n"
- "[release-candidate]\n"
- "gigabeatfx=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip\n"
- "archosfmrecorder=f9dce96\n"
- "archosrecorder = f9dce96\n"
- "iaudiox5=f9dce96,http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip\n"
- "[dailies]\n"
- "timestamp = 20201113\n"
- "rev = 362f7a3\n"
- "[bleeding]\n"
- "timestamp = 20201114T105723Z\n"
- "rev = be1be79\n"
- "[status]\n"
- "archosfmrecorder=3\n"
- "iriverh100=2\n"
- "iriverh300=1\n"
- "iriverh10=0\n"
- ;
-
-
-struct testvector {
- const char* target;
- ServerInfo::ServerInfos entry;
- const char* expected;
-};
-
-
-const struct testvector testdata[] =
-{
- { "archosfmrecorder", ServerInfo::CurReleaseVersion, "3.11.2" },
- { "archosfmrecorder", ServerInfo::CurStatus, "3" },
- { "iaudiom3", ServerInfo::CurReleaseVersion, "3.11.2" },
- { "iaudiom3", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iaudiom5-3.11.2.zip" },
- { "sansae200", ServerInfo::CurReleaseVersion, "3.11.2" },
- { "sansae200", ServerInfo::CurReleaseUrl, "https://unittest/release/3.11.2/rockbox-sansae200-3.11.2.zip" },
- { "iriverh100", ServerInfo::CurReleaseVersion, "3.11.2" },
- { "iriverh100", ServerInfo::CurReleaseUrl, "http://dl.rockbox.org/release/3.11.2/rockbox-iriverh100-3.11.2.zip" },
- { "iriverh100", ServerInfo::CurStatus, "2" },
- { "iriverh100", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iriverh100.zip" },
- { "iriverh300", ServerInfo::CurReleaseVersion, "" },
- { "iriverh300", ServerInfo::CurReleaseUrl, "" },
- { "iriverh300", ServerInfo::CurStatus, "1" },
- { "iriverh10", ServerInfo::CurReleaseVersion, "" },
- { "iriverh10", ServerInfo::CurReleaseUrl, "" },
- { "iriverh10", ServerInfo::CurStatus, "0" },
- { "gigabeatfx", ServerInfo::RelCandidateVersion, "f9dce96" },
- { "gigabeatfx", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-gigabeatfx.zip" },
- { "archosfmrecorder", ServerInfo::RelCandidateVersion, "f9dce96" },
- { "archosfmrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosfmrecorder-f9dce96.zip" },
- { "archosrecorder", ServerInfo::RelCandidateVersion, "f9dce96" },
- { "archosrecorder", ServerInfo::RelCandidateUrl, "https://unittest/rc/f9dce96/rockbox-archosrecorder-f9dce96.zip" },
- { "iaudiox5", ServerInfo::RelCandidateVersion, "f9dce96" },
- { "iaudiox5", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
- { "iaudiox5.v", ServerInfo::RelCandidateVersion, "f9dce96" },
- { "iaudiox5.v", ServerInfo::RelCandidateUrl, "http://dl.rockbox.org/rc/f9dce96/rockbox-iaudiox5.zip" },
- { "iaudiox5.v", ServerInfo::BleedingRevision, "be1be79" },
- { "iaudiox5.v", ServerInfo::BleedingDate, "2020-11-14T10:57:23" },
- { "iaudiox5.v", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iaudiox5.zip" },
-};
-
-
-void TestServerInfo::testMain()
-{
- // create a temporary file for test input. Do not use QSettings() to allow
- // creating different format variations.
- QTemporaryFile tf(this);
- tf.open();
- QString filename = tf.fileName();
- tf.write(testinfo);
- tf.close();
-
- ServerInfo::instance()->readBuildInfo(filename);
-
- unsigned int i;
- for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
- QString result = ServerInfo::instance()->platformValue(testdata[i].entry, testdata[i].target).toString();
- QCOMPARE(result, QString(testdata[i].expected));
- }
-}
-
-
-QTEST_MAIN(TestServerInfo)
-
-// 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-serverinfo.moc"
-