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

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

Issue 2190773002: Fix Volume slider is captured in screenshot done in touchview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: based on Daniel's comments Created 4 years, 4 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
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 <memory> 10 #include <memory>
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 cras_audio_handler_->SetOutputVolumePercent(60);
1976 1976
1977 // Verify the output volume is changed to the designated value, 1977 // Verify the output volume is changed to the designated value,
1978 // OnOutputNodeVolumeChanged event is fired, and the device volume value 1978 // OnOutputNodeVolumeChanged event is fired, and the device volume value
1979 // is saved the preferences. 1979 // is saved in the preferences.
1980 const int kVolume = 60; 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 cras_audio_handler_->SetOutputVolumePercentWithoutNotifyingObservers(60);
1996 // Verify the output volume is changed to the designated value,
1997 // OnOutputNodeVolumeChanged event is not fired, and the device volume value
1998 // is saved in the preferences.
1999 const int kVolume = 60;
Daniel Erat 2016/07/29 17:53:38 move this constant up and use it in the SetOutputV
Qiang(Joe) Xu 2016/07/29 18:58:23 Done.
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));
Daniel Erat 2016/07/29 17:53:38 please also test that further updates _do_ cause n
Qiang(Joe) Xu 2016/07/29 18:58:23 Done.
2006 }
2007
1989 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) { 2008 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) {
1990 AudioNodeList audio_nodes; 2009 AudioNodeList audio_nodes;
1991 audio_nodes.push_back(kInternalSpeaker); 2010 audio_nodes.push_back(kInternalSpeaker);
1992 SetUpCrasAudioHandler(audio_nodes); 2011 SetUpCrasAudioHandler(audio_nodes);
1993 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); 2012 EXPECT_EQ(0, test_observer_->output_volume_changed_count());
1994 2013
1995 const int kDefaultVolume = 75; 2014 const int kDefaultVolume = 75;
1996 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent()); 2015 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent());
1997 2016
1998 // Disable the auto OutputNodeVolumeChanged signal. 2017 // Disable the auto OutputNodeVolumeChanged signal.
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); 3286 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output));
3268 EXPECT_EQ(kInternalSpeaker.id, active_output.id); 3287 EXPECT_EQ(kInternalSpeaker.id, active_output.id);
3269 EXPECT_EQ(kInternalSpeaker.id, 3288 EXPECT_EQ(kInternalSpeaker.id,
3270 cras_audio_handler_->GetPrimaryActiveOutputNode()); 3289 cras_audio_handler_->GetPrimaryActiveOutputNode());
3271 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); 3290 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted());
3272 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); 3291 EXPECT_EQ(1, test_observer_->output_mute_changed_count());
3273 EXPECT_TRUE(test_observer_->output_mute_by_system()); 3292 EXPECT_TRUE(test_observer_->output_mute_by_system());
3274 } 3293 }
3275 3294
3276 } // namespace chromeos 3295 } // namespace chromeos
OLDNEW
« 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