#include <stdint.h>
#include <memory>
#include <vector>
#include "base/command_line.h"
#include "base/environment.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_message_loop.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "media/audio/audio_device_description.h"
#include "media/audio/audio_device_info_accessor_for_tests.h"
#include "media/audio/audio_features.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_manager.h"
#include "media/audio/audio_unittest_util.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_glitch_info.h"
#include "media/base/media_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_ANDROID)
#include "media/audio/android/aaudio_stream_wrapper.h"
#include "media/audio/android/audio_manager_android.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include <fuchsia/media/cpp/fidl_test_base.h>
#include "base/fuchsia/scoped_service_binding.h"
#include "base/fuchsia/test_component_context_for_process.h"
#include "media/fuchsia/audio/fake_audio_capturer.h"
#endif
namespace media {
#if BUILDFLAG(IS_FUCHSIA)
class FakeAudio : public fuchsia::media::testing::Audio_TestBase {
public:
FakeAudio()
: audio_binding_(test_component_context_.additional_services(), this) {}
void CreateAudioCapturer(
fidl::InterfaceRequest<fuchsia::media::AudioCapturer> request,
bool is_loopback) override {
capturer_.push_back(
std::make_unique<FakeAudioCapturer>(std::move(request)));
}
void NotImplemented_(const std::string& name) override {
FAIL() << "Unexpected call to: " << name;
}
private:
base::TestComponentContextForProcess test_component_context_;
base::ScopedServiceBinding<fuchsia::media::Audio> audio_binding_;
std::vector<std::unique_ptr<FakeAudioCapturer>> capturer_;
};
#endif
class TestInputCallback : public AudioInputStream::AudioInputCallback { … };
class AudioInputTest : public testing::TestWithParam<bool> { … };
TEST_P(AudioInputTest, CreateAndClose) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_OpenAndClose …
#else
#define MAYBE_OpenAndClose …
#endif
TEST_P(AudioInputTest, MAYBE_OpenAndClose) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_OpenStopAndClose …
#else
#define MAYBE_OpenStopAndClose …
#endif
TEST_P(AudioInputTest, MAYBE_OpenStopAndClose) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_Record …
#else
#define MAYBE_Record …
#endif
TEST_P(AudioInputTest, MAYBE_Record) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_ANDROID)
INSTANTIATE_TEST_SUITE_P(AAudio, AudioInputTest, testing::Values(true));
#endif
}