OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_audio_controller_chromeos.h" | 5 #include "extensions/shell/browser/shell_audio_controller_chromeos.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "chromeos/audio/audio_device.h" | 8 #include "chromeos/audio/audio_device.h" |
9 #include "chromeos/audio/cras_audio_handler.h" | 9 #include "chromeos/audio/cras_audio_handler.h" |
10 #include "chromeos/dbus/audio_node.h" | 10 #include "chromeos/dbus/audio_node.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // AudioDevice gives the headphone jack a higher priority than the internal | 91 // AudioDevice gives the headphone jack a higher priority than the internal |
92 // speaker and an external mic a higher priority than the internal mic, so we | 92 // speaker and an external mic a higher priority than the internal mic, so we |
93 // should start out favoring headphones and the external mic. | 93 // should start out favoring headphones and the external mic. |
94 AudioNodeList all_nodes; | 94 AudioNodeList all_nodes; |
95 all_nodes.push_back(internal_speaker); | 95 all_nodes.push_back(internal_speaker); |
96 all_nodes.push_back(internal_mic); | 96 all_nodes.push_back(internal_mic); |
97 all_nodes.push_back(headphone); | 97 all_nodes.push_back(headphone); |
98 all_nodes.push_back(external_mic); | 98 all_nodes.push_back(external_mic); |
99 audio_client_->SetAudioNodesAndNotifyObserversForTesting(all_nodes); | 99 audio_client_->SetAudioNodesAndNotifyObserversForTesting(all_nodes); |
100 EXPECT_EQ(headphone.id, audio_handler_->GetActiveOutputNode()); | 100 EXPECT_EQ(headphone.id, audio_handler_->GetPrimaryActiveOutputNode()); |
101 EXPECT_EQ(external_mic.id, audio_handler_->GetActiveInputNode()); | 101 EXPECT_EQ(external_mic.id, audio_handler_->GetPrimaryActiveInputNode()); |
102 | 102 |
103 // Unplug the headphones and mic and check that we switch to the internal | 103 // Unplug the headphones and mic and check that we switch to the internal |
104 // devices. | 104 // devices. |
105 AudioNodeList internal_nodes; | 105 AudioNodeList internal_nodes; |
106 internal_nodes.push_back(internal_speaker); | 106 internal_nodes.push_back(internal_speaker); |
107 internal_nodes.push_back(internal_mic); | 107 internal_nodes.push_back(internal_mic); |
108 audio_client_->SetAudioNodesAndNotifyObserversForTesting(internal_nodes); | 108 audio_client_->SetAudioNodesAndNotifyObserversForTesting(internal_nodes); |
109 EXPECT_EQ(internal_speaker.id, audio_handler_->GetActiveOutputNode()); | 109 EXPECT_EQ(internal_speaker.id, audio_handler_->GetPrimaryActiveOutputNode()); |
110 EXPECT_EQ(internal_mic.id, audio_handler_->GetActiveInputNode()); | 110 EXPECT_EQ(internal_mic.id, audio_handler_->GetPrimaryActiveInputNode()); |
111 | 111 |
112 // Switch back to the external devices. Mark the previously-activated internal | 112 // Switch back to the external devices. Mark the previously-activated internal |
113 // devices as being active so CrasAudioHandler doesn't complain. | 113 // devices as being active so CrasAudioHandler doesn't complain. |
114 SetNodeActive(&all_nodes, internal_speaker.id, true); | 114 SetNodeActive(&all_nodes, internal_speaker.id, true); |
115 SetNodeActive(&all_nodes, internal_mic.id, true); | 115 SetNodeActive(&all_nodes, internal_mic.id, true); |
116 audio_client_->SetAudioNodesAndNotifyObserversForTesting(all_nodes); | 116 audio_client_->SetAudioNodesAndNotifyObserversForTesting(all_nodes); |
117 EXPECT_EQ(headphone.id, audio_handler_->GetActiveOutputNode()); | 117 EXPECT_EQ(headphone.id, audio_handler_->GetPrimaryActiveOutputNode()); |
118 EXPECT_EQ(external_mic.id, audio_handler_->GetActiveInputNode()); | 118 EXPECT_EQ(external_mic.id, audio_handler_->GetPrimaryActiveInputNode()); |
119 } | 119 } |
120 | 120 |
121 // Tests that active audio devices are unmuted and set to 100% volume. | 121 // Tests that active audio devices are unmuted and set to 100% volume. |
122 TEST_F(ShellAudioControllerTest, MaxVolume) { | 122 TEST_F(ShellAudioControllerTest, MaxVolume) { |
123 AudioNodeList nodes; | 123 AudioNodeList nodes; |
124 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_SPEAKER)); | 124 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_SPEAKER)); |
125 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_MIC)); | 125 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_MIC)); |
126 audio_client_->SetAudioNodesAndNotifyObserversForTesting(nodes); | 126 audio_client_->SetAudioNodesAndNotifyObserversForTesting(nodes); |
127 | 127 |
128 EXPECT_FALSE(audio_handler_->IsOutputMuted()); | 128 EXPECT_FALSE(audio_handler_->IsOutputMuted()); |
129 EXPECT_FALSE(audio_handler_->IsInputMuted()); | 129 EXPECT_FALSE(audio_handler_->IsInputMuted()); |
130 EXPECT_EQ(100, audio_handler_->GetOutputVolumePercent()); | 130 EXPECT_EQ(100, audio_handler_->GetOutputVolumePercent()); |
131 EXPECT_EQ(100, audio_handler_->GetInputGainPercent()); | 131 EXPECT_EQ(100, audio_handler_->GetInputGainPercent()); |
132 } | 132 } |
133 | 133 |
134 } // namespace extensions | 134 } // namespace extensions |
OLD | NEW |