OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/win/scoped_com_initializer.h" | |
9 #include "media/audio/audio_io.h" | 8 #include "media/audio/audio_io.h" |
10 #include "media/audio/audio_manager_base.h" | 9 #include "media/audio/audio_manager_base.h" |
11 #include "media/audio/audio_util.h" | 10 #include "media/audio/audio_util.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 | 12 |
14 using base::win::ScopedCOMInitializer; | 13 #if defined(OS_WIN) |
| 14 #include "base/win/scoped_com_initializer.h" |
| 15 #endif |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class AudioInputVolumeTest : public ::testing::Test { | 19 class AudioInputVolumeTest : public ::testing::Test { |
19 protected: | 20 protected: |
20 AudioInputVolumeTest() | 21 AudioInputVolumeTest() |
21 : audio_manager_(AudioManager::Create()), | 22 : audio_manager_(AudioManager::Create()) |
22 com_init_(ScopedCOMInitializer::kMTA) { | 23 #if defined(OS_WIN) |
| 24 , com_init_(base::win::ScopedCOMInitializer::kMTA) |
| 25 #endif |
| 26 { |
23 } | 27 } |
24 | 28 |
25 bool CanRunAudioTests() { | 29 bool CanRunAudioTests() { |
26 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
27 // TODO(henrika): add support for volume control on Windows XP as well. | 31 // TODO(henrika): add support for volume control on Windows XP as well. |
28 // For now, we might as well signal false already here to avoid running | 32 // For now, we might as well signal false already here to avoid running |
29 // these tests on Windows XP. | 33 // these tests on Windows XP. |
30 if (!media::IsWASAPISupported()) | 34 if (!media::IsWASAPISupported()) |
31 return false; | 35 return false; |
32 #endif | 36 #endif |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 ais = NULL; | 84 ais = NULL; |
81 } | 85 } |
82 #elif defined(OS_WIN) || defined(OS_MACOSX) | 86 #elif defined(OS_WIN) || defined(OS_MACOSX) |
83 EXPECT_TRUE(ais->Open()); | 87 EXPECT_TRUE(ais->Open()); |
84 #endif | 88 #endif |
85 | 89 |
86 return ais; | 90 return ais; |
87 } | 91 } |
88 | 92 |
89 scoped_ptr<AudioManager> audio_manager_; | 93 scoped_ptr<AudioManager> audio_manager_; |
90 ScopedCOMInitializer com_init_; | 94 |
| 95 #if defined(OS_WIN) |
| 96 base::win::ScopedCOMInitializer com_init_; |
| 97 #endif |
91 }; | 98 }; |
92 | 99 |
93 TEST_F(AudioInputVolumeTest, InputVolumeTest) { | 100 TEST_F(AudioInputVolumeTest, InputVolumeTest) { |
94 if (!CanRunAudioTests()) | 101 if (!CanRunAudioTests()) |
95 return; | 102 return; |
96 | 103 |
97 // Retrieve a list of all available input devices. | 104 // Retrieve a list of all available input devices. |
98 AudioDeviceNames device_names; | 105 AudioDeviceNames device_names; |
99 audio_manager_->GetAudioInputDeviceNames(&device_names); | 106 audio_manager_->GetAudioInputDeviceNames(&device_names); |
100 if (device_names.empty()) { | 107 if (device_names.empty()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Restores the volume to the original value. | 160 // Restores the volume to the original value. |
154 ais->SetVolume(original_volume); | 161 ais->SetVolume(original_volume); |
155 current_volume = ais->GetVolume(); | 162 current_volume = ais->GetVolume(); |
156 EXPECT_EQ(original_volume, current_volume); | 163 EXPECT_EQ(original_volume, current_volume); |
157 | 164 |
158 ais->Close(); | 165 ais->Close(); |
159 } | 166 } |
160 } | 167 } |
161 | 168 |
162 } // namespace media | 169 } // namespace media |
OLD | NEW |