| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2365 audio_nodes.push_back(kHeadphone); | 2365 audio_nodes.push_back(kHeadphone); |
| 2366 ChangeAudioNodes(audio_nodes); | 2366 ChangeAudioNodes(audio_nodes); |
| 2367 | 2367 |
| 2368 // Verify the active output has been restored to internal speaker. | 2368 // Verify the active output has been restored to internal speaker. |
| 2369 cras_audio_handler_->GetAudioDevices(&audio_devices); | 2369 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2370 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); | 2370 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2371 EXPECT_EQ(kInternalSpeaker.id, | 2371 EXPECT_EQ(kInternalSpeaker.id, |
| 2372 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 2372 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2373 } | 2373 } |
| 2374 | 2374 |
| 2375 // Test the corner case that headphone is plugged in for the first time on |
| 2376 // a cros device after the device is shutdown. |
| 2377 // crbug.com/622045. |
| 2378 TEST_F(CrasAudioHandlerTest, PlugInHeadphoneFirstTimeAfterPowerDown) { |
| 2379 // Simulate plugging headphone for the first on a cros device after it is |
| 2380 // powered down. Internal speaker is set up in audio prefs as active |
| 2381 // before the new cros session starts. |
| 2382 AudioNodeList audio_nodes_in_pref; |
| 2383 audio_nodes_in_pref.push_back(kInternalSpeaker); |
| 2384 |
| 2385 AudioNodeList audio_nodes; |
| 2386 audio_nodes.push_back(kInternalSpeaker); |
| 2387 audio_nodes.push_back(kHeadphone); |
| 2388 |
| 2389 SetupCrasAudioHandlerWithActiveNodeInPref( |
| 2390 audio_nodes, audio_nodes_in_pref, AudioDevice(kInternalSpeaker), false); |
| 2391 |
| 2392 // Verify the audio devices size. |
| 2393 AudioDeviceList audio_devices; |
| 2394 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 2395 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); |
| 2396 |
| 2397 // Verify headphone becomes the active output. |
| 2398 EXPECT_EQ(kHeadphone.id, cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2399 } |
| 2400 |
| 2375 TEST_F(CrasAudioHandlerTest, | 2401 TEST_F(CrasAudioHandlerTest, |
| 2376 PersistActiveUsbHeadphoneAcrossRebootUsbComeLater) { | 2402 PersistActiveUsbHeadphoneAcrossRebootUsbComeLater) { |
| 2377 // Simulates the device was shut down with three audio devices, and | 2403 // Simulates the device was shut down with three audio devices, and |
| 2378 // usb headphone being the active one selected by priority. | 2404 // usb headphone being the active one selected by priority. |
| 2379 AudioNodeList audio_nodes_in_pref; | 2405 AudioNodeList audio_nodes_in_pref; |
| 2380 audio_nodes_in_pref.push_back(kInternalSpeaker); | 2406 audio_nodes_in_pref.push_back(kInternalSpeaker); |
| 2381 audio_nodes_in_pref.push_back(kHeadphone); | 2407 audio_nodes_in_pref.push_back(kHeadphone); |
| 2382 audio_nodes_in_pref.push_back(kUSBHeadphone1); | 2408 audio_nodes_in_pref.push_back(kUSBHeadphone1); |
| 2383 | 2409 |
| 2384 // Simulate the first NodesChanged signal coming with only internal speaker | 2410 // Simulate the first NodesChanged signal coming with only internal speaker |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3267 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); | 3293 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); |
| 3268 EXPECT_EQ(kInternalSpeaker.id, active_output.id); | 3294 EXPECT_EQ(kInternalSpeaker.id, active_output.id); |
| 3269 EXPECT_EQ(kInternalSpeaker.id, | 3295 EXPECT_EQ(kInternalSpeaker.id, |
| 3270 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3296 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 3271 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); | 3297 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); |
| 3272 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); | 3298 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); |
| 3273 EXPECT_TRUE(test_observer_->output_mute_by_system()); | 3299 EXPECT_TRUE(test_observer_->output_mute_by_system()); |
| 3274 } | 3300 } |
| 3275 | 3301 |
| 3276 } // namespace chromeos | 3302 } // namespace chromeos |
| OLD | NEW |