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

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

Issue 2552483002: mash: Have chrome set itself as a controller interface for changing volume (Closed)
Patch Set: comment Created 4 years 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) 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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/common/accessibility_delegate.h" 8 #include "ash/common/accessibility_delegate.h"
9 #include "ash/common/accessibility_types.h" 9 #include "ash/common/accessibility_types.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
14 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 14 #include "chrome/browser/ui/ash/volume_controller.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chromeos/audio/chromeos_sounds.h" 16 #include "chromeos/audio/chromeos_sounds.h"
17 #include "chromeos/audio/cras_audio_handler.h" 17 #include "chromeos/audio/cras_audio_handler.h"
18 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
19 #include "media/audio/sounds/sounds_manager.h" 19 #include "media/audio/sounds/sounds_manager.h"
20 #include "ui/base/accelerators/accelerator.h" 20 #include "ui/base/accelerators/accelerator.h"
21 21
22 namespace { 22 namespace {
23 23
24 class SoundsManagerTestImpl : public media::SoundsManager { 24 class SoundsManagerTestImpl : public media::SoundsManager {
25 public: 25 public:
26 SoundsManagerTestImpl() 26 SoundsManagerTestImpl()
27 : is_sound_initialized_(chromeos::SOUND_COUNT), 27 : is_sound_initialized_(chromeos::SOUND_COUNT),
28 num_play_requests_(chromeos::SOUND_COUNT) { 28 num_play_requests_(chromeos::SOUND_COUNT) {}
29 }
30 29
31 ~SoundsManagerTestImpl() override {} 30 ~SoundsManagerTestImpl() override {}
32 31
33 bool Initialize(SoundKey key, const base::StringPiece& /* data */) override { 32 bool Initialize(SoundKey key, const base::StringPiece& /* data */) override {
34 is_sound_initialized_[key] = true; 33 is_sound_initialized_[key] = true;
35 return true; 34 return true;
36 } 35 }
37 36
38 bool Play(SoundKey key) override { 37 bool Play(SoundKey key) override {
39 ++num_play_requests_[key]; 38 ++num_play_requests_[key];
40 return true; 39 return true;
41 } 40 }
42 41
43 bool Stop(SoundKey key) override { 42 bool Stop(SoundKey key) override { return true; }
44 return true;
45 }
46 43
47 base::TimeDelta GetDuration(SoundKey /* key */) override { 44 base::TimeDelta GetDuration(SoundKey /* key */) override {
48 return base::TimeDelta(); 45 return base::TimeDelta();
49 } 46 }
50 47
51 bool is_sound_initialized(SoundKey key) const { 48 bool is_sound_initialized(SoundKey key) const {
52 return is_sound_initialized_[key]; 49 return is_sound_initialized_[key];
53 } 50 }
54 51
55 int num_play_requests(SoundKey key) const { 52 int num_play_requests(SoundKey key) const { return num_play_requests_[key]; }
56 return num_play_requests_[key];
57 }
58 53
59 private: 54 private:
60 std::vector<bool> is_sound_initialized_; 55 std::vector<bool> is_sound_initialized_;
61 std::vector<int> num_play_requests_; 56 std::vector<int> num_play_requests_;
62 57
63 DISALLOW_COPY_AND_ASSIGN(SoundsManagerTestImpl); 58 DISALLOW_COPY_AND_ASSIGN(SoundsManagerTestImpl);
64 }; 59 };
65 60
66 class VolumeControllerTest : public InProcessBrowserTest { 61 class VolumeControllerTest : public InProcessBrowserTest {
67 public: 62 public:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 227
233 void SetUpCommandLine(base::CommandLine* command_line) override { 228 void SetUpCommandLine(base::CommandLine* command_line) override {
234 VolumeControllerSoundsTest::SetUpCommandLine(command_line); 229 VolumeControllerSoundsTest::SetUpCommandLine(command_line);
235 command_line->AppendSwitch(chromeos::switches::kDisableVolumeAdjustSound); 230 command_line->AppendSwitch(chromeos::switches::kDisableVolumeAdjustSound);
236 } 231 }
237 232
238 private: 233 private:
239 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsDisabledTest); 234 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsDisabledTest);
240 }; 235 };
241 236
242 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsDisabledTest, 237 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsDisabledTest, VolumeAdjustSounds) {
243 VolumeAdjustSounds) {
244 EXPECT_FALSE(is_sound_initialized()); 238 EXPECT_FALSE(is_sound_initialized());
245 239
246 // Check that sound isn't played on volume up and volume down. 240 // Check that sound isn't played on volume up and volume down.
247 audio_handler_->SetOutputVolumePercent(50); 241 audio_handler_->SetOutputVolumePercent(50);
248 volume_controller_->VolumeUp(); 242 volume_controller_->VolumeUp();
249 volume_controller_->VolumeDown(); 243 volume_controller_->VolumeDown();
250 EXPECT_EQ(0, num_play_requests()); 244 EXPECT_EQ(0, num_play_requests());
251 } 245 }
252 246
253 } // namespace 247 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/volume_controller.cc ('k') | chrome/browser/ui/ash/volume_controller_browsertest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698