-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2293 from uklotzde/2.2_globaltrackcache
GlobalTrackCache: Fix edge cases and tests
- Loading branch information
Showing
7 changed files
with
235 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "test/librarytest.h" | ||
|
||
namespace { | ||
|
||
const bool kInMemoryDbConnection = true; | ||
|
||
void deleteTrack(Track* pTrack) { | ||
// Delete track objects directly in unit tests with | ||
// no main event loop | ||
delete pTrack; | ||
}; | ||
|
||
} | ||
|
||
LibraryTest::LibraryTest() | ||
: m_mixxxDb(config(), kInMemoryDbConnection), | ||
m_dbConnectionPooler(m_mixxxDb.connectionPool()), | ||
m_dbConnection(mixxx::DbConnectionPooled(m_mixxxDb.connectionPool())), | ||
m_pTrackCollection(std::make_unique<TrackCollection>(config())) { | ||
MixxxDb::initDatabaseSchema(m_dbConnection); | ||
m_pTrackCollection->connectDatabase(m_dbConnection); | ||
GlobalTrackCache::createInstance(this, deleteTrack); | ||
} | ||
|
||
LibraryTest::~LibraryTest() { | ||
m_pTrackCollection->disconnectDatabase(); | ||
m_pTrackCollection.reset(); | ||
// With the track collection all remaining track references | ||
// should have been dropped before destroying the cache. | ||
GlobalTrackCache::destroyInstance(); | ||
} | ||
|
||
void LibraryTest::saveEvictedTrack(Track* pTrack) noexcept { | ||
m_pTrackCollection->exportTrackMetadata(pTrack); | ||
m_pTrackCollection->saveTrack(pTrack); | ||
} |
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
Oops, something went wrong.