-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathlibrarytest.cpp
More file actions
51 lines (42 loc) · 1.5 KB
/
Copy pathlibrarytest.cpp
File metadata and controls
51 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "test/librarytest.h"
#include "library/coverartcache.h"
#include "library/dateformatbroadcaster.h"
#include "library/library_prefs.h"
#include "track/track.h"
namespace {
const bool kInMemoryDbConnection = true;
void deleteTrack(Track* pTrack) {
// Delete track objects directly in unit tests with
// no main event loop
delete pTrack;
};
std::unique_ptr<TrackCollectionManager> newTrackCollectionManager(
UserSettingsPointer userSettings,
mixxx::DbConnectionPoolPtr dbConnectionPool) {
const auto dbConnection = mixxx::DbConnectionPooled(dbConnectionPool);
if (!MixxxDb::initDatabaseSchema(dbConnection)) {
return nullptr;
}
return std::make_unique<TrackCollectionManager>(
nullptr,
std::move(userSettings),
std::move(dbConnectionPool),
deleteTrack);
}
} // namespace
LibraryTest::LibraryTest()
: MixxxDbTest(kInMemoryDbConnection),
m_pTrackCollectionManager(newTrackCollectionManager(config(), dbConnectionPooler())),
m_keyNotationCO(mixxx::library::prefs::kKeyNotationConfigKey) {
CoverArtCache::createInstance();
DateFormatChangedBroadcaster::createInstance();
}
LibraryTest::~LibraryTest() {
CoverArtCache::destroy();
DateFormatChangedBroadcaster::destroy();
}
TrackPointer LibraryTest::getOrAddTrackByLocation(
const QString& trackLocation) const {
return m_pTrackCollectionManager->getOrAddTrack(
TrackRef::fromFilePath(trackLocation));
}