mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 08:13:35 +00:00
Bug 1586370 - Remove MediaTrackGraph dependency from AudioCallbackDriver gtest. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D57552 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
638c69d019
commit
712efff333
@ -5,7 +5,6 @@
|
||||
|
||||
#include "CubebUtils.h"
|
||||
#include "GraphDriver.h"
|
||||
#include "MediaTrackGraphImpl.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest-printers.h"
|
||||
@ -17,25 +16,50 @@
|
||||
|
||||
#include "MockCubeb.h"
|
||||
|
||||
using IterationResult = GraphInterface::IterationResult;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
using namespace mozilla;
|
||||
|
||||
RefPtr<MediaTrackGraphImpl> MakeMTGImpl() {
|
||||
return MakeRefPtr<MediaTrackGraphImpl>(MediaTrackGraph::AUDIO_THREAD_DRIVER,
|
||||
MediaTrackGraph::DIRECT_DRIVER, 44100,
|
||||
2, nullptr);
|
||||
}
|
||||
class MockGraphInterface : public GraphInterface {
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MockGraphInterface, override);
|
||||
MOCK_METHOD4(NotifyOutputData,
|
||||
void(AudioDataValue*, size_t, TrackRate, uint32_t));
|
||||
MOCK_METHOD4(NotifyInputData,
|
||||
void(const AudioDataValue*, size_t, TrackRate, uint32_t));
|
||||
MOCK_METHOD0(DeviceChanged, void());
|
||||
/* OneIteration cannot be mocked because IterationResult is non-memmovable and
|
||||
* cannot be passed as a parameter, which GMock does internally. */
|
||||
IterationResult OneIteration(GraphTime, AudioMixer*) {
|
||||
return mKeepProcessing ? IterationResult::CreateStillProcessing()
|
||||
: IterationResult::CreateStop(
|
||||
NS_NewRunnableFunction(__func__, [] {}));
|
||||
}
|
||||
#ifdef DEBUG
|
||||
bool InDriverIteration(GraphDriver* aDriver) override {
|
||||
return aDriver->OnThread();
|
||||
}
|
||||
#endif
|
||||
|
||||
void StopIterating() { mKeepProcessing = false; }
|
||||
|
||||
protected:
|
||||
Atomic<bool> mKeepProcessing{true};
|
||||
virtual ~MockGraphInterface() = default;
|
||||
};
|
||||
|
||||
#if 0
|
||||
TEST(TestAudioCallbackDriver, StartStop)
|
||||
MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
|
||||
MockCubeb* mock = new MockCubeb();
|
||||
CubebUtils::ForceSetCubebContext(mock->AsCubebContext());
|
||||
MockCubeb* cubeb = new MockCubeb();
|
||||
CubebUtils::ForceSetCubebContext(cubeb->AsCubebContext());
|
||||
|
||||
RefPtr<MediaTrackGraphImpl> graph = MakeMTGImpl();
|
||||
EXPECT_TRUE(!!graph->mDriver) << "AudioCallbackDriver created.";
|
||||
RefPtr<AudioCallbackDriver> driver;
|
||||
auto graph = MakeRefPtr<NiceMock<MockGraphInterface>>();
|
||||
ON_CALL(*graph, NotifyOutputData)
|
||||
.WillByDefault([&](AudioDataValue*, size_t, TrackRate, uint32_t) {});
|
||||
|
||||
AudioCallbackDriver* driver = graph->mDriver->AsAudioCallbackDriver();
|
||||
driver = MakeRefPtr<AudioCallbackDriver>(graph, nullptr, 44100, 2, 0, nullptr,
|
||||
nullptr, AudioInputType::Unknown);
|
||||
EXPECT_FALSE(driver->ThreadRunning()) << "Verify thread is not running";
|
||||
EXPECT_FALSE(driver->IsStarted()) << "Verify thread is not started";
|
||||
|
||||
@ -46,16 +70,8 @@ MOZ_CAN_RUN_SCRIPT_FOR_DEFINITION {
|
||||
EXPECT_TRUE(driver->IsStarted()) << "Verify thread is started";
|
||||
|
||||
// This will block untill all events have been executed.
|
||||
MOZ_KnownLive(driver->AsAudioCallbackDriver())->Shutdown();
|
||||
graph->StopIterating();
|
||||
MOZ_KnownLive(driver)->Shutdown();
|
||||
EXPECT_FALSE(driver->ThreadRunning()) << "Verify thread is not running";
|
||||
EXPECT_FALSE(driver->IsStarted()) << "Verify thread is not started";
|
||||
|
||||
// This is required because the MTG and the driver hold references between
|
||||
// each other. The driver has a reference to SharedThreadPool which will
|
||||
// block for ever if it is not cleared. The same logic exists in
|
||||
// MediaTrackGraphShutDownRunnable
|
||||
graph->mDriver = nullptr;
|
||||
|
||||
graph->RemoveShutdownBlocker();
|
||||
}
|
||||
#endif
|
||||
|
@ -118,4 +118,7 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
|
||||
if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
|
||||
CXXFLAGS += ['-Wno-unused-private-field']
|
||||
CXXFLAGS += [
|
||||
'-Wno-inconsistent-missing-override',
|
||||
'-Wno-unused-private-field',
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user