#include "services/audio/output_controller.h"
#include <stdint.h>
#include <memory>
#include <optional>
#include <string_view>
#include <vector>
#include "base/barrier_closure.h"
#include "base/check.h"
#include "base/environment.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "base/test/test_message_loop.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "media/audio/audio_device_description.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_parameters.h"
#include "services/audio/loopback_group_member.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
AtLeast;
Invoke;
Mock;
NiceMock;
Return;
StrictMock;
AudioBus;
AudioManager;
AudioOutputStream;
AudioParameters;
RunClosure;
RunOnceClosure;
namespace audio {
namespace {
constexpr int kSampleRate = …;
const media::ChannelLayoutConfig kChannelLayoutConfig = …;
constexpr int kSamplesPerPacket = …;
constexpr double kTestVolume = …;
constexpr float kBufferNonZeroData = …;
AudioParameters GetTestParams() { … }
class MockOutputControllerEventHandler : public OutputController::EventHandler { … };
class MockOutputControllerSyncReader : public OutputController::SyncReader { … };
class MockStreamFactory { … };
class MockAudioOutputStream : public AudioOutputStream,
public AudioOutputStream::AudioSourceCallback { … };
class MockSnooper : public Snoopable::Snooper { … };
class AudioManagerForControllerTest final : public media::FakeAudioManager { … };
ACTION(PopulateBuffer) { … }
class OutputControllerTest : public ::testing::Test { … };
TEST_F(OutputControllerTest, CreateAndClose) { … }
TEST_F(OutputControllerTest, PlayAndClose) { … }
TEST_F(OutputControllerTest, PlayPauseClose) { … }
TEST_F(OutputControllerTest, PlayPausePlayClose) { … }
TEST_F(OutputControllerTest, PlayDeviceChangeClose) { … }
TEST_F(OutputControllerTest, PlayDeviceChangeDeviceChangeClose) { … }
TEST_F(OutputControllerTest, PlayPauseDeviceChangeClose) { … }
TEST_F(OutputControllerTest, CreateDeviceChangeClose) { … }
TEST_F(OutputControllerTest, SwitchDeviceClose) { … }
TEST_F(OutputControllerTest, SwitchDevicePlayClose) { … }
TEST_F(OutputControllerTest, PlayPauseSwitchDevicePlayClose) { … }
TEST_F(OutputControllerTest, PlaySwitchDeviceSwitchDevice2Close) { … }
TEST_F(OutputControllerTest, PlaySwitchDevicePausePlayPauseClose) { … }
TEST_F(OutputControllerTest, PlaySwitchDeviceSwitchDeviceClose) { … }
double GetStreamVolume(AudioOutputStream* stream) { … }
TEST_F(OutputControllerTest, MuteCreatePlayClose) { … }
TEST_F(OutputControllerTest, CreatePlayMuteClose) { … }
TEST_F(OutputControllerTest, MutePlayUnmuteClose) { … }
TEST_F(OutputControllerTest, SnoopCreatePlayStopClose) { … }
TEST_F(OutputControllerTest, CreatePlaySnoopStopClose) { … }
TEST_F(OutputControllerTest, CreatePlaySnoopCloseStop) { … }
TEST_F(OutputControllerTest, TwoSnoopers_StartAtDifferentTimes) { … }
TEST_F(OutputControllerTest, TwoSnoopers_StopAtDifferentTimes) { … }
TEST_F(OutputControllerTest, SnoopWhileMuting) { … }
TEST_F(OutputControllerTest, FlushWhenStreamIsPlayingTriggersError) { … }
TEST_F(OutputControllerTest, FlushesWhenStreamIsNotPlaying) { … }
TEST_F(OutputControllerTest, FlushesAfterDeviceChange) { … }
class MockAudioOutputStreamForMixing : public AudioOutputStream { … };
TEST(OutputControllerMixingTest,
ControllerUsesProvidedCManagedDeviceOutputStreamCreateCallbackCorrectly) { … }
TEST(OutputControllerMixingTest,
ControllerForwardsMixingFlagAndGlitchesToSyncReader) { … }
TEST(OutputControllerMixingTest,
SwitchDeviceIdManagedDeviceOutputStreamCreateCallbackCorrectly) { … }
}
}