#include "services/audio/input_controller.h"
#include <memory>
#include <string_view>
#include <utility>
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "media/audio/aecdump_recording_manager.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_manager.h"
#include "media/audio/fake_audio_input_stream.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
#include "media/audio/mock_audio_manager.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_glitch_info.h"
#include "media/base/audio_processing.h"
#include "media/base/media_switches.h"
#include "media/base/user_input_monitor.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/audio/device_output_listener.h"
#include "services/audio/processing_audio_fifo.h"
#include "services/audio/reference_output.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
AtLeast;
Exactly;
InvokeWithoutArgs;
NiceMock;
NotNull;
StrictMock;
namespace audio {
namespace {
const int kSampleRate = …;
const media::ChannelLayoutConfig kChannelLayoutConfig = …;
const int kSamplesPerPacket = …;
constexpr base::TimeDelta kOnMutePollInterval = …;
enum class ChromeWideEchoCancellationSetting { … };
enum class DecreaseFifoSizeSetting { … };
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
const std::string kFifoSizeParameter = …;
#endif
}
class MockInputControllerEventHandler : public InputController::EventHandler { … };
class MockSyncWriter : public InputController::SyncWriter { … };
class MockUserInputMonitor : public media::UserInputMonitor { … };
class MockAudioInputStream : public media::AudioInputStream { … };
enum class AudioManagerType { … };
template <base::test::TaskEnvironment::TimeSource TimeSource =
base::test::TaskEnvironment::TimeSource::MOCK_TIME,
AudioManagerType audio_manager_type = AudioManagerType::FAKE>
class TimeSourceInputControllerTest
: public ::testing::TestWithParam<
std::tuple<ChromeWideEchoCancellationSetting,
DecreaseFifoSizeSetting>> { … };
auto test_name_generator = …::string name_suffix = …;
SystemTimeInputControllerTest;
InputControllerTest;
InputControllerTestWithMockAudioManager;
TEST_P(InputControllerTest, CreateAndCloseWithoutRecording) { … }
TEST_P(SystemTimeInputControllerTest, CreateRecordAndClose) { … }
TEST_P(InputControllerTestWithMockAudioManager, PropagatesGlitchInfo) { … }
TEST_P(InputControllerTest, RecordTwice) { … }
TEST_P(InputControllerTest, CloseTwice) { … }
TEST_P(InputControllerTest, TestOnmutedCallbackInitiallyUnmuted) { … }
TEST_P(InputControllerTest, TestOnmutedCallbackInitiallyMuted) { … }
auto test_values = …;
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
class InputControllerTestHelper { … };
class MockDeviceOutputListener : public DeviceOutputListener { … };
template <base::test::TaskEnvironment::TimeSource TimeSource =
base::test::TaskEnvironment::TimeSource::MOCK_TIME>
class TimeSourceInputControllerTestWithDeviceListener
: public TimeSourceInputControllerTest<TimeSource> { … };
SystemTimeInputControllerTestWithDeviceListener;
InputControllerTestWithDeviceListener;
TEST_P(InputControllerTestWithDeviceListener,
CreateWithAudioProcessingConfig_WithSomeEffectsEnabled) { … }
TEST_P(InputControllerTestWithDeviceListener,
CreateWithAudioProcessingConfig_WithoutEnablingEffects) { … }
TEST_P(InputControllerTestWithDeviceListener,
CreateWithAudioProcessingConfig_VerifyFifoUsage) { … }
TEST_P(
InputControllerTestWithDeviceListener,
CreateWithAudioProcessingConfig_DoesNotListenForPlayoutReferenceIfNotRequired) { … }
TEST_P(InputControllerTestWithDeviceListener, RecordBeforeSetOutputForAec) { … }
TEST_P(InputControllerTestWithDeviceListener, RecordAfterSetOutputForAec) { … }
TEST_P(InputControllerTestWithDeviceListener, FifoSize) { … }
TEST_P(InputControllerTestWithDeviceListener, ChangeOutputForAec) { … }
TEST_P(SystemTimeInputControllerTestWithDeviceListener, CreateRecordAndClose) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
#endif
}