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

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

Issue 872303003: Do not re-select active device if a lower priority device is hotplugged in and user has already sel… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 EXPECT_EQ(kMicJack.id, cras_audio_handler_->GetPrimaryActiveInputNode()); 2370 EXPECT_EQ(kMicJack.id, cras_audio_handler_->GetPrimaryActiveInputNode());
2371 EXPECT_EQ(1, test_observer_->active_input_node_changed_count()); 2371 EXPECT_EQ(1, test_observer_->active_input_node_changed_count());
2372 test_observer_->reset_active_input_node_changed_count(); 2372 test_observer_->reset_active_input_node_changed_count();
2373 2373
2374 audio_nodes.pop_back(); 2374 audio_nodes.pop_back();
2375 ChangeAudioNodes(audio_nodes); 2375 ChangeAudioNodes(audio_nodes);
2376 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode()); 2376 EXPECT_EQ(0ULL, cras_audio_handler_->GetPrimaryActiveInputNode());
2377 EXPECT_EQ(1, test_observer_->active_input_node_changed_count()); 2377 EXPECT_EQ(1, test_observer_->active_input_node_changed_count());
2378 } 2378 }
2379 2379
2380 // Test the case in which an HDMI output is plugged in with other higher
2381 // priority
2382 // output devices already plugged and user has manually selected an active
2383 // output.
2384 // The hotplug of hdmi output should not change user's selection of active
2385 // device.
2386 // crbug.com/447826.
2387 TEST_F(CrasAudioHandlerTest, HotPlugHDMINotChangeActiveOutput) {
2388 AudioNodeList audio_nodes;
2389 AudioNode internal_speaker(kInternalSpeaker);
2390 audio_nodes.push_back(internal_speaker);
2391 AudioNode usb_headset(kUSBHeadphone1);
2392 usb_headset.plugged_time = 80000000;
2393 audio_nodes.push_back(usb_headset);
2394 SetUpCrasAudioHandler(audio_nodes);
2395
2396 // Verify the audio devices size.
2397 AudioDeviceList audio_devices;
2398 cras_audio_handler_->GetAudioDevices(&audio_devices);
2399 EXPECT_EQ(audio_nodes.size(), audio_devices.size());
2400
2401 // Verify the USB headset is selected as active output by default.
2402 EXPECT_EQ(usb_headset.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
2403
2404 // Manually set the active output to internal speaker.
2405 AudioDevice internal_output(kInternalSpeaker);
2406 cras_audio_handler_->SwitchToDevice(internal_output, true);
2407
2408 // Verify the active output is switched to internal speaker.
2409 EXPECT_EQ(internal_speaker.id,
2410 cras_audio_handler_->GetPrimaryActiveOutputNode());
2411 EXPECT_LT(kInternalSpeaker.plugged_time, usb_headset.plugged_time);
2412 const AudioDevice* usb_device = GetDeviceFromId(usb_headset.id);
2413 EXPECT_FALSE(usb_device->active);
2414
2415 // Plug in HDMI output.
2416 audio_nodes.clear();
2417 internal_speaker.active = true;
2418 audio_nodes.push_back(internal_speaker);
2419 usb_headset.active = false;
2420 audio_nodes.push_back(usb_headset);
2421 AudioNode hdmi(kHDMIOutput);
2422 hdmi.plugged_time = 90000000;
2423 audio_nodes.push_back(hdmi);
2424 ChangeAudioNodes(audio_nodes);
2425
2426 // The active output should not change.
2427 EXPECT_EQ(kInternalSpeaker.id,
2428 cras_audio_handler_->GetPrimaryActiveOutputNode());
2429 }
2430
2380 } // namespace chromeos 2431 } // 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