chromium/media/audio/audio_output_unittest.cc

// Copyright 2017 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 "base/command_line.h"
#include "base/memory/aligned_memory.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "build/build_config.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/simple_sources.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/limits.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

namespace media {

class AudioOutputTest : public testing::TestWithParam<bool> {};

// Test that can it be created and closed.
TEST_P(AudioOutputTest, GetAndClose) {}

// Test that it can be opened and closed.
TEST_P(AudioOutputTest, OpenAndClose) {}

// Verify that Stop() can be called before Start().
TEST_P(AudioOutputTest, StopBeforeStart) {}

// Verify that Stop() can be called more than once.
TEST_P(AudioOutputTest, StopTwice) {}

// This test produces actual audio for .25 seconds on the default device.
#if BUILDFLAG(IS_IOS)
// TODO(crbug.com/40283968): audio output unit startup fails with partition
// alloc.
#define MAYBE_Play200HzTone
#else
#define MAYBE_Play200HzTone
#endif
TEST_P(AudioOutputTest, MAYBE_Play200HzTone) {}

// Test that SetVolume() and GetVolume() work as expected.
TEST_P(AudioOutputTest, VolumeControl) {}

// The test parameter is only relevant on Android. It controls whether or not we
// allow the use of AAudio.
INSTANTIATE_TEST_SUITE_P();

#if BUILDFLAG(IS_ANDROID)
// Run tests with AAudio enabled. On Android P and below, these tests should not
// run, as we only use AAudio on Q+.
INSTANTIATE_TEST_SUITE_P(AAudio, AudioOutputTest, testing::Values(true));
#endif

}  // namespace media