From 965815773da223023bd344a0f992f9c73321f99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Wasylk=C3=B3w?= Date: Sun, 8 Sep 2024 01:36:01 +0200 Subject: [PATCH] Add tests --- CMakeLists.txt | 50 +++++++++++++ QtGui.cpp | 59 ++++++++++++++- dbapi/Equalizer.h | 2 +- dbapi/ItemImporter.cpp | 1 + dbapi/PlaybackControl.cpp | 13 ++++ dbapi/PlaybackControl.h | 4 +- tests/DBApi/All_DBApi.cpp | 14 ++++ tests/DBApi/All_DBApi.h | 11 +++ tests/DBApi/t_Equalizer.cpp | 48 ++++++++++++ tests/DBApi/t_Equalizer.h | 24 ++++++ tests/DBApi/t_ItemImporter.cpp | 43 +++++++++++ tests/DBApi/t_ItemImporter.h | 24 ++++++ tests/DBApi/t_PlaybackControl.cpp | 119 ++++++++++++++++++++++++++++++ tests/DBApi/t_PlaybackControl.h | 40 ++++++++++ tests/DBApi/t_PlaylistManager.cpp | 10 +++ tests/DBApi/t_PlaylistManager.h | 21 ++++++ tests/Tests.cpp | 15 ++++ tests/Tests.h | 5 ++ tests/audio.m3u | 7 ++ tests/audio/silence.mp3 | Bin 0 -> 120017 bytes tests/audio/silence2.mp3 | Bin 0 -> 120017 bytes tests/audio/silence3.mp3 | Bin 0 -> 120017 bytes tests/run_deadbeef_tests.sh | 7 ++ 23 files changed, 512 insertions(+), 5 deletions(-) create mode 100644 tests/DBApi/All_DBApi.cpp create mode 100644 tests/DBApi/All_DBApi.h create mode 100644 tests/DBApi/t_Equalizer.cpp create mode 100644 tests/DBApi/t_Equalizer.h create mode 100644 tests/DBApi/t_ItemImporter.cpp create mode 100644 tests/DBApi/t_ItemImporter.h create mode 100644 tests/DBApi/t_PlaybackControl.cpp create mode 100644 tests/DBApi/t_PlaybackControl.h create mode 100644 tests/DBApi/t_PlaylistManager.cpp create mode 100644 tests/DBApi/t_PlaylistManager.h create mode 100644 tests/Tests.cpp create mode 100644 tests/Tests.h create mode 100644 tests/audio.m3u create mode 100644 tests/audio/silence.mp3 create mode 100644 tests/audio/silence2.mp3 create mode 100644 tests/audio/silence3.mp3 create mode 100755 tests/run_deadbeef_tests.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index f7f3b41..46747d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,3 +123,53 @@ endif() # WORKAROUND: with qt 6.7: install for some reason links to local qt... # install(TARGETS ddb_gui_qt5 DESTINATION "~/.local/lib/deadbeef") install(FILES ${CMAKE_BINARY_DIR}/ddb_gui_qt5.so DESTINATION "~/.local/lib/deadbeef") + + +# TESTS + +project(ddb_gui_q_test LANGUAGES CXX) + +add_library(ddb_gui_q_test SHARED ${SOURCES} tests/Tests.cpp + tests/Tests.h + tests/DBApi/All_DBApi.h tests/DBApi/All_DBApi.cpp + tests/DBApi/t_PlaybackControl.h tests/DBApi/t_PlaybackControl.cpp + tests/DBApi/t_PlaylistManager.h tests/DBApi/t_PlaylistManager.cpp + tests/DBApi/t_ItemImporter.cpp + tests/DBApi/t_ItemImporter.h + tests/DBApi/t_Equalizer.h tests/DBApi/t_Equalizer.cpp) + +find_package(Qt6 COMPONENTS REQUIRED Test) + + + +target_link_libraries(ddb_gui_q_test PRIVATE dbapiplugin DDB2 GuiCommon DDB2plugin GuiCommonplugin Qt6::Core Qt::Gui Qt::Quick Qt::Concurrent Qt::Svg Qt::Test) +if (USE_WIDGETS) + target_link_libraries(ddb_gui_q_test PRIVATE dbapi Qt6::Widgets Qt6::QuickWidgets) +endif() + +if (USE_CHARTS) + target_link_libraries(ddb_gui_q_test PRIVATE dbapi Qt6::Charts) +endif() + +target_include_directories(ddb_gui_q_test PRIVATE ".") + +target_compile_definitions(ddb_gui_q_test PRIVATE USE_WIDGETS=${USE_WIDGETS} QT_USE_STRINGBUILDER) +target_compile_definitions(ddb_gui_q_test PRIVATE USE_CACHE=${USE_COVERART_CACHE}) + +target_compile_options(ddb_gui_q_test PRIVATE "-gdwarf-4") + +# fix for static qt +get_target_property(QT_TARGET_TYPE Qt6::Core TYPE) +if(${QT_TARGET_TYPE} STREQUAL "STATIC_LIBRARY") + find_package(Qt6QmlImportScanner REQUIRED) + qt6_import_qml_plugins(ddb_gui_q_test) +endif() + +if(WIN32) +target_link_options(ddb_gui_q_test PRIVATE "-Wl,--export-all-symbols") +endif() + + +target_compile_definitions(ddb_gui_q_test PRIVATE Q_TEST=1) + +install(FILES ${CMAKE_BINARY_DIR}/ddb_gui_q_test.so DESTINATION "~/.local/lib/deadbeef") diff --git a/QtGui.cpp b/QtGui.cpp index b565b54..6db5416 100644 --- a/QtGui.cpp +++ b/QtGui.cpp @@ -38,6 +38,10 @@ #include #include +#if Q_TEST +#include "tests/Tests.h" +#endif + //#include "DeadbeefTranslator.h" @@ -66,7 +70,9 @@ QGuiApplication *app = nullptr; static int pluginMessage_wrapper(uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { - return api->pluginMessage(id, ctx, p1, p2); + if (api) + return api->pluginMessage(id, ctx, p1, p2); + return 0; } static void initializeQApp() { @@ -190,6 +196,10 @@ static int pluginStart() { api = new DBApi(nullptr, deadbeef_internal); plugin.plugin.message = pluginMessage_wrapper; +#if Q_TEST + runTests(api); +#else + startWidgets(); if (!USE_WIDGETS || DBAPI->conf_get_int("qgui.show_qtquick_window", false)) @@ -200,8 +210,10 @@ static int pluginStart() { unloadQuick(); unloadWidgets(); - - delete api; +#endif + DBApi *api_del = api; + api = nullptr; + delete api_del; delete app; DBAPI->sendmessage(DB_EV_TERMINATE, 0, 0, 0); @@ -247,4 +259,45 @@ extern "C" { qt_plugin.register_widget = registerWidget; return DB_PLUGIN(&plugin); } + +#if Q_TEST + DB_plugin_t *ddb_gui_q_test_load(DB_functions_t *Api) { + deadbeef_internal = Api; + plugin.plugin.api_vmajor = 1; + plugin.plugin.api_vminor = 9; + plugin.plugin.version_major = 1; + plugin.plugin.version_minor = 9; + plugin.plugin.type = DB_PLUGIN_GUI; + plugin.plugin.id = "qt5"; + plugin.plugin.name = "Qt user interface"; + plugin.plugin.descr = "Qt user interface"; + plugin.plugin.copyright = + "ddb_gui_qt5 - Qt user interface\n" + "Copyright (C) 2010 Anton Novikov \n" + "Copyright (C) 2011 Semen Minyushov \n" + "Copyright (C) 2013 Karjavin Roman \n" + "Copyright (C) 2019-2021 Jakub Wasylków \n" + "\n" + "This program is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License\n" + "as published by the Free Software Foundation; either version 2\n" + "of the License, or (at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"; + plugin.plugin.website = "https://github.com/kuba160/ddb_gui_qt5"; + plugin.plugin.start = pluginStart; + plugin.plugin.stop = pluginStop; + plugin.plugin.connect = pluginConnect; + plugin.plugin.message = nullptr; + qt_plugin.register_widget = registerWidget; + return DB_PLUGIN(&plugin); + } +#endif } diff --git a/dbapi/Equalizer.h b/dbapi/Equalizer.h index b1751f4..cd9a302 100644 --- a/dbapi/Equalizer.h +++ b/dbapi/Equalizer.h @@ -11,7 +11,7 @@ class Equalizer : public QObject inline ddb_dsp_context_t * get_supereq(); public: explicit Equalizer(QObject *parent, DB_functions_t *api); - Q_PROPERTY(bool available READ getEqAvailable NOTIFY eqAvailableChanged) + Q_PROPERTY(bool available READ getEqAvailable CONSTANT) Q_PROPERTY(bool enabled READ getEqEnabled WRITE setEqEnabled NOTIFY eqEnabledChanged) Q_PROPERTY(QVariantList values READ getEq WRITE setEq NOTIFY eqChanged) diff --git a/dbapi/ItemImporter.cpp b/dbapi/ItemImporter.cpp index c37a794..a72716e 100644 --- a/dbapi/ItemImporter.cpp +++ b/dbapi/ItemImporter.cpp @@ -2,6 +2,7 @@ #include #include +#define USE_CONCURRENT 1 #ifdef USE_CONCURRENT #include #endif diff --git a/dbapi/PlaybackControl.cpp b/dbapi/PlaybackControl.cpp index 9b55b95..1f12fd8 100644 --- a/dbapi/PlaybackControl.cpp +++ b/dbapi/PlaybackControl.cpp @@ -205,6 +205,19 @@ bool PlaybackControl::getStopAfterCurrent() { void PlaybackControl::setStopAfterCurrent(bool value) { deadbeef->conf_set_int("playlist.stop_after_current", value); deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); + m_stop_after_current = value; + emit stopAfterCurrentChanged(); +} + +bool PlaybackControl::getStopAfterAlbum() { + return m_stop_after_album; +} + +void PlaybackControl::setStopAfterAlbum(bool value) { + deadbeef->conf_set_int("playlist.stop_after_album", value); + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); + m_stop_after_album = value; + emit stopAfterAlbumChanged(); } QString PlaybackControl::tf_current(const QString &format) { diff --git a/dbapi/PlaybackControl.h b/dbapi/PlaybackControl.h index 8489c24..789a3c4 100644 --- a/dbapi/PlaybackControl.h +++ b/dbapi/PlaybackControl.h @@ -44,7 +44,7 @@ class PlaybackControl : public QObject Q_PROPERTY(repeat repeat READ getRepeat WRITE setRepeat NOTIFY repeatChanged) Q_PROPERTY(playback_state state MEMBER m_state NOTIFY stateChanged) Q_PROPERTY(bool stop_after_current READ getStopAfterCurrent WRITE setStopAfterCurrent NOTIFY stopAfterCurrentChanged) - Q_PROPERTY(bool stop_after_album MEMBER m_stop_after_album NOTIFY stopAfterAlbumChanged) + Q_PROPERTY(bool stop_after_album READ getStopAfterAlbum WRITE setStopAfterAlbum NOTIFY stopAfterAlbumChanged) //Q_PROPERTY(DB_playItem_t * currentTrack READ getCurrentTrack NOTIFY currentTrackChanged) Q_PROPERTY(quint32 currentTrackIdx READ getCurrentTrackIdx WRITE setCurrentTrackIdx NOTIFY currentTrackChanged) // NOTE: won't be changed when track is moved @@ -102,6 +102,8 @@ public slots: bool getStopAfterCurrent(); void setStopAfterCurrent(bool value); + bool getStopAfterAlbum(); + void setStopAfterAlbum(bool value); public slots: QString tf_current(const QString &format); diff --git a/tests/DBApi/All_DBApi.cpp b/tests/DBApi/All_DBApi.cpp new file mode 100644 index 0000000..4f70be0 --- /dev/null +++ b/tests/DBApi/All_DBApi.cpp @@ -0,0 +1,14 @@ +#include "All_DBApi.h" +#include "../Tests.h" + +#include "t_PlaybackControl.h" +#include "t_PlaylistManager.h" +#include "t_ItemImporter.h" +#include "t_Equalizer.h" + +void runTests_DBApi(DBApi *Api) { + Q_TEST_RUN(t_PlaybackControl, Api); + Q_TEST_RUN(t_ItemImporter, Api); + Q_TEST_RUN(t_PlaylistManager, Api); + Q_TEST_RUN(t_Equalizer, Api); +} diff --git a/tests/DBApi/All_DBApi.h b/tests/DBApi/All_DBApi.h new file mode 100644 index 0000000..1d45f2b --- /dev/null +++ b/tests/DBApi/All_DBApi.h @@ -0,0 +1,11 @@ +#ifndef ALL_DBAPI_H +#define ALL_DBAPI_H + +#include +#include +#include + +void runTests_DBApi(DBApi *Api); + +#endif // ALL_DBAPI_H + diff --git a/tests/DBApi/t_Equalizer.cpp b/tests/DBApi/t_Equalizer.cpp new file mode 100644 index 0000000..f9b308e --- /dev/null +++ b/tests/DBApi/t_Equalizer.cpp @@ -0,0 +1,48 @@ +#include "t_Equalizer.h" +#include +#include + +#define EQ (&api->eq) + +t_Equalizer::t_Equalizer(DBApi *Api) + : QObject{Api} +{ + api = Api; +} + +void t_Equalizer::eqEnableTest() { + if (!EQ->getEqAvailable()) { + QSKIP("Equalizer unavailable"); + } + + bool curr = EQ->getEqEnabled(); + + QSignalSpy spy(EQ, &Equalizer::eqEnabledChanged); + EQ->setEqEnabled(!curr); + spy.wait(1); + QCOMPARE(EQ->getEqEnabled(), !curr); + QCOMPARE(spy.count(), 1); + EQ->setEqEnabled(curr); + spy.wait(1); +} + +void t_Equalizer::eqSetTest() { + if (!EQ->getEqAvailable()) { + QSKIP("Equalizer unavailable"); + } + + QVariantList eq_orig = EQ->getEq(); + + QVariantList eq_test; + for(int i = 0 ; i < eq_orig.length(); i++) { + eq_test.append(i%2 ? 20.0 : -20.0); + } + + QSignalSpy spy(EQ, &Equalizer::eqChanged); + EQ->setEq(eq_test); + spy.wait(1); + QCOMPARE(EQ->getEq(), eq_test); + QCOMPARE(spy.count(), 1); + EQ->setEq(eq_orig); + spy.wait(1); +} diff --git a/tests/DBApi/t_Equalizer.h b/tests/DBApi/t_Equalizer.h new file mode 100644 index 0000000..26100b5 --- /dev/null +++ b/tests/DBApi/t_Equalizer.h @@ -0,0 +1,24 @@ +#ifndef T_EQUALIZER_H +#define T_EQUALIZER_H + +#include +#include "dbapi/DBApi.h" + +class t_Equalizer : public QObject +{ + Q_OBJECT +public: + explicit t_Equalizer(DBApi *Api); + +private: + DBApi *api; + +private slots: + + void eqEnableTest(); + void eqSetTest(); + +signals: +}; + +#endif // T_EQUALIZER_H diff --git a/tests/DBApi/t_ItemImporter.cpp b/tests/DBApi/t_ItemImporter.cpp new file mode 100644 index 0000000..db5bb70 --- /dev/null +++ b/tests/DBApi/t_ItemImporter.cpp @@ -0,0 +1,43 @@ +#include "t_ItemImporter.h" +#include + +#define PM (&api->playlist) + +t_ItemImporter::t_ItemImporter(DBApi *Api) + : QObject{Api} +{ + api = Api; +} + +void t_ItemImporter::addFileTest() { + QFuture ft = PM->runFileImport({"/home/kuba/sources/ddb_gui_qt6/tests/audio/silence.mp3"}); + ft.waitForFinished(); + PlayItemIterator iter = ft.result(); + int i = 0; + while(iter.getNextIter()) { + i++; + } + QCOMPARE(i, 1); +} + +void t_ItemImporter::addFolderTest() { + QFuture ft = PM->runFolderImport({"/home/kuba/sources/ddb_gui_qt6/tests/audio/"}); + ft.waitForFinished(); + PlayItemIterator iter = ft.result(); + int i = 0; + while(iter.getNextIter()) { + i++; + } + QCOMPARE(i, 3); +} + +void t_ItemImporter::addPlaylistTest() { + QFuture ft = PM->runPlaylistImport({"/home/kuba/sources/ddb_gui_qt6/tests/audio.m3u"}); + ft.waitForFinished(); + PlayItemIterator iter = ft.result(); + int i = 0; + while(iter.getNextIter()) { + i++; + } + QCOMPARE(i, 3); +} diff --git a/tests/DBApi/t_ItemImporter.h b/tests/DBApi/t_ItemImporter.h new file mode 100644 index 0000000..eb20370 --- /dev/null +++ b/tests/DBApi/t_ItemImporter.h @@ -0,0 +1,24 @@ +#ifndef T_ITEMIMPORTER_H +#define T_ITEMIMPORTER_H + +#include +#include "dbapi/DBApi.h" + +class t_ItemImporter : public QObject +{ + Q_OBJECT +public: + explicit t_ItemImporter(DBApi *Api); + +private: + DBApi *api; + +private slots: + void addFolderTest(); + void addFileTest(); + void addPlaylistTest(); + +signals: +}; + +#endif // T_ITEMIMPORTER_H diff --git a/tests/DBApi/t_PlaybackControl.cpp b/tests/DBApi/t_PlaybackControl.cpp new file mode 100644 index 0000000..32ad980 --- /dev/null +++ b/tests/DBApi/t_PlaybackControl.cpp @@ -0,0 +1,119 @@ +#include "t_PlaybackControl.h" +#include +#include + +#define PC (&api->playback) + +t_PlaybackControl::t_PlaybackControl(DBApi *Api) + : QObject{Api} { + api = Api; +} + +//void initTestCase(); +//void cleanupTestCase(); + +void t_PlaybackControl::volumeTest_data() { + QTest::addColumn("volume"); + QTest::addRow("test0,-5.0") << -5.0; + QTest::addRow("test1,0.0") << 0.0; + for(int i = 0; i < 10; i++) { + double test_val = QRandomGenerator::global()->generateDouble() * 50 - 50; + QTest::addRow("rand%d,%f",i, test_val) << test_val; + } +} + +void t_PlaybackControl::volumeTest() { + QFETCH(double, volume); + PlaybackControl *pc = &api->playback; + float orig = pc->getVolume(); + + QSignalSpy spy(pc, &PlaybackControl::volumeChanged); + if (orig == (float) volume) { + QSKIP("same volume already applied"); + } + pc->setVolume(volume); + QCOMPARE((float) pc->getVolume(), (float) volume); + QCOMPARE((float) api->deadbeef->volume_get_db(), (float) volume); + spy.wait(); + QCOMPARE(spy.count(), 1); + pc->setVolume(orig); + spy.wait(); +} + +void t_PlaybackControl::shuffleTest_data() { + QTest::addColumn("shuffle"); + QTest::addRow("PlaybackControl::SHUFFLE_OFF") << PlaybackControl::SHUFFLE_OFF; + QTest::addRow("PlaybackControl::SHUFFLE_TRACKS") << PlaybackControl::SHUFFLE_TRACKS; + QTest::addRow("PlaybackControl::SHUFFLE_RANDOM") << PlaybackControl::SHUFFLE_RANDOM; + QTest::addRow("PlaybackControl::SHUFFLE_ALBUMS") << PlaybackControl::SHUFFLE_ALBUMS; +} + +void t_PlaybackControl::shuffleTest() { + QFETCH(PlaybackControl::shuffle, shuffle); + PlaybackControl *pc = &api->playback; + PlaybackControl::shuffle orig = pc->getShuffle(); + + QSignalSpy spy(pc, &PlaybackControl::shuffleChanged); + if (orig == shuffle) { + QSKIP("same shuffle already applied"); + } + pc->setShuffle(shuffle); + QCOMPARE(pc->getShuffle(), shuffle); + QCOMPARE(api->deadbeef->streamer_get_shuffle(), shuffle); + spy.wait(1); + QCOMPARE(spy.count(), 1); + pc->setShuffle(orig); + spy.wait(1); +} + +void t_PlaybackControl::repeatTest_data() { + QTest::addColumn("repeat"); + QTest::addRow("PlaybackControl::REPEAT_ALL") << PlaybackControl::REPEAT_ALL; + QTest::addRow("PlaybackControl::REPEAT_OFF") << PlaybackControl::REPEAT_OFF; + QTest::addRow("PlaybackControl::REPEAT_SINGLE") << PlaybackControl::REPEAT_SINGLE; +} + +void t_PlaybackControl::repeatTest() { + QFETCH(PlaybackControl::repeat, repeat); + PlaybackControl *pc = &api->playback; + PlaybackControl::repeat orig = pc->getRepeat(); + + QSignalSpy spy(pc, &PlaybackControl::repeatChanged); + if (orig == repeat) { + QSKIP("same repeat already applied"); + } + pc->setRepeat(repeat); + QCOMPARE(pc->getRepeat(), repeat); + QCOMPARE(api->deadbeef->streamer_get_repeat(), repeat); + spy.wait(1); + QCOMPARE(spy.count(), 1); + pc->setRepeat(orig); + spy.wait(1); +} + +void t_PlaybackControl::stopAfterCurrentTest() { + bool curr = PC->getStopAfterCurrent(); + QSignalSpy spy(PC, &PlaybackControl::stopAfterCurrentChanged); + PC->setStopAfterCurrent(!curr); + QCOMPARE(PC->getStopAfterCurrent(), !curr); + spy.wait(1); + QCOMPARE(spy.count(), 1); + PC->setStopAfterCurrent(curr); + spy.wait(1); + QCOMPARE(spy.count(), 2); +} + +void t_PlaybackControl::stopAfterAlbumTest() { + bool curr = PC->getStopAfterAlbum(); + QSignalSpy spy(PC, &PlaybackControl::stopAfterAlbumChanged); + PC->setStopAfterAlbum(!curr); + QCOMPARE(PC->getStopAfterAlbum(), !curr); + spy.wait(1); + QCOMPARE(spy.count(), 1); + PC->setStopAfterAlbum(curr); + QCOMPARE(PC->getStopAfterAlbum(), curr); + spy.wait(1); + QCOMPARE(spy.count(), 2); +} + +// TODO test state/position / playing/paused/stopped and more diff --git a/tests/DBApi/t_PlaybackControl.h b/tests/DBApi/t_PlaybackControl.h new file mode 100644 index 0000000..2466b04 --- /dev/null +++ b/tests/DBApi/t_PlaybackControl.h @@ -0,0 +1,40 @@ +#ifndef T_PLAYBACKCONTROL_H +#define T_PLAYBACKCONTROL_H + +#include +#include +#include "dbapi/DBApi.h" + +class t_PlaybackControl : public QObject { + Q_OBJECT +public: + explicit t_PlaybackControl(DBApi *Api); + + +private: + DBApi *api = nullptr; + + bool myCondition() + { + return true; + } + +private slots: + // void initTestCase(); + // void cleanupTestCase(); + + void volumeTest_data(); + void volumeTest(); + + void shuffleTest_data(); + void shuffleTest(); + + void repeatTest_data(); + void repeatTest(); + + void stopAfterCurrentTest(); + void stopAfterAlbumTest(); + +}; + +#endif // T_PLAYBACKCONTROL_H diff --git a/tests/DBApi/t_PlaylistManager.cpp b/tests/DBApi/t_PlaylistManager.cpp new file mode 100644 index 0000000..91e90a7 --- /dev/null +++ b/tests/DBApi/t_PlaylistManager.cpp @@ -0,0 +1,10 @@ +#include "t_PlaylistManager.h" +#include + +#define PM (&api->playlist) + +t_PlaylistManager::t_PlaylistManager(DBApi *Api) + : QObject{Api} +{ + api = Api; +} diff --git a/tests/DBApi/t_PlaylistManager.h b/tests/DBApi/t_PlaylistManager.h new file mode 100644 index 0000000..c516636 --- /dev/null +++ b/tests/DBApi/t_PlaylistManager.h @@ -0,0 +1,21 @@ +#ifndef T_PLAYLISTMANAGER_H +#define T_PLAYLISTMANAGER_H + +#include +#include "dbapi/DBApi.h" + +class t_PlaylistManager : public QObject +{ + Q_OBJECT +public: + explicit t_PlaylistManager(DBApi *Api); + +private: + DBApi *api; + +private slots: + +signals: +}; + +#endif // T_PLAYLISTMANAGER_H diff --git a/tests/Tests.cpp b/tests/Tests.cpp new file mode 100644 index 0000000..f429743 --- /dev/null +++ b/tests/Tests.cpp @@ -0,0 +1,15 @@ +#include +#include +#include "Tests.h" +#include "DBApi/All_DBApi.h" + +void runTests(DBApi *Api) { + char *conf_dir = getenv("XDG_CONFIG_HOME"); + if (!conf_dir || !strstr(conf_dir, "/tmp")) { + qDebug() << "ERROR: Tests require a config in tmp directory. Try running run_deadbeef_tests.sh."; + } + else { + runTests_DBApi(Api); + } +} + diff --git a/tests/Tests.h b/tests/Tests.h new file mode 100644 index 0000000..c85201d --- /dev/null +++ b/tests/Tests.h @@ -0,0 +1,5 @@ +#include + +void runTests(DBApi* Api); + +#define Q_TEST_RUN(x, api) {auto t = new x(api); QTest::qExec(t); delete t;} diff --git a/tests/audio.m3u b/tests/audio.m3u new file mode 100644 index 0000000..baa4c5b --- /dev/null +++ b/tests/audio.m3u @@ -0,0 +1,7 @@ +#EXTM3U +#EXTINF:30,silence +./audio/silence.mp3 +#EXTINF:30,silence2 +./audio/silence2.mp3 +#EXTINF:30,silence3 +./audio/silence3.mp3 diff --git a/tests/audio/silence.mp3 b/tests/audio/silence.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..e09d4922e742e09bd6aeb9cd2f219a6acd4b4dea GIT binary patch literal 120017 zcmeI$e`J+m0EXdjSxn3(k%(4C5wlq(5|tupDw>K&nq?vqNtB70#FB_4QlcUjQ4vv; zjFgdNDG^DGL`>G%A5UZJ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