#include "services/audio/output_device_mixer_manager.h"
#include <optional>
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "media/audio/audio_device_description.h"
#include "media/audio/audio_io.h"
#include "media/audio/mock_audio_manager.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_parameters.h"
#include "services/audio/output_device_mixer.h"
#include "services/audio/reference_output.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
ByMove;
Eq;
InSequence;
NiceMock;
Ref;
Return;
ReturnRef;
StrictMock;
AudioOutputStream;
AudioParameters;
RunOnceClosure;
namespace audio {
namespace {
enum class ReservedIdTestType { … };
MATCHER(ValidDeviceChangeCallback, "") { … }
MATCHER_P(ExactParams, expected, "") { … }
MATCHER_P(CompatibleParams, expected, "") { … }
const std::string kFakeDeviceId = …;
const std::string kOtherFakeDeviceId = …;
const std::string kFakeCommunicationsId = …;
const std::string kEmptyDeviceId = …;
const std::string kNormalizedDefaultDeviceId = …;
const auto* kReservedDefaultId = …;
const auto* kReservedCommsId = …;
class MockAudioOutputStream : public AudioOutputStream { … };
class LocalMockAudioManager : public media::MockAudioManager { … };
class MockListener : public audio::ReferenceOutput::Listener { … };
class MockOutputDeviceMixer : public audio::OutputDeviceMixer { … };
}
class OutputDeviceMixerManagerTest
: public ::testing::TestWithParam<ReservedIdTestType> { … };
TEST_P(OutputDeviceMixerManagerTest, MakeOutputStream_ForReservedDevice) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_ForReservedDevice_NoGetReservedOuputDeviceIdSupport) { … }
TEST_F(OutputDeviceMixerManagerTest,
MakeOutputStream_ForDefaultDevice_EmptyDeviceId) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_ForSpecificDeviceId_MatchesCurrentReservedId) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_ForSpecificDeviceId_NoGetDefaultOuputDeviceIdSupport) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_ForSpecificDeviceId_NoGetGetReservedIdSupport) { … }
TEST_F(OutputDeviceMixerManagerTest,
MakeOutputStream_ForSpecificDeviceId_IdDoesntMatchReservedIds) { … }
TEST_F(OutputDeviceMixerManagerTest,
MakeOutputStream_GetsDeviceOrDefaultParams) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_WithBitstreamFormat) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_WithStaleDeviceInfo) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_MaxProxies) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_MixerCreationFails) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_MixerReturnsNull) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_OneMixerPerId) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_ReservedIdAndCurrentReservedDeviceIdShareOneMixer) { … }
TEST_F(OutputDeviceMixerManagerTest, MakeOutputStream_TwoDevicesTwoMixers) { … }
TEST_F(OutputDeviceMixerManagerTest,
MakeOutputStream_DefaultMixerDistinctFromOtherMixers) { … }
TEST_F(OutputDeviceMixerManagerTest,
MakeOutputStream_CommunicationsMixerDistinctFromOtherMixers) { … }
TEST_P(OutputDeviceMixerManagerTest,
MakeOutputStream_CurrentReseredIdIsUpdatedAfterDeviceChange) { … }
TEST_P(OutputDeviceMixerManagerTest,
OnDeviceChange_MixersReceiveDeviceChanges) { … }
TEST_F(OutputDeviceMixerManagerTest, OnDeviceChange_OncePerDeviceChange) { … }
TEST_F(OutputDeviceMixerManagerTest, DeviceOutputListener_StartStop) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStop_MultipleDevice) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStop_MultipleListener) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStop_ReservedId) { … }
TEST_F(OutputDeviceMixerManagerTest, DeviceOutputListener_CreateStartStop) { … }
TEST_F(OutputDeviceMixerManagerTest, DeviceOutputListener_StartCreateStop) { … }
TEST_F(OutputDeviceMixerManagerTest, DeviceOutputListener_StartStopCreate) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_CreateStartStop_NoGetReservedIdSupport) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartCreateStop_NoGetReservedIdSupport) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStopCreate_NoGetReservedIdSupport) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStopCreate_TwoListeners) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_CreateStartStop_ReservedId) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartCreateStop_ReservedId) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartStopCreate_ReservedId) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_StartCreateStop_DefaultId_EmptyDeviceId) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_ReservedListenersAttachToCurrentReservedIdMixer) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_CurrentReservedIdListenersAttachToReservedMixer) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_NoCreateAfterDeviceChange_WithListeners) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_ListenersReattachedAfterDeviceChange) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_ReservedIdListenersReattachedAfterDeviceChange) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_CurrentDefaultListenersNotReattached) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_CurrentDefaultMixerCreation_ListenersAttached) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_ReservedIdMixerCreation_ListenersAttached) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_OtherDeviceMixerCreation_ListenersNotAttached) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_MultipleStarts_EquivalentIds) { … }
TEST_F(OutputDeviceMixerManagerTest,
DeviceOutputListener_MultipleStarts_DifferentIds) { … }
TEST_P(OutputDeviceMixerManagerTest,
DeviceOutputListener_MultipleStarts_ReservedToSpecific) { … }
TEST_F(OutputDeviceMixerManagerTest,
ReservedIds_DefaultAndCommunicationsPhysicalIdsShared) { … }
TEST_F(OutputDeviceMixerManagerTest,
ReservedIds_EmptyCommunicationsPhysicalId) { … }
INSTANTIATE_TEST_SUITE_P(…);
}