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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "media/audio/audio_io.h" | 9 #include "media/audio/audio_io.h" |
10 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
| 11 #include "media/audio/audio_unittest_utils.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
14 #include "base/win/scoped_com_initializer.h" | 15 #include "base/win/scoped_com_initializer.h" |
15 #include "media/audio/win/core_audio_util_win.h" | 16 #include "media/audio/win/core_audio_util_win.h" |
16 #endif | 17 #endif |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 double GetVolumeAfterSetVolumeOnLinux(AudioInputStream* ais, | 21 double GetVolumeAfterSetVolumeOnLinux(AudioInputStream* ais, |
(...skipping 17 matching lines...) Expand all Loading... |
38 class AudioInputVolumeTest : public ::testing::Test { | 39 class AudioInputVolumeTest : public ::testing::Test { |
39 protected: | 40 protected: |
40 AudioInputVolumeTest() | 41 AudioInputVolumeTest() |
41 : audio_manager_(AudioManager::CreateForTesting()) | 42 : audio_manager_(AudioManager::CreateForTesting()) |
42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
43 , com_init_(base::win::ScopedCOMInitializer::kMTA) | 44 , com_init_(base::win::ScopedCOMInitializer::kMTA) |
44 #endif | 45 #endif |
45 { | 46 { |
46 } | 47 } |
47 | 48 |
48 bool CanRunAudioTests() { | 49 bool HasCoreAudioAndInputDevices() { |
49 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
50 // TODO(henrika): add support for volume control on Windows XP as well. | 51 // TODO(henrika): add support for volume control on Windows XP as well. |
51 // For now, we might as well signal false already here to avoid running | 52 if (!CoreAudioUtils::IsSupported()) |
52 // these tests on Windows XP. | |
53 if (!CoreAudioUtil::IsSupported()) | |
54 return false; | 53 return false; |
55 #endif | 54 #endif |
56 if (!audio_manager_) | |
57 return false; | |
58 | |
59 return audio_manager_->HasAudioInputDevices(); | 55 return audio_manager_->HasAudioInputDevices(); |
60 } | 56 } |
61 | 57 |
62 // Helper method which checks if the stream has volume support. | 58 // Helper method which checks if the stream has volume support. |
63 bool HasDeviceVolumeControl(AudioInputStream* stream) { | 59 bool HasDeviceVolumeControl(AudioInputStream* stream) { |
64 if (!stream) | 60 if (!stream) |
65 return false; | 61 return false; |
66 | 62 |
67 return (stream->GetMaxVolume() != 0.0); | 63 return (stream->GetMaxVolume() != 0.0); |
68 } | 64 } |
(...skipping 30 matching lines...) Expand all Loading... |
99 | 95 |
100 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 96 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
101 // Currently failing on linux ARM bot: http://crbug/238490 | 97 // Currently failing on linux ARM bot: http://crbug/238490 |
102 // Also flaky on x86_64: http://crbug/236936 | 98 // Also flaky on x86_64: http://crbug/236936 |
103 #define MAYBE_InputVolumeTest DISABLED_InputVolumeTest | 99 #define MAYBE_InputVolumeTest DISABLED_InputVolumeTest |
104 #else | 100 #else |
105 #define MAYBE_InputVolumeTest InputVolumeTest | 101 #define MAYBE_InputVolumeTest InputVolumeTest |
106 #endif | 102 #endif |
107 | 103 |
108 TEST_F(AudioInputVolumeTest, MAYBE_InputVolumeTest) { | 104 TEST_F(AudioInputVolumeTest, MAYBE_InputVolumeTest) { |
109 if (!CanRunAudioTests()) | 105 ABORT_AUDIO_TEST_IF_NOT(HasCoreAudioAndInputDevices()); |
110 return; | |
111 | 106 |
112 // Retrieve a list of all available input devices. | 107 // Retrieve a list of all available input devices. |
113 AudioDeviceNames device_names; | 108 AudioDeviceNames device_names; |
114 audio_manager_->GetAudioInputDeviceNames(&device_names); | 109 audio_manager_->GetAudioInputDeviceNames(&device_names); |
115 if (device_names.empty()) { | 110 if (device_names.empty()) { |
116 LOG(WARNING) << "Could not find any available input device"; | 111 LOG(WARNING) << "Could not find any available input device"; |
117 return; | 112 return; |
118 } | 113 } |
119 | 114 |
120 // Scan all available input devices and repeat the same test for all of them. | 115 // Scan all available input devices and repeat the same test for all of them. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Restores the volume to the original value. | 171 // Restores the volume to the original value. |
177 ais->SetVolume(original_volume); | 172 ais->SetVolume(original_volume); |
178 current_volume = ais->GetVolume(); | 173 current_volume = ais->GetVolume(); |
179 EXPECT_EQ(original_volume, current_volume); | 174 EXPECT_EQ(original_volume, current_volume); |
180 | 175 |
181 ais->Close(); | 176 ais->Close(); |
182 } | 177 } |
183 } | 178 } |
184 | 179 |
185 } // namespace media | 180 } // namespace media |
OLD | NEW |