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

Side by Side Diff: chrome/browser/ui/ash/volume_controller_browsertest_chromeos.cc

Issue 212793003: Volume adjust sound is played only if spoken feedback is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/ash/volume_controller_chromeos.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "ash/accessibility_delegate.h"
7 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
11 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 13 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
12 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chromeos/audio/chromeos_sounds.h" 15 #include "chromeos/audio/chromeos_sounds.h"
14 #include "chromeos/audio/cras_audio_handler.h" 16 #include "chromeos/audio/cras_audio_handler.h"
15 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
16 #include "media/audio/sounds/sounds_manager.h" 18 #include "media/audio/sounds/sounds_manager.h"
17 #include "ui/base/accelerators/accelerator.h" 19 #include "ui/base/accelerators/accelerator.h"
18 20
19 namespace { 21 namespace {
20 22
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 class VolumeControllerSoundsTest : public VolumeControllerTest { 161 class VolumeControllerSoundsTest : public VolumeControllerTest {
160 public: 162 public:
161 VolumeControllerSoundsTest() : sounds_manager_(NULL) {} 163 VolumeControllerSoundsTest() : sounds_manager_(NULL) {}
162 virtual ~VolumeControllerSoundsTest() {} 164 virtual ~VolumeControllerSoundsTest() {}
163 165
164 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 166 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
165 sounds_manager_ = new SoundsManagerTestImpl(); 167 sounds_manager_ = new SoundsManagerTestImpl();
166 media::SoundsManager::InitializeForTesting(sounds_manager_); 168 media::SoundsManager::InitializeForTesting(sounds_manager_);
167 } 169 }
168 170
169 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 171 void EnableSpokenFeedback(bool enabled) {
170 VolumeControllerTest::SetUpCommandLine(command_line); 172 chromeos::AccessibilityManager* manager =
171 command_line->AppendSwitch(ash::switches::kAshEnableSystemSounds); 173 chromeos::AccessibilityManager::Get();
174 manager->EnableSpokenFeedback(enabled, ash::A11Y_NOTIFICATION_NONE);
172 } 175 }
173 176
174 bool is_sound_initialized() const { 177 bool is_sound_initialized() const {
175 return sounds_manager_->is_sound_initialized( 178 return sounds_manager_->is_sound_initialized(chromeos::SOUND_VOLUME_ADJUST);
176 chromeos::SOUND_VOLUME_ADJUST);
177 } 179 }
178 180
179 int num_play_requests() const { 181 int num_play_requests() const {
180 return sounds_manager_->num_play_requests(chromeos::SOUND_VOLUME_ADJUST); 182 return sounds_manager_->num_play_requests(chromeos::SOUND_VOLUME_ADJUST);
181 } 183 }
182 184
183 private: 185 private:
184 SoundsManagerTestImpl* sounds_manager_; 186 SoundsManagerTestImpl* sounds_manager_;
185 187
186 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsTest); 188 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsTest);
187 }; 189 };
188 190
189 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsTest, VolumeAdjustSounds) { 191 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsTest, Simple) {
192 audio_handler_->SetOutputVolumePercent(50);
193
194 EnableSpokenFeedback(false /* enabled */);
195 VolumeUp();
196 VolumeDown();
197 EXPECT_EQ(0, num_play_requests());
198
199 EnableSpokenFeedback(true /* enabled */);
200 VolumeUp();
201 VolumeDown();
202 EXPECT_EQ(2, num_play_requests());
203 }
204
205 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsTest, EdgeCases) {
190 EXPECT_TRUE(is_sound_initialized()); 206 EXPECT_TRUE(is_sound_initialized());
207 EnableSpokenFeedback(true /* enabled */);
191 208
192 // Check that sound is played on volume up and volume down. 209 // Check that sound is played on volume up and volume down.
193 audio_handler_->SetOutputVolumePercent(50); 210 audio_handler_->SetOutputVolumePercent(50);
194 VolumeUp(); 211 VolumeUp();
195 EXPECT_EQ(1, num_play_requests()); 212 EXPECT_EQ(1, num_play_requests());
196 VolumeDown(); 213 VolumeDown();
197 EXPECT_EQ(2, num_play_requests()); 214 EXPECT_EQ(2, num_play_requests());
198 215
199 audio_handler_->SetOutputVolumePercent(99); 216 audio_handler_->SetOutputVolumePercent(99);
200 VolumeUp(); 217 VolumeUp();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 EXPECT_FALSE(is_sound_initialized()); 253 EXPECT_FALSE(is_sound_initialized());
237 254
238 // Check that sound isn't played on volume up and volume down. 255 // Check that sound isn't played on volume up and volume down.
239 audio_handler_->SetOutputVolumePercent(50); 256 audio_handler_->SetOutputVolumePercent(50);
240 VolumeUp(); 257 VolumeUp();
241 VolumeDown(); 258 VolumeDown();
242 EXPECT_EQ(0, num_play_requests()); 259 EXPECT_EQ(0, num_play_requests());
243 } 260 }
244 261
245 } // namespace 262 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/volume_controller_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698