diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-08-04 12:24:38 +0200 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-08-04 13:14:51 +0200 |
commit | a6f59f7766a64cb44a67f02ff1705aaeb7e62b30 (patch) | |
tree | a328e00587cdc54c20018faa11c2030e8a2528ae /src/test/signalpathtest.h | |
parent | cd7c3e0f29862e6eda3b378dd5096f7d1695a708 (diff) |
mixer/playerinfo: Make implicit PlayerInfo creation explicit
Until now, the `PlayerInfo` singleton was instantiated implicitly when
it was first accessed. This commit makes the instantiation explicit by
adding a dedicated `PlayerInfo::create()` method.
When running tests directly via `mixxx-test` (i.e. not a via `ctest`),
all tests will be executed in the *same* process. Thus, the singleton
will be instantiated by the first test that accessses the instance, but
stay alive until `mixxx-test` is terminated.
The `PlayerInfo` instance will repeatedly call
`updateCurrentlyPlayingDeck()` through the `timerEvent()` mehtod during
its lifetime. This will access some COs, e.g. `[Master],num_decks`.
Depending on the currently running test, these COs may or may not be
present. When `QCoreApplication::processEvents()` is called, there might
be a `timerEvent()` in the queue and will cause CO access. If the CO is
*not* present for that test, the test will throw a `DEBUG_ASSERT`.
By making the singleton instantiation more explicit, we can add
`PlayerInfo::create()` and `PlayerInfo::destroy()` calls only to the
constructor/destructor of text fixtures that need it, and ensure that
the timer doesn't cause failed debug assertions in unrelated tests.
This fixes the remaining `DEBUG_ASSERT` issues and paves the way for
merging PR #2911.
Diffstat (limited to 'src/test/signalpathtest.h')
-rw-r--r-- | src/test/signalpathtest.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/test/signalpathtest.h b/src/test/signalpathtest.h index d6bd67d070..10d5541651 100644 --- a/src/test/signalpathtest.h +++ b/src/test/signalpathtest.h @@ -1,25 +1,25 @@ -#ifndef ENGINEBACKENDTEST_H_ -#define ENGINEBACKENDTEST_H_ +#pragma once -#include <gtest/gtest.h> #include <gmock/gmock.h> +#include <gtest/gtest.h> -#include <QtDebug> #include <QTest> +#include <QtDebug> -#include "preferences/usersettings.h" #include "control/controlobject.h" -#include "mixer/deck.h" #include "effects/effectsmanager.h" -#include "engine/enginebuffer.h" #include "engine/bufferscalers/enginebufferscale.h" #include "engine/channels/enginechannel.h" #include "engine/channels/enginedeck.h" -#include "engine/enginemaster.h" #include "engine/controls/ratecontrol.h" +#include "engine/enginebuffer.h" +#include "engine/enginemaster.h" #include "engine/sync/enginesync.h" +#include "mixer/deck.h" +#include "mixer/playerinfo.h" #include "mixer/previewdeck.h" #include "mixer/sampler.h" +#include "preferences/usersettings.h" #include "test/mixxxtest.h" #include "util/defs.h" #include "util/memory.h" @@ -94,6 +94,8 @@ class BaseSignalPathTest : public MixxxTest { m_pEngineSync = m_pEngineMaster->getEngineSync(); ControlObject::set(ConfigKey("[Master]", "enabled"), 1.0); + + PlayerInfo::create(); } ~BaseSignalPathTest() override { @@ -111,6 +113,7 @@ class BaseSignalPathTest : public MixxxTest { delete m_pEffectsManager; delete m_pVisualsManager; delete m_pNumDecks; + PlayerInfo::destroy(); } void addDeck(EngineDeck* pDeck) { @@ -234,5 +237,3 @@ class SignalPathTest : public BaseSignalPathTest { loadTrack(m_pMixerDeck3, pTrack); } }; - -#endif /* ENGINEBACKENDTEST_H_ */ |