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

Unified Diff: chromeos/audio/cras_audio_handler_unittest.cc

Issue 23620055: Fix the bluetooth audio device id changing on the fly issue and the active device inconsistent issu… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
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 03dd4aa2a48804f45028ad2c524cc3f99121b6db..f584f21be44b11083f7af8c2a01abc8d8a96ba7d 100644
--- a/chromeos/audio/cras_audio_handler_unittest.cc
+++ b/chromeos/audio/cras_audio_handler_unittest.cc
@@ -935,6 +935,55 @@ TEST_F(CrasAudioHandlerTest, OneActiveAudioOutputAfterLoginNewUserSession) {
}
}
+TEST_F(CrasAudioHandlerTest, BluetoothSpeakerIdChangedOnFly) {
+ // Initialize with internal speaker and bluetooth headset.
+ AudioNodeList audio_nodes;
+ audio_nodes.push_back(kInternalSpeaker);
+ audio_nodes.push_back(kBluetoothHeadset);
+ SetUpCrasAudioHandler(audio_nodes);
+ const size_t init_nodes_size = audio_nodes.size();
+
+ // Verify the audio devices size.
+ AudioDeviceList audio_devices;
+ cras_audio_handler_->GetAudioDevices(&audio_devices);
+ EXPECT_EQ(init_nodes_size, audio_devices.size());
+ EXPECT_EQ(0, test_observer_->audio_nodes_changed_count());
+
+ // Verify the bluetooth headset is selected as the active output and all other
+ // audio devices are not active.
+ EXPECT_EQ(0, test_observer_->active_output_node_changed_count());
+ AudioDevice active_output;
+ EXPECT_TRUE(cras_audio_handler_->GetActiveOutputDevice(&active_output));
+ EXPECT_EQ(kBluetoothHeadset.id, active_output.id);
+ EXPECT_EQ(kBluetoothHeadset.id, cras_audio_handler_->GetActiveOutputNode());
+ EXPECT_TRUE(cras_audio_handler_->has_alternative_output());
+
+ // Cras changes the bluetooth headset's id on the fly.
+ audio_nodes.clear();
+ AudioNode internal_speaker(kInternalSpeaker);
+ internal_speaker.active = false;
+ audio_nodes.push_back(internal_speaker);
+ AudioNode bluetooth_headphone(kBluetoothHeadset);
+ // Change bluetooth headphone id.
+ bluetooth_headphone.id = kBluetoothHeadsetId + 20000;
+ bluetooth_headphone.active = false;
+ audio_nodes.push_back(bluetooth_headphone);
+ ChangeAudioNodes(audio_nodes);
+
+ // Verify NodesChanged event is fired, and the audio devices size is not
+ // changed.
+ audio_devices.clear();
+ cras_audio_handler_->GetAudioDevices(&audio_devices);
+ EXPECT_EQ(init_nodes_size, audio_devices.size());
+ EXPECT_EQ(1, test_observer_->audio_nodes_changed_count());
+
+ // Verify ActiveOutputNodeChanged event is fired, and active device should be
+ // bluetooth headphone.
+ EXPECT_EQ(1, test_observer_->active_output_node_changed_count());
+ EXPECT_TRUE(cras_audio_handler_->GetActiveOutputDevice(&active_output));
+ EXPECT_EQ(bluetooth_headphone.id, active_output.id);
+}
+
TEST_F(CrasAudioHandlerTest, PlugUSBMic) {
// Set up initial audio devices, only with internal mic.
AudioNodeList audio_nodes;
« chromeos/audio/cras_audio_handler.cc ('K') | « chromeos/audio/cras_audio_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698