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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 DVLOG(2) << it->unique_id << " matches with " << output_device_id; | 633 DVLOG(2) << it->unique_id << " matches with " << output_device_id; |
634 found_an_associated_device = true; | 634 found_an_associated_device = true; |
635 } | 635 } |
636 } | 636 } |
637 | 637 |
638 EXPECT_TRUE(found_an_associated_device); | 638 EXPECT_TRUE(found_an_associated_device); |
639 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 639 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
640 } | 640 } |
641 #endif // defined(USE_CRAS) | 641 #endif // defined(USE_CRAS) |
642 | 642 |
643 class TestAudioManager : public FakeAudioManager { | |
644 // For testing the default implementation of GetGroupId(Input|Output) | |
645 // input$i is associated to output$i, if both exist. | |
646 // Default input is input1. | |
647 // Default output is output2. | |
648 public: | |
649 TestAudioManager( | |
650 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
651 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | |
652 AudioLogFactory* audio_log_factory) | |
653 : FakeAudioManager(task_runner, worker_task_runner, audio_log_factory) {} | |
654 | |
655 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override { | |
656 device_names->emplace_back("Input 1", "input1"); | |
657 device_names->emplace_back("Input 2", "input2"); | |
658 device_names->emplace_back("Input 3", "input3"); | |
659 device_names->push_front(AudioDeviceName::CreateDefault()); | |
660 } | |
661 | |
662 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override { | |
663 device_names->emplace_back("Output 1", "output1"); | |
664 device_names->emplace_back("Output 2", "output2"); | |
665 device_names->emplace_back("Output 4", "output4"); | |
666 device_names->push_front(AudioDeviceName::CreateDefault()); | |
667 } | |
668 | |
669 std::string GetDefaultOutputDeviceID() override { return "output4"; } | |
670 | |
671 std::string GetAssociatedOutputDeviceID( | |
672 const std::string& input_id) override { | |
673 if (input_id == "input1") | |
674 return "output1"; | |
675 else if (input_id == "input2") | |
tommi (sloooow) - chröme
2016/08/29 16:19:53
nit: 'else' isn't needed.
Max Morin
2016/08/30 08:17:45
Done.
| |
676 return "output2"; | |
677 else if (input_id == "default") | |
678 return "output1"; | |
679 return ""; | |
680 } | |
681 }; | |
682 | |
683 TEST_F(AudioManagerTest, GetGroupId) { | |
684 CreateAudioManagerForTesting<TestAudioManager>(); | |
685 // Groups: | |
686 // 0: input1, output1, default input | |
687 // 1: input2, output2 | |
688 // 2: input3, | |
689 // 3: output4, default output | |
690 std::vector<std::string> group; | |
691 group.push_back(audio_manager_->GetGroupIDInput("input1")); | |
692 group.push_back(audio_manager_->GetGroupIDInput("input2")); | |
693 group.push_back(audio_manager_->GetGroupIDInput("input3")); | |
694 group.push_back(audio_manager_->GetGroupIDOutput("output4")); | |
695 for (size_t i = 0; i < group.size(); ++i) { | |
696 for (size_t j = i + 1; j < group.size(); ++j) { | |
697 EXPECT_NE(group[i], group[j]); | |
698 } | |
699 } | |
700 EXPECT_EQ(group[0], audio_manager_->GetGroupIDOutput("output1")); | |
701 EXPECT_EQ(group[0], audio_manager_->GetGroupIDInput("default")); | |
702 EXPECT_EQ(group[1], audio_manager_->GetGroupIDOutput("output2")); | |
703 EXPECT_EQ(group[3], audio_manager_->GetGroupIDOutput("default")); | |
704 } | |
705 | |
643 } // namespace media | 706 } // namespace media |
OLD | NEW |