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

Unified Diff: chromeos/audio/cras_audio_handler_unittest.cc

Issue 2270693005: Fix the corner case for new audio device is not selected as active if it is plugged in for the firs… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/audio/cras_audio_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler_unittest.cc
diff --git a/chromeos/audio/cras_audio_handler_unittest.cc b/chromeos/audio/cras_audio_handler_unittest.cc
index 7375b4dfa8f0c94e72e3eef31fa6e7789fdfbb4d..7ec72df18fa4354b38413884f88c771a07f803f1 100644
--- a/chromeos/audio/cras_audio_handler_unittest.cc
+++ b/chromeos/audio/cras_audio_handler_unittest.cc
@@ -2372,6 +2372,32 @@ TEST_F(CrasAudioHandlerTest, PersistActiveSpeakerAcrossReboot) {
cras_audio_handler_->GetPrimaryActiveOutputNode());
}
+// Test the corner case that headphone is plugged in for the first time on
+// a cros device after the device is shutdown.
+// crbug.com/622045.
+TEST_F(CrasAudioHandlerTest, PlugInHeadphoneFirstTimeAfterPowerDown) {
+ // Simulate plugging headphone for the first on a cros device after it is
+ // powered down. Internal speaker is set up in audio prefs as active
+ // before the new cros session starts.
+ AudioNodeList audio_nodes_in_pref;
+ audio_nodes_in_pref.push_back(kInternalSpeaker);
+
+ AudioNodeList audio_nodes;
+ audio_nodes.push_back(kInternalSpeaker);
+ audio_nodes.push_back(kHeadphone);
+
+ SetupCrasAudioHandlerWithActiveNodeInPref(
+ audio_nodes, audio_nodes_in_pref, AudioDevice(kInternalSpeaker), false);
+
+ // Verify the audio devices size.
+ AudioDeviceList audio_devices;
+ cras_audio_handler_->GetAudioDevices(&audio_devices);
+ EXPECT_EQ(audio_nodes.size(), audio_devices.size());
+
+ // Verify headphone becomes the active output.
+ EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
+}
+
TEST_F(CrasAudioHandlerTest,
PersistActiveUsbHeadphoneAcrossRebootUsbComeLater) {
// Simulates the device was shut down with three audio devices, and
« 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