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

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

Issue 1759103003: Exclude non-simple-usage audio nodes from being selected as primary node, and do not persist their … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 const AudioDevice* active_keyboard_mic = GetDeviceFromId(kKeyboardMic.id); 568 const AudioDevice* active_keyboard_mic = GetDeviceFromId(kKeyboardMic.id);
569 EXPECT_TRUE(active_keyboard_mic->active); 569 EXPECT_TRUE(active_keyboard_mic->active);
570 570
571 // Make keyboard mic inactive. 571 // Make keyboard mic inactive.
572 cras_audio_handler_->SetKeyboardMicActive(false); 572 cras_audio_handler_->SetKeyboardMicActive(false);
573 EXPECT_EQ(kInternalMic.id, cras_audio_handler_->GetPrimaryActiveInputNode()); 573 EXPECT_EQ(kInternalMic.id, cras_audio_handler_->GetPrimaryActiveInputNode());
574 const AudioDevice* inactive_keyboard_mic = GetDeviceFromId(kKeyboardMic.id); 574 const AudioDevice* inactive_keyboard_mic = GetDeviceFromId(kKeyboardMic.id);
575 EXPECT_FALSE(inactive_keyboard_mic->active); 575 EXPECT_FALSE(inactive_keyboard_mic->active);
576 } 576 }
577 577
578 TEST_F(CrasAudioHandlerTest, KeyboardMicNotSetAsPrimaryActive) {
579 AudioNodeList audio_nodes;
580 audio_nodes.push_back(kKeyboardMic);
581 SetUpCrasAudioHandler(audio_nodes);
582
583 // Verify keyboard mic is not set as primary active input.
584 AudioDeviceList audio_devices;
585 cras_audio_handler_->GetAudioDevices(&audio_devices);
586 EXPECT_EQ(audio_nodes.size(), audio_devices.size());
587 EXPECT_TRUE(cras_audio_handler_->HasKeyboardMic());
588 EXPECT_EQ(0u, cras_audio_handler_->GetPrimaryActiveInputNode());
589
590 // Verify the internal mic is set as primary input.
591 audio_nodes.push_back(kInternalMic);
592 ChangeAudioNodes(audio_nodes);
593 cras_audio_handler_->GetAudioDevices(&audio_devices);
594 EXPECT_EQ(audio_nodes.size(), audio_devices.size());
595 EXPECT_TRUE(cras_audio_handler_->HasKeyboardMic());
596 EXPECT_EQ(kInternalMic.id, cras_audio_handler_->GetPrimaryActiveInputNode());
597 }
598
578 TEST_F(CrasAudioHandlerTest, SwitchActiveOutputDevice) { 599 TEST_F(CrasAudioHandlerTest, SwitchActiveOutputDevice) {
579 AudioNodeList audio_nodes; 600 AudioNodeList audio_nodes;
580 audio_nodes.push_back(kInternalSpeaker); 601 audio_nodes.push_back(kInternalSpeaker);
581 audio_nodes.push_back(kHeadphone); 602 audio_nodes.push_back(kHeadphone);
582 SetUpCrasAudioHandler(audio_nodes); 603 SetUpCrasAudioHandler(audio_nodes);
583 AudioDeviceList audio_devices; 604 AudioDeviceList audio_devices;
584 cras_audio_handler_->GetAudioDevices(&audio_devices); 605 cras_audio_handler_->GetAudioDevices(&audio_devices);
585 EXPECT_EQ(audio_nodes.size(), audio_devices.size()); 606 EXPECT_EQ(audio_nodes.size(), audio_devices.size());
586 607
587 // Verify the initial active output device is headphone. 608 // Verify the initial active output device is headphone.
(...skipping 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); 3066 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output));
3046 EXPECT_EQ(kInternalSpeaker.id, active_output.id); 3067 EXPECT_EQ(kInternalSpeaker.id, active_output.id);
3047 EXPECT_EQ(kInternalSpeaker.id, 3068 EXPECT_EQ(kInternalSpeaker.id,
3048 cras_audio_handler_->GetPrimaryActiveOutputNode()); 3069 cras_audio_handler_->GetPrimaryActiveOutputNode());
3049 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); 3070 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted());
3050 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); 3071 EXPECT_EQ(1, test_observer_->output_mute_changed_count());
3051 EXPECT_TRUE(test_observer_->output_mute_by_system()); 3072 EXPECT_TRUE(test_observer_->output_mute_by_system());
3052 } 3073 }
3053 3074
3054 } // namespace chromeos 3075 } // 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