| 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" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 563 |
| 564 EXPECT_TRUE(found_an_associated_device); | 564 EXPECT_TRUE(found_an_associated_device); |
| 565 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 565 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 566 } | 566 } |
| 567 #endif // defined(USE_CRAS) | 567 #endif // defined(USE_CRAS) |
| 568 | 568 |
| 569 // Mock class to verify enable and disable debug recording calls. | 569 // Mock class to verify enable and disable debug recording calls. |
| 570 class MockAudioDebugRecordingManager : public AudioDebugRecordingManager { | 570 class MockAudioDebugRecordingManager : public AudioDebugRecordingManager { |
| 571 public: | 571 public: |
| 572 MockAudioDebugRecordingManager( | 572 MockAudioDebugRecordingManager( |
| 573 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 573 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 574 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 574 : AudioDebugRecordingManager(std::move(task_runner)) {} |
| 575 : AudioDebugRecordingManager(std::move(task_runner), | |
| 576 std::move(file_task_runner)) {} | |
| 577 | 575 |
| 578 ~MockAudioDebugRecordingManager() override {} | 576 ~MockAudioDebugRecordingManager() override {} |
| 579 | 577 |
| 580 MOCK_METHOD1(EnableDebugRecording, void(const base::FilePath&)); | 578 MOCK_METHOD1(EnableDebugRecording, void(const base::FilePath&)); |
| 581 MOCK_METHOD0(DisableDebugRecording, void()); | 579 MOCK_METHOD0(DisableDebugRecording, void()); |
| 582 | 580 |
| 583 private: | 581 private: |
| 584 DISALLOW_COPY_AND_ASSIGN(MockAudioDebugRecordingManager); | 582 DISALLOW_COPY_AND_ASSIGN(MockAudioDebugRecordingManager); |
| 585 }; | 583 }; |
| 586 | 584 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 617 | 615 |
| 618 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override { | 616 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override { |
| 619 device_names->emplace_back("Output 1", "output1"); | 617 device_names->emplace_back("Output 1", "output1"); |
| 620 device_names->emplace_back("Output 2", "output2"); | 618 device_names->emplace_back("Output 2", "output2"); |
| 621 device_names->emplace_back("Output 3", "output3"); | 619 device_names->emplace_back("Output 3", "output3"); |
| 622 device_names->emplace_back("Output 4", "output4"); | 620 device_names->emplace_back("Output 4", "output4"); |
| 623 device_names->push_front(AudioDeviceName::CreateDefault()); | 621 device_names->push_front(AudioDeviceName::CreateDefault()); |
| 624 } | 622 } |
| 625 | 623 |
| 626 std::unique_ptr<AudioDebugRecordingManager> CreateAudioDebugRecordingManager( | 624 std::unique_ptr<AudioDebugRecordingManager> CreateAudioDebugRecordingManager( |
| 627 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 625 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override { |
| 628 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) override { | |
| 629 return base::MakeUnique<MockAudioDebugRecordingManager>( | 626 return base::MakeUnique<MockAudioDebugRecordingManager>( |
| 630 std::move(task_runner), std::move(file_task_runner)); | 627 std::move(task_runner)); |
| 631 } | 628 } |
| 632 }; | 629 }; |
| 633 | 630 |
| 634 TEST_F(AudioManagerTest, GroupId) { | 631 TEST_F(AudioManagerTest, GroupId) { |
| 635 CreateAudioManagerForTesting<TestAudioManager>(); | 632 CreateAudioManagerForTesting<TestAudioManager>(); |
| 636 // Groups: | 633 // Groups: |
| 637 // input1, output1, default input | 634 // input1, output1, default input |
| 638 // input2, output2 | 635 // input2, output2 |
| 639 // input3, | 636 // input3, |
| 640 // output3 | 637 // output3 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 655 } | 652 } |
| 656 | 653 |
| 657 TEST_F(AudioManagerTest, AudioDebugRecording) { | 654 TEST_F(AudioManagerTest, AudioDebugRecording) { |
| 658 CreateAudioManagerForTesting<TestAudioManager>(); | 655 CreateAudioManagerForTesting<TestAudioManager>(); |
| 659 | 656 |
| 660 AudioManagerBase* audio_manager_base = | 657 AudioManagerBase* audio_manager_base = |
| 661 static_cast<AudioManagerBase*>(audio_manager_.get()); | 658 static_cast<AudioManagerBase*>(audio_manager_.get()); |
| 662 | 659 |
| 663 // Initialize is normally done in AudioManager::Create(), but since we don't | 660 // Initialize is normally done in AudioManager::Create(), but since we don't |
| 664 // use that in this test, we need to initialize here. | 661 // use that in this test, we need to initialize here. |
| 665 audio_manager_->InitializeOutputDebugRecording( | 662 audio_manager_->InitializeOutputDebugRecording(); |
| 666 audio_manager_->GetTaskRunner()); | |
| 667 | 663 |
| 668 MockAudioDebugRecordingManager* mock_debug_recording_manager = | 664 MockAudioDebugRecordingManager* mock_debug_recording_manager = |
| 669 static_cast<MockAudioDebugRecordingManager*>( | 665 static_cast<MockAudioDebugRecordingManager*>( |
| 670 audio_manager_base->debug_recording_manager_.get()); | 666 audio_manager_base->debug_recording_manager_.get()); |
| 671 ASSERT_TRUE(mock_debug_recording_manager); | 667 ASSERT_TRUE(mock_debug_recording_manager); |
| 672 | 668 |
| 673 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); | 669 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); |
| 674 audio_manager_->DisableOutputDebugRecording(); | 670 audio_manager_->DisableOutputDebugRecording(); |
| 675 | 671 |
| 676 base::FilePath file_path(FILE_PATH_LITERAL("path")); | 672 base::FilePath file_path(FILE_PATH_LITERAL("path")); |
| 677 EXPECT_CALL(*mock_debug_recording_manager, EnableDebugRecording(file_path)); | 673 EXPECT_CALL(*mock_debug_recording_manager, EnableDebugRecording(file_path)); |
| 678 audio_manager_->EnableOutputDebugRecording(file_path); | 674 audio_manager_->EnableOutputDebugRecording(file_path); |
| 679 | 675 |
| 680 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); | 676 EXPECT_CALL(*mock_debug_recording_manager, DisableDebugRecording()); |
| 681 audio_manager_->DisableOutputDebugRecording(); | 677 audio_manager_->DisableOutputDebugRecording(); |
| 682 } | 678 } |
| 683 | 679 |
| 684 } // namespace media | 680 } // namespace media |
| OLD | NEW |