diff options
author | Owen Williams <owilliams@mixxx.org> | 2021-10-01 16:06:44 -0400 |
---|---|---|
committer | Owen Williams <owilliams@mixxx.org> | 2021-10-01 17:31:12 -0400 |
commit | b60c00fd34ea4a00d598a565086a76b87167d438 (patch) | |
tree | e892e4eba6de6d4d44c1e96e3eafdb828cd106a7 /src | |
parent | 8b1ed1b1646079c60b184369941a03f812751b08 (diff) |
Fix race condition in ReplayGain test
This test caused a race because it called slotLoadTrack instead of loadTrack, so it did not wait for the track to actually load. The test was quitting before the caching reader had a chance to finish setting up, so when the test was getting torn down there was a chance that the reader would try to access the objects while they were being destructed.
Because the test infrastructure has its own destruction code, it's not clear if this crash could occur in regular code.
Fixes https://bugs.launchpad.net/mixxx/+bug/1940589
Diffstat (limited to 'src')
-rw-r--r-- | src/test/replaygaintest.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/test/replaygaintest.cpp b/src/test/replaygaintest.cpp index c9407470ea..5ec0629383 100644 --- a/src/test/replaygaintest.cpp +++ b/src/test/replaygaintest.cpp @@ -160,13 +160,18 @@ TEST_F(ReplayGainTest, NormalizePeak) { class AdjustReplayGainTest : public MockedEngineBackendTest {}; TEST_F(AdjustReplayGainTest, AdjustReplayGainUpdatesPregain) { + const QString kTrackLocationTest = QDir::currentPath() + "/src/test/sine-30.wav"; + TrackPointer pTrack(Track::newTemporary(kTrackLocationTest)); + + // Load the same track in decks 1 and 2 so we can see that the pregain is adjusted on both + // decks. + loadTrack(m_pMixerDeck1, pTrack); + loadTrack(m_pMixerDeck2, pTrack); + // Initialize fake track replaygain so it's not zero. mixxx::ReplayGain replayGain; replayGain.setRatio(1.0); - m_pTrack1->setReplayGain(replayGain); - // Load the same track in decks 1 and 2 so we can see that the pregain is adjusted on both - // decks. - m_pMixerDeck2->slotLoadTrack(m_pTrack1, false); + pTrack->setReplayGain(replayGain); // Because of this artificial process we have to manually set the replaygain CO for the second // deck. m_pMixerDeck2->slotSetReplayGain(replayGain); @@ -183,7 +188,7 @@ TEST_F(AdjustReplayGainTest, AdjustReplayGainUpdatesPregain) { .005); EXPECT_DOUBLE_EQ(1.2, ControlObject::getControl(ConfigKey(m_sGroup1, "replaygain"))->get()); EXPECT_DOUBLE_EQ(1.2, ControlObject::getControl(ConfigKey(m_sGroup2, "replaygain"))->get()); - EXPECT_DOUBLE_EQ(1.2, m_pTrack1->getReplayGain().getRatio()); + EXPECT_DOUBLE_EQ(1.2, pTrack->getReplayGain().getRatio()); } } // anonymous namespace |