| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/environment.h" | 6 #include "base/environment.h" |
| 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 "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 scoped_ptr<PCMWaveInAudioInputStream> stream( | 75 scoped_ptr<PCMWaveInAudioInputStream> stream( |
| 76 static_cast<PCMWaveInAudioInputStream*>( | 76 static_cast<PCMWaveInAudioInputStream*>( |
| 77 amw->CreatePCMWaveInAudioInputStream(parameters, device_id))); | 77 amw->CreatePCMWaveInAudioInputStream(parameters, device_id))); |
| 78 return stream.get() ? stream->device_id_ : std::string(); | 78 return stream.get() ? stream->device_id_ : std::string(); |
| 79 } | 79 } |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 // Helper method which verifies that the device list starts with a valid | 82 // Helper method which verifies that the device list starts with a valid |
| 83 // default record followed by non-default device names. | 83 // default record followed by non-default device names. |
| 84 static void CheckDeviceNames(const AudioDeviceNames& device_names) { | 84 static void CheckDeviceNames(const AudioDeviceNames& device_names) { |
| 85 VLOG(2) << "Got " << device_names.size() << " audio devices."; | 85 DVLOG(2) << "Got " << device_names.size() << " audio devices."; |
| 86 if (!device_names.empty()) { | 86 if (!device_names.empty()) { |
| 87 AudioDeviceNames::const_iterator it = device_names.begin(); | 87 AudioDeviceNames::const_iterator it = device_names.begin(); |
| 88 | 88 |
| 89 // The first device in the list should always be the default device. | 89 // The first device in the list should always be the default device. |
| 90 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), | 90 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), |
| 91 it->device_name); | 91 it->device_name); |
| 92 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); | 92 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); |
| 93 ++it; | 93 ++it; |
| 94 | 94 |
| 95 // Other devices should have non-empty name and id and should not contain | 95 // Other devices should have non-empty name and id and should not contain |
| 96 // default name or id. | 96 // default name or id. |
| 97 while (it != device_names.end()) { | 97 while (it != device_names.end()) { |
| 98 EXPECT_FALSE(it->device_name.empty()); | 98 EXPECT_FALSE(it->device_name.empty()); |
| 99 EXPECT_FALSE(it->unique_id.empty()); | 99 EXPECT_FALSE(it->unique_id.empty()); |
| 100 VLOG(2) << "Device ID(" << it->unique_id | 100 DVLOG(2) << "Device ID(" << it->unique_id |
| 101 << "), label: " << it->device_name; | 101 << "), label: " << it->device_name; |
| 102 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), | 102 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), |
| 103 it->device_name); | 103 it->device_name); |
| 104 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), | 104 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), |
| 105 it->unique_id); | 105 it->unique_id); |
| 106 ++it; | 106 ++it; |
| 107 } | 107 } |
| 108 } else { | 108 } else { |
| 109 // Log a warning so we can see the status on the build bots. No need to | 109 // Log a warning so we can see the status on the build bots. No need to |
| 110 // break the test though since this does successfully test the code and | 110 // break the test though since this does successfully test the code and |
| 111 // some failure cases. | 111 // some failure cases. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 #if defined(USE_ALSA) | 332 #if defined(USE_ALSA) |
| 333 // On Linux, there are two implementations available and both can | 333 // On Linux, there are two implementations available and both can |
| 334 // sometimes be tested on a single system. These tests specifically | 334 // sometimes be tested on a single system. These tests specifically |
| 335 // test Alsa. | 335 // test Alsa. |
| 336 | 336 |
| 337 TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) { | 337 TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) { |
| 338 if (!CanRunInputTest()) | 338 if (!CanRunInputTest()) |
| 339 return; | 339 return; |
| 340 | 340 |
| 341 VLOG(2) << "Testing AudioManagerAlsa."; | 341 DVLOG(2) << "Testing AudioManagerAlsa."; |
| 342 CreateAudioManagerForTesting<AudioManagerAlsa>(); | 342 CreateAudioManagerForTesting<AudioManagerAlsa>(); |
| 343 AudioDeviceNames device_names; | 343 AudioDeviceNames device_names; |
| 344 audio_manager_->GetAudioInputDeviceNames(&device_names); | 344 audio_manager_->GetAudioInputDeviceNames(&device_names); |
| 345 CheckDeviceNames(device_names); | 345 CheckDeviceNames(device_names); |
| 346 } | 346 } |
| 347 | 347 |
| 348 TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) { | 348 TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) { |
| 349 if (!CanRunOutputTest()) | 349 if (!CanRunOutputTest()) |
| 350 return; | 350 return; |
| 351 | 351 |
| 352 VLOG(2) << "Testing AudioManagerAlsa."; | 352 DVLOG(2) << "Testing AudioManagerAlsa."; |
| 353 CreateAudioManagerForTesting<AudioManagerAlsa>(); | 353 CreateAudioManagerForTesting<AudioManagerAlsa>(); |
| 354 AudioDeviceNames device_names; | 354 AudioDeviceNames device_names; |
| 355 audio_manager_->GetAudioOutputDeviceNames(&device_names); | 355 audio_manager_->GetAudioOutputDeviceNames(&device_names); |
| 356 CheckDeviceNames(device_names); | 356 CheckDeviceNames(device_names); |
| 357 } | 357 } |
| 358 #endif // defined(USE_ALSA) | 358 #endif // defined(USE_ALSA) |
| 359 | 359 |
| 360 TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) { | 360 TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) { |
| 361 #if defined(OS_WIN) || defined(OS_MACOSX) | 361 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 362 if (!CanRunInputTest()) | 362 if (!CanRunInputTest()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 376 audio_manager_->GetAudioInputDeviceNames(&device_names); | 376 audio_manager_->GetAudioInputDeviceNames(&device_names); |
| 377 bool found_an_associated_device = false; | 377 bool found_an_associated_device = false; |
| 378 for (AudioDeviceNames::iterator it = device_names.begin(); | 378 for (AudioDeviceNames::iterator it = device_names.begin(); |
| 379 it != device_names.end(); | 379 it != device_names.end(); |
| 380 ++it) { | 380 ++it) { |
| 381 EXPECT_FALSE(it->unique_id.empty()); | 381 EXPECT_FALSE(it->unique_id.empty()); |
| 382 EXPECT_FALSE(it->device_name.empty()); | 382 EXPECT_FALSE(it->device_name.empty()); |
| 383 std::string output_device_id( | 383 std::string output_device_id( |
| 384 audio_manager_->GetAssociatedOutputDeviceID(it->unique_id)); | 384 audio_manager_->GetAssociatedOutputDeviceID(it->unique_id)); |
| 385 if (!output_device_id.empty()) { | 385 if (!output_device_id.empty()) { |
| 386 VLOG(2) << it->unique_id << " matches with " << output_device_id; | 386 DVLOG(2) << it->unique_id << " matches with " << output_device_id; |
| 387 found_an_associated_device = true; | 387 found_an_associated_device = true; |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 EXPECT_TRUE(found_an_associated_device); | 391 EXPECT_TRUE(found_an_associated_device); |
| 392 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 392 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace media | 395 } // namespace media |
| OLD | NEW |