| 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 "media/audio/audio_manager.h" | 5 #include "media/audio/audio_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/environment.h" | 11 #include "base/environment.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/test/test_message_loop.h" | 17 #include "base/test/test_message_loop.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "media/audio/audio_device_description.h" | 20 #include "media/audio/audio_device_description.h" |
| 21 #include "media/audio/audio_device_info_accessor_for_tests.h" |
| 21 #include "media/audio/audio_device_name.h" | 22 #include "media/audio/audio_device_name.h" |
| 22 #include "media/audio/audio_output_proxy.h" | 23 #include "media/audio/audio_output_proxy.h" |
| 23 #include "media/audio/audio_unittest_util.h" | 24 #include "media/audio/audio_unittest_util.h" |
| 24 #include "media/audio/fake_audio_log_factory.h" | 25 #include "media/audio/fake_audio_log_factory.h" |
| 25 #include "media/audio/fake_audio_manager.h" | 26 #include "media/audio/fake_audio_manager.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 #if defined(USE_ALSA) | 30 #if defined(USE_ALSA) |
| 30 #include "media/audio/alsa/audio_manager_alsa.h" | 31 #include "media/audio/alsa/audio_manager_alsa.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 stream->Close(); | 197 stream->Close(); |
| 197 | 198 |
| 198 // Create a non-default device and ensure it gets a different dispatcher. | 199 // Create a non-default device and ensure it gets a different dispatcher. |
| 199 stream = audio_manager_->MakeAudioOutputStreamProxy(params, "123456"); | 200 stream = audio_manager_->MakeAudioOutputStreamProxy(params, "123456"); |
| 200 ASSERT_NE(dispatcher1, reinterpret_cast<AudioOutputProxy*>(stream) | 201 ASSERT_NE(dispatcher1, reinterpret_cast<AudioOutputProxy*>(stream) |
| 201 ->get_dispatcher_for_testing()); | 202 ->get_dispatcher_for_testing()); |
| 202 stream->Close(); | 203 stream->Close(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 void GetDefaultOutputStreamParameters(media::AudioParameters* params) { | 206 void GetDefaultOutputStreamParameters(media::AudioParameters* params) { |
| 206 *params = audio_manager_->GetDefaultOutputStreamParameters(); | 207 *params = device_info_accessor_->GetDefaultOutputStreamParameters(); |
| 207 } | 208 } |
| 208 | 209 |
| 209 void GetAssociatedOutputDeviceID(const std::string& input_device_id, | 210 void GetAssociatedOutputDeviceID(const std::string& input_device_id, |
| 210 std::string* output_device_id) { | 211 std::string* output_device_id) { |
| 211 *output_device_id = | 212 *output_device_id = |
| 212 audio_manager_->GetAssociatedOutputDeviceID(input_device_id); | 213 device_info_accessor_->GetAssociatedOutputDeviceID(input_device_id); |
| 213 } | 214 } |
| 214 | 215 |
| 215 #if defined(USE_CRAS) | 216 #if defined(USE_CRAS) |
| 216 void TearDown() override { | 217 void TearDown() override { |
| 217 chromeos::CrasAudioHandler::Shutdown(); | 218 chromeos::CrasAudioHandler::Shutdown(); |
| 218 audio_pref_handler_ = nullptr; | 219 audio_pref_handler_ = nullptr; |
| 219 chromeos::DBusThreadManager::Shutdown(); | 220 chromeos::DBusThreadManager::Shutdown(); |
| 220 } | 221 } |
| 221 | 222 |
| 222 void SetUpCrasAudioHandlerWithTestingNodes(const AudioNodeList& audio_nodes) { | 223 void SetUpCrasAudioHandlerWithTestingNodes(const AudioNodeList& audio_nodes) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } else { | 313 } else { |
| 313 // Log a warning so we can see the status on the build bots. No need to | 314 // Log a warning so we can see the status on the build bots. No need to |
| 314 // break the test though since this does successfully test the code and | 315 // break the test though since this does successfully test the code and |
| 315 // some failure cases. | 316 // some failure cases. |
| 316 LOG(WARNING) << "No input devices detected"; | 317 LOG(WARNING) << "No input devices detected"; |
| 317 } | 318 } |
| 318 } | 319 } |
| 319 #endif // defined(USE_CRAS) | 320 #endif // defined(USE_CRAS) |
| 320 | 321 |
| 321 bool InputDevicesAvailable() { | 322 bool InputDevicesAvailable() { |
| 322 return audio_manager_->HasAudioInputDevices(); | 323 return device_info_accessor_->HasAudioInputDevices(); |
| 323 } | 324 } |
| 324 bool OutputDevicesAvailable() { | 325 bool OutputDevicesAvailable() { |
| 325 return audio_manager_->HasAudioOutputDevices(); | 326 return device_info_accessor_->HasAudioOutputDevices(); |
| 326 } | 327 } |
| 327 | 328 |
| 328 template <typename T = std::nullptr_t> | 329 template <typename T = std::nullptr_t> |
| 329 void CreateAudioManagerForTesting() { | 330 void CreateAudioManagerForTesting() { |
| 330 // Only one AudioManager may exist at a time, so destroy the one we're | 331 // Only one AudioManager may exist at a time, so destroy the one we're |
| 331 // currently holding before creating a new one. | 332 // currently holding before creating a new one. |
| 332 // Flush the message loop to run any shutdown tasks posted by AudioManager. | 333 // Flush the message loop to run any shutdown tasks posted by AudioManager. |
| 333 audio_manager_.reset(); | 334 audio_manager_.reset(); |
| 334 base::RunLoop().RunUntilIdle(); | 335 base::RunLoop().RunUntilIdle(); |
| 335 | 336 |
| 336 audio_manager_ = | 337 audio_manager_ = |
| 337 TestAudioManagerFactory<T>::Create(&fake_audio_log_factory_); | 338 TestAudioManagerFactory<T>::Create(&fake_audio_log_factory_); |
| 338 // A few AudioManager implementations post initialization tasks to | 339 // A few AudioManager implementations post initialization tasks to |
| 339 // audio thread. Flush the thread to ensure that |audio_manager_| is | 340 // audio thread. Flush the thread to ensure that |audio_manager_| is |
| 340 // initialized and ready to use before returning from this function. | 341 // initialized and ready to use before returning from this function. |
| 341 // TODO(alokp): We should perhaps do this in AudioManager::Create(). | 342 // TODO(alokp): We should perhaps do this in AudioManager::Create(). |
| 342 base::RunLoop().RunUntilIdle(); | 343 base::RunLoop().RunUntilIdle(); |
| 344 device_info_accessor_ = |
| 345 base::MakeUnique<AudioDeviceInfoAccessorForTests>(audio_manager_.get()); |
| 343 } | 346 } |
| 344 | 347 |
| 345 base::TestMessageLoop message_loop_; | 348 base::TestMessageLoop message_loop_; |
| 346 FakeAudioLogFactory fake_audio_log_factory_; | 349 FakeAudioLogFactory fake_audio_log_factory_; |
| 347 ScopedAudioManagerPtr audio_manager_; | 350 ScopedAudioManagerPtr audio_manager_; |
| 351 std::unique_ptr<AudioDeviceInfoAccessorForTests> device_info_accessor_; |
| 348 | 352 |
| 349 #if defined(USE_CRAS) | 353 #if defined(USE_CRAS) |
| 350 chromeos::CrasAudioHandler* cras_audio_handler_ = nullptr; // Not owned. | 354 chromeos::CrasAudioHandler* cras_audio_handler_ = nullptr; // Not owned. |
| 351 chromeos::FakeCrasAudioClient* audio_client_ = nullptr; // Not owned. | 355 chromeos::FakeCrasAudioClient* audio_client_ = nullptr; // Not owned. |
| 352 scoped_refptr<chromeos::AudioDevicesPrefHandlerStub> audio_pref_handler_; | 356 scoped_refptr<chromeos::AudioDevicesPrefHandlerStub> audio_pref_handler_; |
| 353 #endif // defined(USE_CRAS) | 357 #endif // defined(USE_CRAS) |
| 354 }; | 358 }; |
| 355 | 359 |
| 356 #if defined(USE_CRAS) | 360 #if defined(USE_CRAS) |
| 357 TEST_F(AudioManagerTest, EnumerateInputDevicesCras) { | 361 TEST_F(AudioManagerTest, EnumerateInputDevicesCras) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 372 expectation[kJabraMic1.id] = | 376 expectation[kJabraMic1.id] = |
| 373 cras_audio_handler_->GetDeviceFromId(kJabraMic1.id)->display_name; | 377 cras_audio_handler_->GetDeviceFromId(kJabraMic1.id)->display_name; |
| 374 expectation[kJabraMic2.id] = | 378 expectation[kJabraMic2.id] = |
| 375 cras_audio_handler_->GetDeviceFromId(kJabraMic2.id)->display_name; | 379 cras_audio_handler_->GetDeviceFromId(kJabraMic2.id)->display_name; |
| 376 expectation[kUSBCameraMic.id] = | 380 expectation[kUSBCameraMic.id] = |
| 377 cras_audio_handler_->GetDeviceFromId(kUSBCameraMic.id)->display_name; | 381 cras_audio_handler_->GetDeviceFromId(kUSBCameraMic.id)->display_name; |
| 378 | 382 |
| 379 DVLOG(2) << "Testing AudioManagerCras."; | 383 DVLOG(2) << "Testing AudioManagerCras."; |
| 380 CreateAudioManagerForTesting<AudioManagerCras>(); | 384 CreateAudioManagerForTesting<AudioManagerCras>(); |
| 381 AudioDeviceDescriptions device_descriptions; | 385 AudioDeviceDescriptions device_descriptions; |
| 382 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 386 device_info_accessor_->GetAudioInputDeviceDescriptions(&device_descriptions); |
| 383 CheckDeviceDescriptionsCras(device_descriptions, expectation); | 387 CheckDeviceDescriptionsCras(device_descriptions, expectation); |
| 384 } | 388 } |
| 385 | 389 |
| 386 TEST_F(AudioManagerTest, EnumerateOutputDevicesCras) { | 390 TEST_F(AudioManagerTest, EnumerateOutputDevicesCras) { |
| 387 // Setup the devices without internal mic, so that it doesn't exist | 391 // Setup the devices without internal mic, so that it doesn't exist |
| 388 // beamforming capable mic. | 392 // beamforming capable mic. |
| 389 AudioNodeList audio_nodes; | 393 AudioNodeList audio_nodes; |
| 390 audio_nodes.push_back(kJabraMic1); | 394 audio_nodes.push_back(kJabraMic1); |
| 391 audio_nodes.push_back(kJabraMic2); | 395 audio_nodes.push_back(kJabraMic2); |
| 392 audio_nodes.push_back(kUSBCameraMic); | 396 audio_nodes.push_back(kUSBCameraMic); |
| 393 audio_nodes.push_back(kHDMIOutput); | 397 audio_nodes.push_back(kHDMIOutput); |
| 394 audio_nodes.push_back(kJabraSpeaker1); | 398 audio_nodes.push_back(kJabraSpeaker1); |
| 395 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 399 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 396 | 400 |
| 397 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 401 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
| 398 | 402 |
| 399 // Setup expectation with physical devices. | 403 // Setup expectation with physical devices. |
| 400 std::map<uint64_t, std::string> expectation; | 404 std::map<uint64_t, std::string> expectation; |
| 401 expectation[kHDMIOutput.id] = | 405 expectation[kHDMIOutput.id] = |
| 402 cras_audio_handler_->GetDeviceFromId(kHDMIOutput.id)->display_name; | 406 cras_audio_handler_->GetDeviceFromId(kHDMIOutput.id)->display_name; |
| 403 expectation[kJabraSpeaker1.id] = | 407 expectation[kJabraSpeaker1.id] = |
| 404 cras_audio_handler_->GetDeviceFromId(kJabraSpeaker1.id)->display_name; | 408 cras_audio_handler_->GetDeviceFromId(kJabraSpeaker1.id)->display_name; |
| 405 | 409 |
| 406 DVLOG(2) << "Testing AudioManagerCras."; | 410 DVLOG(2) << "Testing AudioManagerCras."; |
| 407 CreateAudioManagerForTesting<AudioManagerCras>(); | 411 CreateAudioManagerForTesting<AudioManagerCras>(); |
| 408 AudioDeviceDescriptions device_descriptions; | 412 AudioDeviceDescriptions device_descriptions; |
| 409 audio_manager_->GetAudioOutputDeviceDescriptions(&device_descriptions); | 413 device_info_accessor_->GetAudioOutputDeviceDescriptions(&device_descriptions); |
| 410 CheckDeviceDescriptionsCras(device_descriptions, expectation); | 414 CheckDeviceDescriptionsCras(device_descriptions, expectation); |
| 411 } | 415 } |
| 412 #else // !defined(USE_CRAS) | 416 #else // !defined(USE_CRAS) |
| 413 | 417 |
| 414 TEST_F(AudioManagerTest, HandleDefaultDeviceIDs) { | 418 TEST_F(AudioManagerTest, HandleDefaultDeviceIDs) { |
| 415 // Use a fake manager so we can makeup device ids, this will still use the | 419 // Use a fake manager so we can makeup device ids, this will still use the |
| 416 // AudioManagerBase code. | 420 // AudioManagerBase code. |
| 417 CreateAudioManagerForTesting<FakeAudioManager>(); | 421 CreateAudioManagerForTesting<FakeAudioManager>(); |
| 418 HandleDefaultDeviceIDsTest(); | 422 HandleDefaultDeviceIDsTest(); |
| 419 base::RunLoop().RunUntilIdle(); | 423 base::RunLoop().RunUntilIdle(); |
| 420 } | 424 } |
| 421 | 425 |
| 422 // Test that devices can be enumerated. | 426 // Test that devices can be enumerated. |
| 423 TEST_F(AudioManagerTest, EnumerateInputDevices) { | 427 TEST_F(AudioManagerTest, EnumerateInputDevices) { |
| 424 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); | 428 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); |
| 425 | 429 |
| 426 AudioDeviceDescriptions device_descriptions; | 430 AudioDeviceDescriptions device_descriptions; |
| 427 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 431 device_info_accessor_->GetAudioInputDeviceDescriptions(&device_descriptions); |
| 428 CheckDeviceDescriptions(device_descriptions); | 432 CheckDeviceDescriptions(device_descriptions); |
| 429 } | 433 } |
| 430 | 434 |
| 431 // Test that devices can be enumerated. | 435 // Test that devices can be enumerated. |
| 432 TEST_F(AudioManagerTest, EnumerateOutputDevices) { | 436 TEST_F(AudioManagerTest, EnumerateOutputDevices) { |
| 433 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 437 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
| 434 | 438 |
| 435 AudioDeviceDescriptions device_descriptions; | 439 AudioDeviceDescriptions device_descriptions; |
| 436 audio_manager_->GetAudioOutputDeviceDescriptions(&device_descriptions); | 440 device_info_accessor_->GetAudioOutputDeviceDescriptions(&device_descriptions); |
| 437 CheckDeviceDescriptions(device_descriptions); | 441 CheckDeviceDescriptions(device_descriptions); |
| 438 } | 442 } |
| 439 | 443 |
| 440 // Run additional tests for Windows since enumeration can be done using | 444 // Run additional tests for Windows since enumeration can be done using |
| 441 // two different APIs. MMDevice is default for Vista and higher and Wave | 445 // two different APIs. MMDevice is default for Vista and higher and Wave |
| 442 // is default for XP and lower. | 446 // is default for XP and lower. |
| 443 #if defined(OS_WIN) | 447 #if defined(OS_WIN) |
| 444 | 448 |
| 445 // Override default enumeration API and force usage of Windows MMDevice. | 449 // Override default enumeration API and force usage of Windows MMDevice. |
| 446 // This test will only run on Windows Vista and higher. | 450 // This test will only run on Windows Vista and higher. |
| 447 TEST_F(AudioManagerTest, EnumerateInputDevicesWinMMDevice) { | 451 TEST_F(AudioManagerTest, EnumerateInputDevicesWinMMDevice) { |
| 448 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); | 452 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); |
| 449 | 453 |
| 450 AudioDeviceDescriptions device_descriptions; | 454 AudioDeviceDescriptions device_descriptions; |
| 451 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 455 device_info_accessor_->GetAudioInputDeviceDescriptions(&device_descriptions); |
| 452 CheckDeviceDescriptions(device_descriptions); | 456 CheckDeviceDescriptions(device_descriptions); |
| 453 } | 457 } |
| 454 | 458 |
| 455 TEST_F(AudioManagerTest, EnumerateOutputDevicesWinMMDevice) { | 459 TEST_F(AudioManagerTest, EnumerateOutputDevicesWinMMDevice) { |
| 456 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 460 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
| 457 | 461 |
| 458 AudioDeviceDescriptions device_descriptions; | 462 AudioDeviceDescriptions device_descriptions; |
| 459 audio_manager_->GetAudioOutputDeviceDescriptions(&device_descriptions); | 463 device_info_accessor_->GetAudioOutputDeviceDescriptions(&device_descriptions); |
| 460 CheckDeviceDescriptions(device_descriptions); | 464 CheckDeviceDescriptions(device_descriptions); |
| 461 } | 465 } |
| 462 #endif // defined(OS_WIN) | 466 #endif // defined(OS_WIN) |
| 463 | 467 |
| 464 #if defined(USE_PULSEAUDIO) | 468 #if defined(USE_PULSEAUDIO) |
| 465 // On Linux, there are two implementations available and both can | 469 // On Linux, there are two implementations available and both can |
| 466 // sometimes be tested on a single system. These tests specifically | 470 // sometimes be tested on a single system. These tests specifically |
| 467 // test Pulseaudio. | 471 // test Pulseaudio. |
| 468 | 472 |
| 469 TEST_F(AudioManagerTest, EnumerateInputDevicesPulseaudio) { | 473 TEST_F(AudioManagerTest, EnumerateInputDevicesPulseaudio) { |
| 470 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); | 474 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); |
| 471 | 475 |
| 472 CreateAudioManagerForTesting<AudioManagerPulse>(); | 476 CreateAudioManagerForTesting<AudioManagerPulse>(); |
| 473 if (audio_manager_.get()) { | 477 if (audio_manager_.get()) { |
| 474 AudioDeviceDescriptions device_descriptions; | 478 AudioDeviceDescriptions device_descriptions; |
| 475 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 479 device_info_accessor_->GetAudioInputDeviceDescriptions( |
| 480 &device_descriptions); |
| 476 CheckDeviceDescriptions(device_descriptions); | 481 CheckDeviceDescriptions(device_descriptions); |
| 477 } else { | 482 } else { |
| 478 LOG(WARNING) << "No pulseaudio on this system."; | 483 LOG(WARNING) << "No pulseaudio on this system."; |
| 479 } | 484 } |
| 480 } | 485 } |
| 481 | 486 |
| 482 TEST_F(AudioManagerTest, EnumerateOutputDevicesPulseaudio) { | 487 TEST_F(AudioManagerTest, EnumerateOutputDevicesPulseaudio) { |
| 483 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 488 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
| 484 | 489 |
| 485 CreateAudioManagerForTesting<AudioManagerPulse>(); | 490 CreateAudioManagerForTesting<AudioManagerPulse>(); |
| 486 if (audio_manager_.get()) { | 491 if (audio_manager_.get()) { |
| 487 AudioDeviceDescriptions device_descriptions; | 492 AudioDeviceDescriptions device_descriptions; |
| 488 audio_manager_->GetAudioOutputDeviceDescriptions(&device_descriptions); | 493 device_info_accessor_->GetAudioOutputDeviceDescriptions( |
| 494 &device_descriptions); |
| 489 CheckDeviceDescriptions(device_descriptions); | 495 CheckDeviceDescriptions(device_descriptions); |
| 490 } else { | 496 } else { |
| 491 LOG(WARNING) << "No pulseaudio on this system."; | 497 LOG(WARNING) << "No pulseaudio on this system."; |
| 492 } | 498 } |
| 493 } | 499 } |
| 494 #endif // defined(USE_PULSEAUDIO) | 500 #endif // defined(USE_PULSEAUDIO) |
| 495 | 501 |
| 496 #if defined(USE_ALSA) | 502 #if defined(USE_ALSA) |
| 497 // On Linux, there are two implementations available and both can | 503 // On Linux, there are two implementations available and both can |
| 498 // sometimes be tested on a single system. These tests specifically | 504 // sometimes be tested on a single system. These tests specifically |
| 499 // test Alsa. | 505 // test Alsa. |
| 500 | 506 |
| 501 TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) { | 507 TEST_F(AudioManagerTest, EnumerateInputDevicesAlsa) { |
| 502 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); | 508 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); |
| 503 | 509 |
| 504 DVLOG(2) << "Testing AudioManagerAlsa."; | 510 DVLOG(2) << "Testing AudioManagerAlsa."; |
| 505 CreateAudioManagerForTesting<AudioManagerAlsa>(); | 511 CreateAudioManagerForTesting<AudioManagerAlsa>(); |
| 506 AudioDeviceDescriptions device_descriptions; | 512 AudioDeviceDescriptions device_descriptions; |
| 507 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 513 device_info_accessor_->GetAudioInputDeviceDescriptions(&device_descriptions); |
| 508 CheckDeviceDescriptions(device_descriptions); | 514 CheckDeviceDescriptions(device_descriptions); |
| 509 } | 515 } |
| 510 | 516 |
| 511 TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) { | 517 TEST_F(AudioManagerTest, EnumerateOutputDevicesAlsa) { |
| 512 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 518 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
| 513 | 519 |
| 514 DVLOG(2) << "Testing AudioManagerAlsa."; | 520 DVLOG(2) << "Testing AudioManagerAlsa."; |
| 515 CreateAudioManagerForTesting<AudioManagerAlsa>(); | 521 CreateAudioManagerForTesting<AudioManagerAlsa>(); |
| 516 AudioDeviceDescriptions device_descriptions; | 522 AudioDeviceDescriptions device_descriptions; |
| 517 audio_manager_->GetAudioOutputDeviceDescriptions(&device_descriptions); | 523 device_info_accessor_->GetAudioOutputDeviceDescriptions(&device_descriptions); |
| 518 CheckDeviceDescriptions(device_descriptions); | 524 CheckDeviceDescriptions(device_descriptions); |
| 519 } | 525 } |
| 520 #endif // defined(USE_ALSA) | 526 #endif // defined(USE_ALSA) |
| 521 | 527 |
| 522 TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) { | 528 TEST_F(AudioManagerTest, GetDefaultOutputStreamParameters) { |
| 523 #if defined(OS_WIN) || defined(OS_MACOSX) | 529 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 524 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); | 530 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); |
| 525 | 531 |
| 526 AudioParameters params; | 532 AudioParameters params; |
| 527 GetDefaultOutputStreamParameters(¶ms); | 533 GetDefaultOutputStreamParameters(¶ms); |
| 528 EXPECT_TRUE(params.IsValid()); | 534 EXPECT_TRUE(params.IsValid()); |
| 529 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 535 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 530 } | 536 } |
| 531 | 537 |
| 532 TEST_F(AudioManagerTest, GetAssociatedOutputDeviceID) { | 538 TEST_F(AudioManagerTest, GetAssociatedOutputDeviceID) { |
| 533 #if defined(OS_WIN) || defined(OS_MACOSX) | 539 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 534 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable() && OutputDevicesAvailable()); | 540 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable() && OutputDevicesAvailable()); |
| 535 | 541 |
| 536 AudioDeviceDescriptions device_descriptions; | 542 AudioDeviceDescriptions device_descriptions; |
| 537 audio_manager_->GetAudioInputDeviceDescriptions(&device_descriptions); | 543 device_info_accessor_->GetAudioInputDeviceDescriptions(&device_descriptions); |
| 538 bool found_an_associated_device = false; | 544 bool found_an_associated_device = false; |
| 539 for (const auto& description : device_descriptions) { | 545 for (const auto& description : device_descriptions) { |
| 540 EXPECT_FALSE(description.unique_id.empty()); | 546 EXPECT_FALSE(description.unique_id.empty()); |
| 541 EXPECT_FALSE(description.device_name.empty()); | 547 EXPECT_FALSE(description.device_name.empty()); |
| 542 EXPECT_FALSE(description.group_id.empty()); | 548 EXPECT_FALSE(description.group_id.empty()); |
| 543 std::string output_device_id; | 549 std::string output_device_id; |
| 544 GetAssociatedOutputDeviceID(description.unique_id, &output_device_id); | 550 GetAssociatedOutputDeviceID(description.unique_id, &output_device_id); |
| 545 if (!output_device_id.empty()) { | 551 if (!output_device_id.empty()) { |
| 546 DVLOG(2) << description.unique_id << " matches with " << output_device_id; | 552 DVLOG(2) << description.unique_id << " matches with " << output_device_id; |
| 547 found_an_associated_device = true; | 553 found_an_associated_device = true; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 628 |
| 623 TEST_F(AudioManagerTest, GroupId) { | 629 TEST_F(AudioManagerTest, GroupId) { |
| 624 CreateAudioManagerForTesting<TestAudioManager>(); | 630 CreateAudioManagerForTesting<TestAudioManager>(); |
| 625 // Groups: | 631 // Groups: |
| 626 // input1, output1, default input | 632 // input1, output1, default input |
| 627 // input2, output2 | 633 // input2, output2 |
| 628 // input3, | 634 // input3, |
| 629 // output3 | 635 // output3 |
| 630 // output4, default output | 636 // output4, default output |
| 631 AudioDeviceDescriptions inputs; | 637 AudioDeviceDescriptions inputs; |
| 632 audio_manager_->GetAudioInputDeviceDescriptions(&inputs); | 638 device_info_accessor_->GetAudioInputDeviceDescriptions(&inputs); |
| 633 AudioDeviceDescriptions outputs; | 639 AudioDeviceDescriptions outputs; |
| 634 audio_manager_->GetAudioOutputDeviceDescriptions(&outputs); | 640 device_info_accessor_->GetAudioOutputDeviceDescriptions(&outputs); |
| 635 EXPECT_EQ(inputs[0].group_id, outputs[1].group_id); | 641 EXPECT_EQ(inputs[0].group_id, outputs[1].group_id); |
| 636 EXPECT_EQ(inputs[1].group_id, outputs[1].group_id); | 642 EXPECT_EQ(inputs[1].group_id, outputs[1].group_id); |
| 637 EXPECT_EQ(inputs[2].group_id, outputs[2].group_id); | 643 EXPECT_EQ(inputs[2].group_id, outputs[2].group_id); |
| 638 EXPECT_NE(inputs[3].group_id, outputs[3].group_id); | 644 EXPECT_NE(inputs[3].group_id, outputs[3].group_id); |
| 639 EXPECT_EQ(outputs[4].group_id, outputs[0].group_id); | 645 EXPECT_EQ(outputs[4].group_id, outputs[0].group_id); |
| 640 EXPECT_NE(inputs[0].group_id, outputs[0].group_id); | 646 EXPECT_NE(inputs[0].group_id, outputs[0].group_id); |
| 641 EXPECT_NE(inputs[1].group_id, outputs[2].group_id); | 647 EXPECT_NE(inputs[1].group_id, outputs[2].group_id); |
| 642 EXPECT_NE(inputs[2].group_id, outputs[3].group_id); | 648 EXPECT_NE(inputs[2].group_id, outputs[3].group_id); |
| 643 EXPECT_NE(inputs[1].group_id, outputs[3].group_id); | 649 EXPECT_NE(inputs[1].group_id, outputs[3].group_id); |
| 644 } | 650 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 664 | 670 |
| 665 base::FilePath file_path(FILE_PATH_LITERAL("path")); | 671 base::FilePath file_path(FILE_PATH_LITERAL("path")); |
| 666 EXPECT_CALL(*mock_debug_recording_manager, EnableDebugRecording(file_path)); | 672 EXPECT_CALL(*mock_debug_recording_manager, EnableDebugRecording(file_path)); |
| 667 audio_manager_->EnableOutputDebugRecording(file_path); | 673 audio_manager_->EnableOutputDebugRecording(file_path); |
| 668 | 674 |
| 669 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); | 675 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); |
| 670 audio_manager_->DisableOutputDebugRecording(); | 676 audio_manager_->DisableOutputDebugRecording(); |
| 671 } | 677 } |
| 672 | 678 |
| 673 } // namespace media | 679 } // namespace media |
| OLD | NEW |