OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "media/audio/audio_manager.h" | 7 #include "media/audio/audio_manager.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
| 10 #if defined(OS_LINUX) |
| 11 #include "media/audio/linux/audio_manager_linux.h" |
| 12 #endif // defined(OS_LINUX) |
| 13 |
10 #if defined(USE_PULSEAUDIO) | 14 #if defined(USE_PULSEAUDIO) |
11 #include "media/audio/pulse/audio_manager_pulse.h" | 15 #include "media/audio/pulse/audio_manager_pulse.h" |
12 #endif | 16 #endif // defined(USE_PULSEAUDIO) |
13 | 17 |
14 namespace media { | 18 namespace media { |
15 | 19 |
16 // TODO(joi): Remove guards once implemented for all platforms. | 20 void GetAudioOutputDeviceNamesImpl(AudioManager* audio_manager) { |
17 TEST(AudioManagerTest, GetAudioOutputDeviceNames) { | |
18 #if defined(USE_PULSEAUDIO) | |
19 scoped_ptr<AudioManager> audio_manager_pulse(AudioManagerPulse::Create()); | |
20 if (!audio_manager_pulse) | |
21 return; | |
22 | |
23 AudioDeviceNames device_names; | 21 AudioDeviceNames device_names; |
24 audio_manager_pulse->GetAudioOutputDeviceNames(&device_names); | 22 audio_manager->GetAudioOutputDeviceNames(&device_names); |
25 | 23 |
26 VLOG(2) << "Got " << device_names.size() << " audio output devices."; | 24 VLOG(2) << "Got " << device_names.size() << " audio output devices."; |
27 for (AudioDeviceNames::iterator it = device_names.begin(); | 25 for (AudioDeviceNames::iterator it = device_names.begin(); |
28 it != device_names.end(); | 26 it != device_names.end(); |
29 ++it) { | 27 ++it) { |
30 EXPECT_FALSE(it->unique_id.empty()); | 28 EXPECT_FALSE(it->unique_id.empty()); |
31 EXPECT_FALSE(it->device_name.empty()); | 29 EXPECT_FALSE(it->device_name.empty()); |
32 VLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; | 30 VLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; |
33 } | 31 } |
| 32 } |
| 33 |
| 34 TEST(AudioManagerTest, GetAudioOutputDeviceNames) { |
| 35 #if defined(USE_PULSEAUDIO) |
| 36 { |
| 37 VLOG(2) << "Testing AudioManagerPulse."; |
| 38 scoped_ptr<AudioManager> pulse_audio_manager(AudioManagerPulse::Create()); |
| 39 if (pulse_audio_manager.get()) |
| 40 GetAudioOutputDeviceNamesImpl(pulse_audio_manager.get()); |
| 41 else |
| 42 LOG(WARNING) << "No pulseaudio on this system."; |
| 43 } |
34 #endif // defined(USE_PULSEAUDIO) | 44 #endif // defined(USE_PULSEAUDIO) |
| 45 #if defined(USE_ALSA) |
| 46 { |
| 47 VLOG(2) << "Testing AudioManagerLinux."; |
| 48 scoped_ptr<AudioManager> alsa_audio_manager(new AudioManagerLinux()); |
| 49 GetAudioOutputDeviceNamesImpl(alsa_audio_manager.get()); |
| 50 } |
| 51 #endif // defined(USE_ALSA) |
35 } | 52 } |
36 | 53 |
37 } // namespace media | 54 } // namespace media |
OLD | NEW |