diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-02-29 11:26:05 +0100 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2020-02-29 11:26:25 +0100 |
commit | 35b96e5c3e63a5330711c16366e724b0fe29c4ed (patch) | |
tree | 8b1b64a17c93e359a86904ae246248f4f8fb2d04 | |
parent | ee515ca80f827e11e5e85773c4d1529cd3b39252 (diff) |
Fix more spurious test failures due caused by concurrent tasks
-rw-r--r-- | src/test/autodjprocessor_test.cpp | 4 | ||||
-rw-r--r-- | src/test/librarytest.cpp | 8 | ||||
-rw-r--r-- | src/test/librarytest.h | 6 | ||||
-rw-r--r-- | src/test/searchqueryparsertest.cpp | 4 |
4 files changed, 18 insertions, 4 deletions
diff --git a/src/test/autodjprocessor_test.cpp b/src/test/autodjprocessor_test.cpp index 5e7b9058b4..8d318ae02c 100644 --- a/src/test/autodjprocessor_test.cpp +++ b/src/test/autodjprocessor_test.cpp @@ -211,8 +211,8 @@ class AutoDJProcessorTest : public LibraryTest { } TrackId addTrackToCollection(const QString& trackLocation) { - TrackPointer pTrack = internalCollection()->getOrAddTrack( - TrackRef::fromFileInfo(trackLocation)); + TrackPointer pTrack = + getOrAddTrackByLocationBlocking(trackLocation); return pTrack ? pTrack->getId() : TrackId(); } diff --git a/src/test/librarytest.cpp b/src/test/librarytest.cpp index 36ab56c56f..b699c04da6 100644 --- a/src/test/librarytest.cpp +++ b/src/test/librarytest.cpp @@ -40,3 +40,11 @@ LibraryTest::~LibraryTest() { QThreadPool::globalInstance()->clear(); QThreadPool::globalInstance()->waitForDone(); } + +TrackPointer LibraryTest::getOrAddTrackByLocationBlocking( + const QString& trackLocation) { + TrackPointer pTrack = internalCollection()->getOrAddTrack( + TrackRef::fromFileInfo(trackLocation)); + QThreadPool::globalInstance()->waitForDone(); + return pTrack; +} diff --git a/src/test/librarytest.h b/src/test/librarytest.h index 67f468cdc1..62513ea417 100644 --- a/src/test/librarytest.h +++ b/src/test/librarytest.h @@ -31,6 +31,12 @@ class LibraryTest : public MixxxTest { return trackCollections()->internalCollection(); } + // Blocks until all background tasks after adding the + // track (like cover art guessing) have been finished. + // Otherwise timing issues may cause test failures! + TrackPointer getOrAddTrackByLocationBlocking( + const QString& trackLocation); + private: const MixxxDb m_mixxxDb; const mixxx::DbConnectionPooler m_dbConnectionPooler; diff --git a/src/test/searchqueryparsertest.cpp b/src/test/searchqueryparsertest.cpp index 0e4ce9dbc8..f1d80f9742 100644 --- a/src/test/searchqueryparsertest.cpp +++ b/src/test/searchqueryparsertest.cpp @@ -17,8 +17,8 @@ class SearchQueryParserTest : public LibraryTest { } TrackId addTrackToCollection(const QString& trackLocation) { - TrackPointer pTrack = internalCollection()->getOrAddTrack( - TrackRef::fromFileInfo(trackLocation)); + TrackPointer pTrack = + getOrAddTrackByLocationBlocking(trackLocation); return pTrack ? pTrack->getId() : TrackId(); } |