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) | 10 #if defined(OS_LINUX) |
11 #include "media/audio/linux/audio_manager_linux.h" | |
11 #include "media/audio/pulse/audio_manager_pulse.h" | 12 #include "media/audio/pulse/audio_manager_pulse.h" |
12 #endif | 13 #endif // defined(OS_LINUX) |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 | 16 |
16 // TODO(joi): Remove guards once implemented for all platforms. | 17 void GetAudioOutputDeviceNamesImpl(AudioManager* audio_manager) { |
17 #if defined(OS_LINUX) | |
18 TEST(AudioManagerTest, GetAudioOutputDeviceNames) { | |
19 scoped_ptr<AudioManager> audio_manager_pulse(AudioManagerPulse::Create()); | |
20 if (!audio_manager_pulse) | |
21 return; | |
22 | |
23 AudioDeviceNames device_names; | 18 AudioDeviceNames device_names; |
24 audio_manager_pulse->GetAudioOutputDeviceNames(&device_names); | 19 audio_manager->GetAudioOutputDeviceNames(&device_names); |
25 | 20 |
26 VLOG(2) << "Got " << device_names.size() << " audio output devices."; | 21 VLOG(2) << "Got " << device_names.size() << " audio output devices."; |
27 for (AudioDeviceNames::iterator it = device_names.begin(); | 22 for (AudioDeviceNames::iterator it = device_names.begin(); |
28 it != device_names.end(); | 23 it != device_names.end(); |
29 ++it) { | 24 ++it) { |
30 EXPECT_FALSE(it->unique_id.empty()); | 25 EXPECT_FALSE(it->unique_id.empty()); |
31 EXPECT_FALSE(it->device_name.empty()); | 26 EXPECT_FALSE(it->device_name.empty()); |
32 VLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; | 27 VLOG(2) << "Device ID(" << it->unique_id << "), label: " << it->device_name; |
33 } | 28 } |
34 } | 29 } |
30 | |
31 TEST(AudioManagerTest, GetAudioOutputDeviceNames) { | |
32 #if defined(OS_LINUX) | |
33 { | |
34 VLOG(2) << "Testing AudioManagerPulse."; | |
35 scoped_ptr<AudioManager> pulse_audio_manager(AudioManagerPulse::Create()); | |
tommi (sloooow) - chröme
2013/09/04 13:43:29
What about:
scoped_ptr<AudioManager> audio_manager
Jói
2013/09/04 13:44:42
If I do that, I only get to test either pulseaudio
tommi (sloooow) - chröme
2013/09/04 14:32:51
OK, sounds good this way.
| |
36 if (pulse_audio_manager.get()) | |
37 GetAudioOutputDeviceNamesImpl(pulse_audio_manager.get()); | |
38 else | |
39 VLOG(2) << "No pulseaudio on this system."; | |
40 } | |
41 { | |
42 VLOG(2) << "Testing AudioManagerLinux."; | |
43 scoped_ptr<AudioManager> alsa_audio_manager(new AudioManagerLinux()); | |
44 GetAudioOutputDeviceNamesImpl(alsa_audio_manager.get()); | |
45 } | |
35 #endif // defined(OS_LINUX) | 46 #endif // defined(OS_LINUX) |
47 } | |
36 | 48 |
37 } // namespace media | 49 } // namespace media |
OLD | NEW |