-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
512 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef ALL_DBAPI_H | ||
#define ALL_DBAPI_H | ||
|
||
#include <QObject> | ||
#include <QTest> | ||
#include <dbapi/DBApi.h> | ||
|
||
void runTests_DBApi(DBApi *Api); | ||
|
||
#endif // ALL_DBAPI_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "t_Equalizer.h" | ||
#include <QTest> | ||
#include <QSignalSpy> | ||
|
||
#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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef T_EQUALIZER_H | ||
#define T_EQUALIZER_H | ||
|
||
#include <QObject> | ||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "t_ItemImporter.h" | ||
#include <QTest> | ||
|
||
#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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef T_ITEMIMPORTER_H | ||
#define T_ITEMIMPORTER_H | ||
|
||
#include <QObject> | ||
#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 |
Oops, something went wrong.