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

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

Issue 857433003: Update {virtual,override,final} to follow C++11 style chrome/browser/ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase Created 5 years, 11 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) 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/accessibility_delegate.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
13 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 13 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chromeos/audio/chromeos_sounds.h" 15 #include "chromeos/audio/chromeos_sounds.h"
16 #include "chromeos/audio/cras_audio_handler.h" 16 #include "chromeos/audio/cras_audio_handler.h"
17 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
18 #include "media/audio/sounds/sounds_manager.h" 18 #include "media/audio/sounds/sounds_manager.h"
19 #include "ui/base/accelerators/accelerator.h" 19 #include "ui/base/accelerators/accelerator.h"
20 20
21 namespace { 21 namespace {
22 22
23 class SoundsManagerTestImpl : public media::SoundsManager { 23 class SoundsManagerTestImpl : public media::SoundsManager {
24 public: 24 public:
25 SoundsManagerTestImpl() 25 SoundsManagerTestImpl()
26 : is_sound_initialized_(chromeos::SOUND_COUNT), 26 : is_sound_initialized_(chromeos::SOUND_COUNT),
27 num_play_requests_(chromeos::SOUND_COUNT) { 27 num_play_requests_(chromeos::SOUND_COUNT) {
28 } 28 }
29 29
30 virtual ~SoundsManagerTestImpl() {} 30 ~SoundsManagerTestImpl() override {}
31 31
32 virtual bool Initialize(SoundKey key, 32 bool Initialize(SoundKey key, const base::StringPiece& /* data */) override {
33 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 virtual 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 virtual base::TimeDelta GetDuration(SoundKey /* key */) override { 42 base::TimeDelta GetDuration(SoundKey /* key */) override {
44 return base::TimeDelta(); 43 return base::TimeDelta();
45 } 44 }
46 45
47 bool is_sound_initialized(SoundKey key) const { 46 bool is_sound_initialized(SoundKey key) const {
48 return is_sound_initialized_[key]; 47 return is_sound_initialized_[key];
49 } 48 }
50 49
51 int num_play_requests(SoundKey key) const { 50 int num_play_requests(SoundKey key) const {
52 return num_play_requests_[key]; 51 return num_play_requests_[key];
53 } 52 }
54 53
55 private: 54 private:
56 std::vector<bool> is_sound_initialized_; 55 std::vector<bool> is_sound_initialized_;
57 std::vector<int> num_play_requests_; 56 std::vector<int> num_play_requests_;
58 57
59 DISALLOW_COPY_AND_ASSIGN(SoundsManagerTestImpl); 58 DISALLOW_COPY_AND_ASSIGN(SoundsManagerTestImpl);
60 }; 59 };
61 60
62 class VolumeControllerTest : public InProcessBrowserTest { 61 class VolumeControllerTest : public InProcessBrowserTest {
63 public: 62 public:
64 VolumeControllerTest() {} 63 VolumeControllerTest() {}
65 virtual ~VolumeControllerTest() {} 64 ~VolumeControllerTest() override {}
66 65
67 virtual void SetUpOnMainThread() override { 66 void SetUpOnMainThread() override {
68 volume_controller_.reset(new VolumeController()); 67 volume_controller_.reset(new VolumeController());
69 audio_handler_ = chromeos::CrasAudioHandler::Get(); 68 audio_handler_ = chromeos::CrasAudioHandler::Get();
70 } 69 }
71 70
72 protected: 71 protected:
73 void VolumeMute() { 72 void VolumeMute() {
74 volume_controller_->HandleVolumeMute(ui::Accelerator()); 73 volume_controller_->HandleVolumeMute(ui::Accelerator());
75 } 74 }
76 75
77 void VolumeUp() { 76 void VolumeUp() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Thus, further VolumeUp doesn't recover the volume, it's just slightly 153 // Thus, further VolumeUp doesn't recover the volume, it's just slightly
155 // bigger than 0. 154 // bigger than 0.
156 VolumeUp(); 155 VolumeUp();
157 EXPECT_LT(0, audio_handler_->GetOutputVolumePercent()); 156 EXPECT_LT(0, audio_handler_->GetOutputVolumePercent());
158 EXPECT_GT(initial_volume, audio_handler_->GetOutputVolumePercent()); 157 EXPECT_GT(initial_volume, audio_handler_->GetOutputVolumePercent());
159 } 158 }
160 159
161 class VolumeControllerSoundsTest : public VolumeControllerTest { 160 class VolumeControllerSoundsTest : public VolumeControllerTest {
162 public: 161 public:
163 VolumeControllerSoundsTest() : sounds_manager_(NULL) {} 162 VolumeControllerSoundsTest() : sounds_manager_(NULL) {}
164 virtual ~VolumeControllerSoundsTest() {} 163 ~VolumeControllerSoundsTest() override {}
165 164
166 virtual void SetUpInProcessBrowserTestFixture() override { 165 void SetUpInProcessBrowserTestFixture() override {
167 sounds_manager_ = new SoundsManagerTestImpl(); 166 sounds_manager_ = new SoundsManagerTestImpl();
168 media::SoundsManager::InitializeForTesting(sounds_manager_); 167 media::SoundsManager::InitializeForTesting(sounds_manager_);
169 } 168 }
170 169
171 void EnableSpokenFeedback(bool enabled) { 170 void EnableSpokenFeedback(bool enabled) {
172 chromeos::AccessibilityManager* manager = 171 chromeos::AccessibilityManager* manager =
173 chromeos::AccessibilityManager::Get(); 172 chromeos::AccessibilityManager::Get();
174 manager->EnableSpokenFeedback(enabled, ui::A11Y_NOTIFICATION_NONE); 173 manager->EnableSpokenFeedback(enabled, ui::A11Y_NOTIFICATION_NONE);
175 } 174 }
176 175
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 229
231 // Check that audio is unmuted and sound is played. 230 // Check that audio is unmuted and sound is played.
232 VolumeUp(); 231 VolumeUp();
233 ASSERT_FALSE(audio_handler_->IsOutputMuted()); 232 ASSERT_FALSE(audio_handler_->IsOutputMuted());
234 EXPECT_EQ(4, num_play_requests()); 233 EXPECT_EQ(4, num_play_requests());
235 } 234 }
236 235
237 class VolumeControllerSoundsDisabledTest : public VolumeControllerSoundsTest { 236 class VolumeControllerSoundsDisabledTest : public VolumeControllerSoundsTest {
238 public: 237 public:
239 VolumeControllerSoundsDisabledTest() {} 238 VolumeControllerSoundsDisabledTest() {}
240 virtual ~VolumeControllerSoundsDisabledTest() {} 239 ~VolumeControllerSoundsDisabledTest() override {}
241 240
242 virtual void SetUpCommandLine(base::CommandLine* command_line) override { 241 void SetUpCommandLine(base::CommandLine* command_line) override {
243 VolumeControllerSoundsTest::SetUpCommandLine(command_line); 242 VolumeControllerSoundsTest::SetUpCommandLine(command_line);
244 command_line->AppendSwitch(chromeos::switches::kDisableVolumeAdjustSound); 243 command_line->AppendSwitch(chromeos::switches::kDisableVolumeAdjustSound);
245 } 244 }
246 245
247 private: 246 private:
248 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsDisabledTest); 247 DISALLOW_COPY_AND_ASSIGN(VolumeControllerSoundsDisabledTest);
249 }; 248 };
250 249
251 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsDisabledTest, 250 IN_PROC_BROWSER_TEST_F(VolumeControllerSoundsDisabledTest,
252 VolumeAdjustSounds) { 251 VolumeAdjustSounds) {
253 EXPECT_FALSE(is_sound_initialized()); 252 EXPECT_FALSE(is_sound_initialized());
254 253
255 // Check that sound isn't played on volume up and volume down. 254 // Check that sound isn't played on volume up and volume down.
256 audio_handler_->SetOutputVolumePercent(50); 255 audio_handler_->SetOutputVolumePercent(50);
257 VolumeUp(); 256 VolumeUp();
258 VolumeDown(); 257 VolumeDown();
259 EXPECT_EQ(0, num_play_requests()); 258 EXPECT_EQ(0, num_play_requests());
260 } 259 }
261 260
262 } // namespace 261 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/user_accounts_delegate_chromeos.h ('k') | chrome/browser/ui/ash/volume_controller_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698