Skip to content

Commit

Permalink
test: Only register SoundSourceProviders when actually necessary
Browse files Browse the repository at this point in the history
This allows tests to inherit from MixxxTest and still register
SoundSourceProviders themselves, e.g. by instantiating CoreServices.
It also reduces log spam caused by the sound source provider
registration.
  • Loading branch information
Holzhaus committed Jun 10, 2021
1 parent b4aa128 commit d2e5a99
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/test/librarytest.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#include "library/trackcollection.h"
#include "library/trackcollectionmanager.h"
#include "test/mixxxdbtest.h"
#include "test/soundsourcemixin.h"
#include "util/db/dbconnectionpooled.h"
#include "util/db/dbconnectionpooler.h"

class LibraryTest : public MixxxDbTest {
class LibraryTest : public MixxxDbTest, SoundSourceMixin {
protected:
LibraryTest();
~LibraryTest() override = default;
Expand Down
6 changes: 0 additions & 6 deletions src/test/mixxxtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "control/control.h"
#include "library/coverartutils.h"
#include "sources/soundsourceproxy.h"
#include "util/cmdlineargs.h"
#include "util/logging.h"

Expand Down Expand Up @@ -45,11 +44,6 @@ MixxxTest::ApplicationScope::ApplicationScope(int& argc, char** argv) {

DEBUG_ASSERT(s_pApplication.isNull());
s_pApplication.reset(new MixxxApplication(argc, argv));

const bool providersRegistered =
SoundSourceProxy::registerProviders();
Q_UNUSED(providersRegistered);
DEBUG_ASSERT(providersRegistered);
}

MixxxTest::ApplicationScope::~ApplicationScope() {
Expand Down
3 changes: 2 additions & 1 deletion src/test/signalpathtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mixer/sampler.h"
#include "preferences/usersettings.h"
#include "test/mixxxtest.h"
#include "test/soundsourcemixin.h"
#include "track/track.h"
#include "util/defs.h"
#include "util/memory.h"
Expand Down Expand Up @@ -55,7 +56,7 @@ class TestEngineMaster : public EngineMaster {
}
};

class BaseSignalPathTest : public MixxxTest {
class BaseSignalPathTest : public MixxxTest, SoundSourceMixin {
protected:
BaseSignalPathTest() {
m_pGuiTick = std::make_unique<GuiTick>();
Expand Down
3 changes: 2 additions & 1 deletion src/test/soundproxy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "sources/audiosourcestereoproxy.h"
#include "sources/soundsourceproxy.h"
#include "test/mixxxtest.h"
#include "test/soundsourcemixin.h"
#include "track/track.h"
#include "track/trackmetadata.h"
#include "util/samplebuffer.h"
Expand Down Expand Up @@ -35,7 +36,7 @@ const CSAMPLE kMaxDecodingError = 0.01f;

} // anonymous namespace

class SoundSourceProxyTest : public MixxxTest {
class SoundSourceProxyTest : public MixxxTest, SoundSourceMixin {
protected:
static QStringList getFileNameSuffixes() {
QStringList availableFileNameSuffixes;
Expand Down
12 changes: 12 additions & 0 deletions src/test/soundsourcemixin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include "sources/soundsourceproxy.h"

class SoundSourceMixin {
protected:
SoundSourceMixin() {
const bool providersRegistered =
SoundSourceProxy::registerProviders();
Q_UNUSED(providersRegistered);
DEBUG_ASSERT(providersRegistered);
}
};
3 changes: 2 additions & 1 deletion src/test/trackupdate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "library/coverart.h"
#include "sources/soundsourceproxy.h"
#include "test/mixxxtest.h"
#include "test/soundsourcemixin.h"
#include "track/track.h"

namespace {
Expand All @@ -12,7 +13,7 @@ const QDir kTestDir(QDir::current().absoluteFilePath("src/test/id3-test-data"));
} // anonymous namespace

// Test for updating track metadata and cover art from files.
class TrackUpdateTest: public MixxxTest {
class TrackUpdateTest : public MixxxTest, SoundSourceMixin {
protected:
static bool hasTrackMetadata(const TrackPointer& pTrack) {
return !pTrack->getArtist().isEmpty();
Expand Down

0 comments on commit d2e5a99

Please sign in to comment.