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

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: several updates included 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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 kVolume1 = 60;
1996 const int kVolume2 = 80;
1997 cras_audio_handler_->SetOutputVolumePercentWithoutNotifyingObservers(
1998 kVolume1, CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT);
1999 // Verify the output volume is changed to the designated value,
2000 // OnOutputNodeVolumeChanged event is not fired, and the device volume value
2001 // is saved in the preferences.
2002 EXPECT_EQ(kVolume1, cras_audio_handler_->GetOutputVolumePercent());
2003 EXPECT_EQ(0, test_observer_->output_volume_changed_count());
2004 AudioDevice device;
2005 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device));
2006 EXPECT_EQ(device.id, kInternalSpeaker.id);
2007 EXPECT_EQ(kVolume1, audio_pref_handler_->GetOutputVolumeValue(&device));
2008
2009 // Make another SetOutputVolumePercentWithoutNotifyingObservers call to make
2010 // sure everything is right.
2011 cras_audio_handler_->SetOutputVolumePercentWithoutNotifyingObservers(
2012 kVolume2, CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT);
2013 EXPECT_EQ(kVolume2, cras_audio_handler_->GetOutputVolumePercent());
2014 EXPECT_EQ(0, test_observer_->output_volume_changed_count());
2015 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device));
2016 EXPECT_EQ(device.id, kInternalSpeaker.id);
2017 EXPECT_EQ(kVolume2, audio_pref_handler_->GetOutputVolumeValue(&device));
2018
2019 // Make a final SetOutputVolumePercent call to check if
2020 // SetOutputVolumePercentWithoutNotifyingObservers may block subsequent
2021 // notifying observers.
2022 cras_audio_handler_->SetOutputVolumePercent(kVolume1);
2023 EXPECT_EQ(kVolume1, cras_audio_handler_->GetOutputVolumePercent());
2024 EXPECT_EQ(1, test_observer_->output_volume_changed_count());
2025 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device));
2026 EXPECT_EQ(device.id, kInternalSpeaker.id);
2027 EXPECT_EQ(kVolume1, audio_pref_handler_->GetOutputVolumeValue(&device));
2028 }
2029
1989 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) { 2030 TEST_F(CrasAudioHandlerTest, SetOutputVolumeWithDelayedSignal) {
1990 AudioNodeList audio_nodes; 2031 AudioNodeList audio_nodes;
1991 audio_nodes.push_back(kInternalSpeaker); 2032 audio_nodes.push_back(kInternalSpeaker);
1992 SetUpCrasAudioHandler(audio_nodes); 2033 SetUpCrasAudioHandler(audio_nodes);
1993 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); 2034 EXPECT_EQ(0, test_observer_->output_volume_changed_count());
1994 2035
1995 const int kDefaultVolume = 75; 2036 const int kDefaultVolume = 75;
1996 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent()); 2037 EXPECT_EQ(kDefaultVolume, cras_audio_handler_->GetOutputVolumePercent());
1997 2038
1998 // Disable the auto OutputNodeVolumeChanged signal. 2039 // Disable the auto OutputNodeVolumeChanged signal.
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output)); 3308 cras_audio_handler_->GetPrimaryActiveOutputDevice(&active_output));
3268 EXPECT_EQ(kInternalSpeaker.id, active_output.id); 3309 EXPECT_EQ(kInternalSpeaker.id, active_output.id);
3269 EXPECT_EQ(kInternalSpeaker.id, 3310 EXPECT_EQ(kInternalSpeaker.id,
3270 cras_audio_handler_->GetPrimaryActiveOutputNode()); 3311 cras_audio_handler_->GetPrimaryActiveOutputNode());
3271 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); 3312 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted());
3272 EXPECT_EQ(1, test_observer_->output_mute_changed_count()); 3313 EXPECT_EQ(1, test_observer_->output_mute_changed_count());
3273 EXPECT_TRUE(test_observer_->output_mute_by_system()); 3314 EXPECT_TRUE(test_observer_->output_mute_by_system());
3274 } 3315 }
3275 3316
3276 } // namespace chromeos 3317 } // 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