Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2198)

Side by Side Diff: chromeos/audio/cras_audio_handler_unittest.cc

Issue 751773002: Reset the active audio node id once all of the devices are gone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/cras_audio_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chromeos/audio/cras_audio_handler.h" 5 #include "chromeos/audio/cras_audio_handler.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 void reset_active_output_node_changed_count() { 212 void reset_active_output_node_changed_count() {
213 active_output_node_changed_count_ = 0; 213 active_output_node_changed_count_ = 0;
214 } 214 }
215 215
216 int active_input_node_changed_count() const { 216 int active_input_node_changed_count() const {
217 return active_input_node_changed_count_; 217 return active_input_node_changed_count_;
218 } 218 }
219 219
220 void reset_active_input_node_changed_count() { 220 void reset_active_input_node_changed_count() {
221 active_output_node_changed_count_ = 0; 221 active_input_node_changed_count_ = 0;
222 } 222 }
223 223
224 int audio_nodes_changed_count() const { 224 int audio_nodes_changed_count() const {
225 return audio_nodes_changed_count_; 225 return audio_nodes_changed_count_;
226 } 226 }
227 227
228 int output_mute_changed_count() const { 228 int output_mute_changed_count() const {
229 return output_mute_changed_count_; 229 return output_mute_changed_count_;
230 } 230 }
231 231
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 cras_audio_handler_->ChangeActiveNodes(active_nodes); 2277 cras_audio_handler_->ChangeActiveNodes(active_nodes);
2278 2278
2279 // Verify the jabra speaker's output is selected as active output, and 2279 // Verify the jabra speaker's output is selected as active output, and
2280 // jabra's input is selected as active input. 2280 // jabra's input is selected as active input.
2281 EXPECT_EQ(2, GetActiveDeviceCount()); 2281 EXPECT_EQ(2, GetActiveDeviceCount());
2282 EXPECT_EQ(kHDMIOutput.id, cras_audio_handler_->GetPrimaryActiveOutputNode()); 2282 EXPECT_EQ(kHDMIOutput.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
2283 EXPECT_EQ(kUSBJabraSpeakerInput1.id, 2283 EXPECT_EQ(kUSBJabraSpeakerInput1.id,
2284 cras_audio_handler_->GetPrimaryActiveInputNode()); 2284 cras_audio_handler_->GetPrimaryActiveInputNode());
2285 } 2285 }
2286 2286
2287 TEST_F(CrasAudioHandlerTest, NoMoreAudioInputDevices) {
2288 // Some device like chromebox does not have the internal input device. The
2289 // active devices should be reset when the user plugs a device and then
2290 // unplugs it to such device.
2291
2292 AudioNodeList audio_nodes;
2293 audio_nodes.push_back(kInternalSpeaker);
2294 SetUpCrasAudioHandler(audio_nodes);
2295
2296 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode());
2297
2298 audio_nodes.push_back(kMicJack);
2299 ChangeAudioNodes(audio_nodes);
2300
2301 EXPECT_EQ(kMicJack.id, cras_audio_handler_->GetPrimaryActiveInputNode());
2302 EXPECT_EQ(1, test_observer_->active_input_node_changed_count());
2303 test_observer_->reset_active_input_node_changed_count();
2304
2305 audio_nodes.pop_back();
2306 ChangeAudioNodes(audio_nodes);
2307 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode());
2308 EXPECT_EQ(1, test_observer_->active_input_node_changed_count());
2309 }
2310
2287 } // namespace chromeos 2311 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/cras_audio_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698