chromium/media/audio/audio_output_proxy_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stdint.h>

#include <memory>
#include <string>
#include <utility>

#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_output_dispatcher_impl.h"
#include "media/audio/audio_output_proxy.h"
#include "media/audio/audio_output_resampler.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_output_stream.h"
#include "media/audio/test_audio_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
AllOf;
DoAll;
Field;
Mock;
NotNull;
Return;
SetArrayArgument;
AudioBus;
AudioInputStream;
AudioManager;
AudioManagerBase;
AudioOutputDispatcher;
AudioOutputProxy;
AudioOutputStream;
AudioParameters;
FakeAudioOutputStream;
TestAudioThread;

namespace {

static const int kTestCloseDelayMs =;

// Delay between callbacks to AudioSourceCallback::OnMoreData.
static const int kOnMoreDataCallbackDelayMs =;

// Let start run long enough for many OnMoreData callbacks to occur.
static const int kStartRunTimeMs =;

// Dummy function.
std::unique_ptr<media::AudioDebugRecorder> RegisterDebugRecording(
    const media::AudioParameters& params) {}

class MockAudioOutputStream : public AudioOutputStream {};

class CallbackExposingMockOutputStream : public AudioOutputStream {};

class MockAudioManager : public AudioManagerBase {};

class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback {};

}  // namespace

namespace media {

class AudioOutputProxyTest : public testing::Test {};

class AudioOutputResamplerTest : public AudioOutputProxyTest {};

TEST_F(AudioOutputProxyTest, CreateAndClose) {}

TEST_F(AudioOutputResamplerTest, CreateAndClose) {}

TEST_F(AudioOutputProxyTest, OpenAndClose) {}

TEST_F(AudioOutputResamplerTest, OpenAndClose) {}

// Create a stream, and verify that it is closed after kTestCloseDelayMs.
// if it doesn't start playing.
TEST_F(AudioOutputProxyTest, CreateAndWait) {}

// Create a stream, and verify that it is closed after kTestCloseDelayMs.
// if it doesn't start playing.
TEST_F(AudioOutputResamplerTest, CreateAndWait) {}

TEST_F(AudioOutputProxyTest, StartAndStop) {}

TEST_F(AudioOutputResamplerTest, StartAndStop) {}

TEST_F(AudioOutputProxyTest, CloseAfterStop) {}

TEST_F(AudioOutputResamplerTest, CloseAfterStop) {}

TEST_F(AudioOutputProxyTest, TwoStreams) {}

TEST_F(AudioOutputResamplerTest, TwoStreams) {}

// Two streams: verify that second stream is allocated when the first
// starts playing.
TEST_F(AudioOutputProxyTest, OneStream_TwoPlays) {}

TEST_F(AudioOutputResamplerTest, OneStream_TwoPlays) {}

// Two streams, both are playing. Dispatcher should not open a third stream.
TEST_F(AudioOutputProxyTest, TwoStreams_BothPlaying) {}

TEST_F(AudioOutputResamplerTest, TwoStreams_BothPlaying) {}

TEST_F(AudioOutputProxyTest, OpenFailed) {}

// Start() method failed.
TEST_F(AudioOutputProxyTest, StartFailed) {}

TEST_F(AudioOutputResamplerTest, StartFailed) {}

TEST_F(AudioOutputProxyTest, DispatcherDestroyed_BeforeOpen) {}

TEST_F(AudioOutputResamplerTest, DispatcherDestroyed_BeforeOpen) {}

TEST_F(AudioOutputProxyTest, DispatcherDestroyed_BeforeStart) {}

TEST_F(AudioOutputResamplerTest, DispatcherDestroyed_BeforeStart) {}

TEST_F(AudioOutputProxyTest, DispatcherDestroyed_BeforeStop) {}

TEST_F(AudioOutputResamplerTest, DispatcherDestroyed_BeforeStop) {}

TEST_F(AudioOutputProxyTest, DispatcherDestroyed_AfterStop) {}

TEST_F(AudioOutputResamplerTest, DispatcherDestroyed_AfterStop) {}

TEST_F(AudioOutputProxyTest, DispatcherDeviceChangeClosesIdleStreams) {}

// Simulate AudioOutputStream::Create() failure with a low latency stream and
// ensure AudioOutputResampler falls back to the high latency path.
TEST_F(AudioOutputResamplerTest, LowLatencyCreateFailedFallback) {}

// Simulate AudioOutputStream::Open() failure with a low latency stream and
// ensure AudioOutputResampler falls back to the high latency path.
TEST_F(AudioOutputResamplerTest, LowLatencyOpenFailedFallback) {}

// Simulate failures to open both the low latency and the fallback high latency
// stream and ensure AudioOutputResampler falls back to a fake stream.
TEST_F(AudioOutputResamplerTest, HighLatencyFallbackFailed) {}

// Simulate failures to open both the low latency, the fallback high latency
// stream, and the fake audio output stream and ensure AudioOutputResampler
// terminates normally.
TEST_F(AudioOutputResamplerTest, AllFallbackFailed) {}

// Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls
// eventually followed by one which fails; root cause of http://crbug.com/150619
TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) {}

// Simulate failures to open both the low latency and the fallback high latency
// stream and ensure AudioOutputResampler falls back to a fake stream.  Ensure
// that after the close delay elapses, opening another stream succeeds with a
// non-fake stream.
TEST_F(AudioOutputResamplerTest, FallbackRecovery) {}

TEST_F(AudioOutputResamplerTest, PropagatesGlitchInfo) {}

}  // namespace media