Chromium Code Reviews| 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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 EXPECT_FALSE(cras_audio_handler_->IsInputMuted()); | 1965 EXPECT_FALSE(cras_audio_handler_->IsInputMuted()); |
| 1966 EXPECT_EQ(2, test_observer_->input_mute_changed_count()); | 1966 EXPECT_EQ(2, test_observer_->input_mute_changed_count()); |
| 1967 } | 1967 } |
| 1968 | 1968 |
| 1969 TEST_F(CrasAudioHandlerTest, SetOutputVolumePercent) { | 1969 TEST_F(CrasAudioHandlerTest, SetOutputVolumePercent) { |
| 1970 AudioNodeList audio_nodes; | 1970 AudioNodeList audio_nodes; |
| 1971 audio_nodes.push_back(kInternalSpeaker); | 1971 audio_nodes.push_back(kInternalSpeaker); |
| 1972 SetUpCrasAudioHandler(audio_nodes); | 1972 SetUpCrasAudioHandler(audio_nodes); |
| 1973 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | 1973 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); |
| 1974 | 1974 |
| 1975 cras_audio_handler_->SetOutputVolumePercent(60); | 1975 const int kVolume = 60; |
| 1976 cras_audio_handler_->SetOutputVolumePercent(kVolume); | |
| 1976 | 1977 |
| 1977 // Verify the output volume is changed to the designated value, | 1978 // Verify the output volume is changed to the designated value, |
| 1978 // OnOutputNodeVolumeChanged event is fired, and the device volume value | 1979 // OnOutputNodeVolumeChanged event is fired, and the device volume value |
| 1979 // is saved the preferences. | 1980 // is saved in the preferences. |
| 1980 const int kVolume = 60; | |
| 1981 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); | 1981 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); |
| 1982 EXPECT_EQ(1, test_observer_->output_volume_changed_count()); | 1982 EXPECT_EQ(1, test_observer_->output_volume_changed_count()); |
| 1983 AudioDevice device; | 1983 AudioDevice device; |
| 1984 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); | 1984 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); |
| 1985 EXPECT_EQ(device.id, kInternalSpeaker.id); | 1985 EXPECT_EQ(device.id, kInternalSpeaker.id); |
| 1986 EXPECT_EQ(kVolume, audio_pref_handler_->GetOutputVolumeValue(&device)); | 1986 EXPECT_EQ(kVolume, audio_pref_handler_->GetOutputVolumeValue(&device)); |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 TEST_F(CrasAudioHandlerTest, SetOutputVolumePercentWithoutNotifyingObservers) { | |
| 1990 AudioNodeList audio_nodes; | |
| 1991 audio_nodes.push_back(kInternalSpeaker); | |
| 1992 SetUpCrasAudioHandler(audio_nodes); | |
| 1993 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | |
| 1994 | |
| 1995 const int kVolume = 60; | |
| 1996 cras_audio_handler_->SetOutputVolumePercentWithoutNotifyingObservers(kVolume); | |
| 1997 // Verify the output volume is changed to the designated value, | |
| 1998 // OnOutputNodeVolumeChanged event is not fired, and the device volume value | |
| 1999 // is saved in the preferences. | |
| 2000 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); | |
| 2001 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | |
| 2002 AudioDevice device; | |
| 2003 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); | |
| 2004 EXPECT_EQ(device.id, kInternalSpeaker.id); | |
| 2005 EXPECT_EQ(kVolume, audio_pref_handler_->GetOutputVolumeValue(&device)); | |
| 2006 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | |
|
jennyz
2016/07/29 22:17:14
This line can be removed. It is the same as line 2
Qiang(Joe) Xu
2016/08/01 20:28:09
Done.
| |
| 2007 } | |
| 2008 | |
| 1989 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) { | 2009 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) { |
| 1990 AudioNodeList audio_nodes; | 2010 AudioNodeList audio_nodes; |
| 1991 audio_nodes.push_back(kInternalSpeaker); | 2011 audio_nodes.push_back(kInternalSpeaker); |
| 1992 SetUpCrasAudioHandler(audio_nodes); | 2012 SetUpCrasAudioHandler(audio_nodes); |
| 1993 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | 2013 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); |
| 1994 | 2014 |
| 1995 const int kDefaultVolume = 75; | 2015 const int kDefaultVolume = 75; |
| 1996 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent()); | 2016 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent()); |
| 1997 | 2017 |
| 1998 // Disable the auto OutputNodeVolumeChanged signal. | 2018 // Disable the auto OutputNodeVolumeChanged signal. |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3267 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); | 3287 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); |
| 3268 EXPECT_EQ(kInternalSpeaker.id, active_output.id); | 3288 EXPECT_EQ(kInternalSpeaker.id, active_output.id); |
| 3269 EXPECT_EQ(kInternalSpeaker.id, | 3289 EXPECT_EQ(kInternalSpeaker.id, |
| 3270 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 3290 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 3271 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); | 3291 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); |
| 3272 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); | 3292 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); |
| 3273 EXPECT_TRUE(test_observer_->output_mute_by_system()); | 3293 EXPECT_TRUE(test_observer_->output_mute_by_system()); |
| 3274 } | 3294 } |
| 3275 | 3295 |
| 3276 } // namespace chromeos | 3296 } // namespace chromeos |
| OLD | NEW |