-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathlibrarytest.cpp
42 lines (34 loc) · 1.25 KB
/
librarytest.cpp
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
#include "test/librarytest.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()
: m_mixxxDb(config(), kInMemoryDbConnection),
m_dbConnectionPooler(m_mixxxDb.connectionPool()),
m_pTrackCollectionManager(newTrackCollectionManager(config(), m_dbConnectionPooler)),
m_keyNotationCO(ConfigKey("[Library]", "key_notation")) {
}
TrackPointer LibraryTest::getOrAddTrackByLocation(
const QString& trackLocation) const {
return m_pTrackCollectionManager->getOrAddTrack(
TrackRef::fromFileInfo(trackLocation));
}