Commit 0b12aa9c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

test: Invert logic to clarify which background service gets started

All unit tests used to start the notifier, while it's only needed for a
single set of tests
parent d5f4a7fa
......@@ -156,10 +156,12 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
static const char* const supportedExtensions[];
static const size_t NbSupportedExtensions;
private:
protected:
virtual void startParser();
virtual void startDiscoverer();
virtual void startDeletionNotifier();
private:
bool recreateDatabase( const std::string& dbPath );
InitializeResult updateDatabaseModel( unsigned int previousVersion,
const std::string& path );
......
......@@ -39,6 +39,8 @@ class MediaLibraryTester : public MediaLibrary
public:
MediaLibraryTester();
virtual void startParser() override {}
virtual void startDiscoverer() override {}
virtual void startDeletionNotifier() override {}
std::vector<MediaPtr> files();
// Use the filename getter
using MediaLibrary::media;
......@@ -76,12 +78,20 @@ private:
std::shared_ptr<Folder> dummyFolder;
};
class MediaLibraryWithoutBackground : public MediaLibraryTester
class MediaLibraryWithDiscoverer : public MediaLibraryTester
{
virtual void startDiscoverer() override {}
virtual void startDiscoverer() override
{
// Fall back to the default variant which actually starts the discoverer
MediaLibrary::startDiscoverer();
}
};
class MediaLibraryWithNotifier : public MediaLibraryTester
{
virtual void startDiscoverer() override {}
virtual void startDeletionNotifier() override
{
// Fall back to the default variant which actually starts the notifier
MediaLibrary::startDeletionNotifier();
}
};
......@@ -62,7 +62,7 @@ protected:
virtual void InstantiateMediaLibrary() override
{
ml.reset( new MediaLibraryTester );
ml.reset( new MediaLibraryWithDiscoverer );
}
virtual void Reload()
......
......@@ -54,7 +54,7 @@ public:
virtual void InstantiateMediaLibrary() override
{
ml.reset( new MediaLibraryTester );
ml.reset( new MediaLibraryWithDiscoverer );
}
virtual void Reload()
......
......@@ -556,7 +556,7 @@ protected:
virtual void InstantiateMediaLibrary() override
{
ml.reset( new MediaLibraryTester );
ml.reset( new MediaLibraryWithDiscoverer );
}
virtual void Reload()
......
......@@ -55,7 +55,7 @@ public:
virtual void SetUp() override
{
unlink("test.db");
ml.reset( new MediaLibraryWithoutBackground );
ml.reset( new MediaLibraryTester );
cbMock.reset( new mock::NoopCallback );
}
......
......@@ -79,7 +79,7 @@ void Tests::SetUp()
void Tests::InstantiateMediaLibrary()
{
ml.reset( new MediaLibraryWithoutBackground );
ml.reset( new MediaLibraryTester );
}
::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new TestEnv);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment