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 1109793005: Fix the issue where the active output device is lost after the device suspend/resume without any ac… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 72eaaf38411d32874d19d5de6cd5c4dcdf6b102d..fa5dbc35ba60a5c266c49f4c1517455b8022c1ae 100644
--- a/chromeos/audio/cras_audio_handler_unittest.cc
+++ b/chromeos/audio/cras_audio_handler_unittest.cc
@@ -2429,4 +2429,68 @@ TEST_F(CrasAudioHandlerTest, HotPlugHDMINotChangeActiveOutput) {
cras_audio_handler_->GetPrimaryActiveOutputNode());
}
+// Test the case in which the active device was set to inactive from cras after
+// resuming from suspension state. See crbug.com/478968.
+TEST_F(CrasAudioHandlerTest, ActiveNodeLostAfterResume) {
+ AudioNodeList audio_nodes;
+ EXPECT_FALSE(kHeadphone.active);
+ audio_nodes.push_back(kHeadphone);
+ EXPECT_FALSE(kHDMIOutput.active);
+ audio_nodes.push_back(kHDMIOutput);
+ SetUpCrasAudioHandler(audio_nodes);
+
+ // Verify the headphone is selected as the active output.
+ AudioDeviceList audio_devices;
+ cras_audio_handler_->GetAudioDevices(&audio_devices);
+ EXPECT_EQ(audio_nodes.size(), audio_devices.size());
+ EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
+ const AudioDevice* active_headphone = GetDeviceFromId(kHeadphone.id);
+ EXPECT_EQ(kHeadphone.id, active_headphone->id);
+ EXPECT_TRUE(active_headphone->active);
+
+ // Simulate NodesChanged signal with headphone turning into inactive state,
+ // and HDMI node removed.
+ audio_nodes.clear();
+ audio_nodes.push_back(kHeadphone);
+ ChangeAudioNodes(audio_nodes);
+
+ // Verify the headphone is set to active again.
+ EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
+ const AudioDevice* headphone_resumed = GetDeviceFromId(kHeadphone.id);
+ EXPECT_EQ(kHeadphone.id, headphone_resumed->id);
+ EXPECT_TRUE(headphone_resumed->active);
+}
+
+// Test the case in which there are two NodesChanged signal for discovering
+// output devices, and there is race between NodesChange and SetActiveOutput
+// during this process. See crbug.com/478968.
+TEST_F(CrasAudioHandlerTest, ActiveNodeLostDuringLoginSession) {
+ AudioNodeList audio_nodes;
+ EXPECT_FALSE(kHeadphone.active);
+ audio_nodes.push_back(kHeadphone);
+ SetUpCrasAudioHandler(audio_nodes);
+
+ // Verify the headphone is selected as the active output.
+ AudioDeviceList audio_devices;
+ cras_audio_handler_->GetAudioDevices(&audio_devices);
+ EXPECT_EQ(audio_nodes.size(), audio_devices.size());
+ EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
+ const AudioDevice* active_headphone = GetDeviceFromId(kHeadphone.id);
+ EXPECT_EQ(kHeadphone.id, active_headphone->id);
+ EXPECT_TRUE(active_headphone->active);
+
+ // Simulate NodesChanged signal with headphone turning into inactive state,
+ // and add a new HDMI output node.
+ audio_nodes.clear();
+ audio_nodes.push_back(kHeadphone);
+ audio_nodes.push_back(kHDMIOutput);
+ ChangeAudioNodes(audio_nodes);
+
+ // Verify the headphone is set to active again.
+ EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode());
+ const AudioDevice* headphone_resumed = GetDeviceFromId(kHeadphone.id);
+ EXPECT_EQ(kHeadphone.id, headphone_resumed->id);
+ EXPECT_TRUE(headphone_resumed->active);
+}
+
} // namespace chromeos
« 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