| Index: media/audio/audio_manager_unittest.cc
|
| diff --git a/media/audio/audio_manager_unittest.cc b/media/audio/audio_manager_unittest.cc
|
| index 930e776c5f570fa64563623db9b2d6b1a9bfb93e..21e11f8890bf9784c9d5b49a0f9c8662ef407b17 100644
|
| --- a/media/audio/audio_manager_unittest.cc
|
| +++ b/media/audio/audio_manager_unittest.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/synchronization/waitable_event.h"
|
| #include "media/audio/audio_manager.h"
|
| #include "media/audio/audio_manager_base.h"
|
| +#include "media/audio/audio_unittest_utils.h"
|
| #include "media/audio/fake_audio_log_factory.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -46,8 +47,6 @@ class AudioManagerTest : public ::testing::Test {
|
| event.Wait();
|
| }
|
|
|
| - AudioManager* audio_manager() { return audio_manager_.get(); };
|
| -
|
| #if defined(OS_WIN)
|
| bool SetMMDeviceEnumeration() {
|
| AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get());
|
| @@ -113,11 +112,11 @@ class AudioManagerTest : public ::testing::Test {
|
| }
|
| }
|
|
|
| - bool CanRunInputTest() {
|
| + bool InputDevicesAvailable() {
|
| return audio_manager_->HasAudioInputDevices();
|
| }
|
|
|
| - bool CanRunOutputTest() {
|
| + bool OutputDevicesAvailable() {
|
| return audio_manager_->HasAudioOutputDevices();
|
| }
|
|
|
| @@ -133,7 +132,7 @@ class AudioManagerTest : public ::testing::Test {
|
|
|
| // Synchronously runs the provided callback/closure on the audio thread.
|
| void RunOnAudioThread(const base::Closure& closure) {
|
| - if (!audio_manager()->GetTaskRunner()->BelongsToCurrentThread()) {
|
| + if (!audio_manager_->GetTaskRunner()->BelongsToCurrentThread()) {
|
| base::WaitableEvent event(false, false);
|
| audio_manager_->GetTaskRunner()->PostTask(
|
| FROM_HERE,
|
| @@ -149,7 +148,7 @@ class AudioManagerTest : public ::testing::Test {
|
|
|
| void RunOnAudioThreadImpl(const base::Closure& closure,
|
| base::WaitableEvent* event) {
|
| - DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
|
| + DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
|
| closure.Run();
|
| event->Signal();
|
| }
|
| @@ -165,26 +164,24 @@ class AudioManagerTest : public ::testing::Test {
|
|
|
| // Test that devices can be enumerated.
|
| TEST_F(AudioManagerTest, EnumerateInputDevices) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| RunOnAudioThread(
|
| base::Bind(&AudioManager::GetAudioInputDeviceNames,
|
| - base::Unretained(audio_manager()),
|
| + base::Unretained(audio_manager_.get()),
|
| &device_names));
|
| CheckDeviceNames(device_names);
|
| }
|
|
|
| // Test that devices can be enumerated.
|
| TEST_F(AudioManagerTest, EnumerateOutputDevices) {
|
| - if (!CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(OutputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| RunOnAudioThread(
|
| base::Bind(&AudioManager::GetAudioOutputDeviceNames,
|
| - base::Unretained(audio_manager()),
|
| + base::Unretained(audio_manager_.get()),
|
| &device_names));
|
| CheckDeviceNames(device_names);
|
| }
|
| @@ -197,8 +194,7 @@ TEST_F(AudioManagerTest, EnumerateOutputDevices) {
|
| // Override default enumeration API and force usage of Windows MMDevice.
|
| // This test will only run on Windows Vista and higher.
|
| TEST_F(AudioManagerTest, EnumerateInputDevicesWinMMDevice) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| if (!SetMMDeviceEnumeration()) {
|
| @@ -211,8 +207,7 @@ TEST_F(AudioManagerTest, EnumerateInputDevicesWinMMDevice) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, EnumerateOutputDevicesWinMMDevice) {
|
| - if (!CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(OutputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| if (!SetMMDeviceEnumeration()) {
|
| @@ -227,8 +222,7 @@ TEST_F(AudioManagerTest, EnumerateOutputDevicesWinMMDevice) {
|
| // Override default enumeration API and force usage of Windows Wave.
|
| // This test will run on Windows XP, Windows Vista and Windows 7.
|
| TEST_F(AudioManagerTest, EnumerateInputDevicesWinWave) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| SetWaveEnumeration();
|
| @@ -237,8 +231,7 @@ TEST_F(AudioManagerTest, EnumerateInputDevicesWinWave) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, EnumerateOutputDevicesWinWave) {
|
| - if (!CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(OutputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| SetWaveEnumeration();
|
| @@ -247,8 +240,7 @@ TEST_F(AudioManagerTest, EnumerateOutputDevicesWinWave) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, WinXPDeviceIdUnchanged) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| AudioDeviceNames xp_device_names;
|
| SetWaveEnumeration();
|
| @@ -264,8 +256,7 @@ TEST_F(AudioManagerTest, WinXPDeviceIdUnchanged) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, ConvertToWinXPInputDeviceId) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| if (!SetMMDeviceEnumeration()) {
|
| // Usage of MMDevice will fail on XP and lower.
|
| @@ -301,8 +292,7 @@ TEST_F(AudioManagerTest, ConvertToWinXPInputDeviceId) {
|
| // test Pulseaudio.
|
|
|
| TEST_F(AudioManagerTest, EnumerateInputDevicesPulseaudio) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| CreateAudioManagerForTesting<AudioManagerPulse>();
|
| if (audio_manager_.get()) {
|
| @@ -315,8 +305,7 @@ TEST_F(AudioManagerTest, EnumerateInputDevicesPulseaudio) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, EnumerateOutputDevicesPulseaudio) {
|
| - if (!CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(OutputDevicesAvailable());
|
|
|
| CreateAudioManagerForTesting<AudioManagerPulse>();
|
| if (audio_manager_.get()) {
|
| @@ -335,8 +324,7 @@ TEST_F(AudioManagerTest, EnumerateOutputDevicesPulseaudio) {
|
| // test Alsa.
|
|
|
| TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) {
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| DVLOG(2) << "Testing AudioManagerAlsa.";
|
| CreateAudioManagerForTesting<AudioManagerAlsa>();
|
| @@ -346,8 +334,7 @@ TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) {
|
| }
|
|
|
| TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) {
|
| - if (!CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(OutputDevicesAvailable());
|
|
|
| DVLOG(2) << "Testing AudioManagerAlsa.";
|
| CreateAudioManagerForTesting<AudioManagerAlsa>();
|
| @@ -359,8 +346,7 @@ TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) {
|
|
|
| TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) {
|
| #if defined(OS_WIN) || defined(OS_MACOSX)
|
| - if (!CanRunInputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable());
|
|
|
| AudioParameters params = audio_manager_->GetDefaultOutputStreamParameters();
|
| EXPECT_TRUE(params.IsValid());
|
| @@ -369,8 +355,7 @@ TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) {
|
|
|
| TEST_F(AudioManagerTest, GetAssociatedOutputDeviceID) {
|
| #if defined(OS_WIN) || defined(OS_MACOSX)
|
| - if (!CanRunInputTest() || !CanRunOutputTest())
|
| - return;
|
| + CAN_RUN_AUDIO_TEST_IF(InputDevicesAvailable() && OutputDevicesAvailable());
|
|
|
| AudioDeviceNames device_names;
|
| audio_manager_->GetAudioInputDeviceNames(&device_names);
|
|
|