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

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 680153002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix formatting Created 6 years, 1 month 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
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_delegate.h » ('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 "ash/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "ui/events/test/events_test_utils_x11.h" 44 #include "ui/events/test/events_test_utils_x11.h"
45 #endif 45 #endif
46 46
47 namespace ash { 47 namespace ash {
48 48
49 namespace { 49 namespace {
50 50
51 class TestTarget : public ui::AcceleratorTarget { 51 class TestTarget : public ui::AcceleratorTarget {
52 public: 52 public:
53 TestTarget() : accelerator_pressed_count_(0), accelerator_repeat_count_(0) {} 53 TestTarget() : accelerator_pressed_count_(0), accelerator_repeat_count_(0) {}
54 virtual ~TestTarget() {} 54 ~TestTarget() override {}
55 55
56 int accelerator_pressed_count() const { 56 int accelerator_pressed_count() const {
57 return accelerator_pressed_count_; 57 return accelerator_pressed_count_;
58 } 58 }
59 59
60 int accelerator_repeat_count() const { return accelerator_repeat_count_; } 60 int accelerator_repeat_count() const { return accelerator_repeat_count_; }
61 61
62 void reset() { 62 void reset() {
63 accelerator_pressed_count_ = 0; 63 accelerator_pressed_count_ = 0;
64 accelerator_repeat_count_ = 0; 64 accelerator_repeat_count_ = 0;
65 } 65 }
66 66
67 // Overridden from ui::AcceleratorTarget: 67 // Overridden from ui::AcceleratorTarget:
68 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 68 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
69 virtual bool CanHandleAccelerators() const override; 69 bool CanHandleAccelerators() const override;
70 70
71 private: 71 private:
72 int accelerator_pressed_count_; 72 int accelerator_pressed_count_;
73 int accelerator_repeat_count_; 73 int accelerator_repeat_count_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(TestTarget); 75 DISALLOW_COPY_AND_ASSIGN(TestTarget);
76 }; 76 };
77 77
78 class ReleaseAccelerator : public ui::Accelerator { 78 class ReleaseAccelerator : public ui::Accelerator {
79 public: 79 public:
80 ReleaseAccelerator(ui::KeyboardCode keycode, int modifiers) 80 ReleaseAccelerator(ui::KeyboardCode keycode, int modifiers)
81 : ui::Accelerator(keycode, modifiers) { 81 : ui::Accelerator(keycode, modifiers) {
82 set_type(ui::ET_KEY_RELEASED); 82 set_type(ui::ET_KEY_RELEASED);
83 } 83 }
84 }; 84 };
85 85
86 class DummyBrightnessControlDelegate : public BrightnessControlDelegate { 86 class DummyBrightnessControlDelegate : public BrightnessControlDelegate {
87 public: 87 public:
88 explicit DummyBrightnessControlDelegate(bool consume) 88 explicit DummyBrightnessControlDelegate(bool consume)
89 : consume_(consume), 89 : consume_(consume),
90 handle_brightness_down_count_(0), 90 handle_brightness_down_count_(0),
91 handle_brightness_up_count_(0) { 91 handle_brightness_up_count_(0) {
92 } 92 }
93 virtual ~DummyBrightnessControlDelegate() {} 93 ~DummyBrightnessControlDelegate() override {}
94 94
95 virtual bool HandleBrightnessDown( 95 bool HandleBrightnessDown(const ui::Accelerator& accelerator) override {
96 const ui::Accelerator& accelerator) override {
97 ++handle_brightness_down_count_; 96 ++handle_brightness_down_count_;
98 last_accelerator_ = accelerator; 97 last_accelerator_ = accelerator;
99 return consume_; 98 return consume_;
100 } 99 }
101 virtual bool HandleBrightnessUp(const ui::Accelerator& accelerator) override { 100 bool HandleBrightnessUp(const ui::Accelerator& accelerator) override {
102 ++handle_brightness_up_count_; 101 ++handle_brightness_up_count_;
103 last_accelerator_ = accelerator; 102 last_accelerator_ = accelerator;
104 return consume_; 103 return consume_;
105 } 104 }
106 virtual void SetBrightnessPercent(double percent, bool gradual) override {} 105 void SetBrightnessPercent(double percent, bool gradual) override {}
107 virtual void GetBrightnessPercent( 106 void GetBrightnessPercent(
108 const base::Callback<void(double)>& callback) override { 107 const base::Callback<void(double)>& callback) override {
109 callback.Run(100.0); 108 callback.Run(100.0);
110 } 109 }
111 110
112 int handle_brightness_down_count() const { 111 int handle_brightness_down_count() const {
113 return handle_brightness_down_count_; 112 return handle_brightness_down_count_;
114 } 113 }
115 int handle_brightness_up_count() const { 114 int handle_brightness_up_count() const {
116 return handle_brightness_up_count_; 115 return handle_brightness_up_count_;
117 } 116 }
(...skipping 11 matching lines...) Expand all
129 }; 128 };
130 129
131 class DummyImeControlDelegate : public ImeControlDelegate { 130 class DummyImeControlDelegate : public ImeControlDelegate {
132 public: 131 public:
133 explicit DummyImeControlDelegate(bool consume) 132 explicit DummyImeControlDelegate(bool consume)
134 : consume_(consume), 133 : consume_(consume),
135 handle_next_ime_count_(0), 134 handle_next_ime_count_(0),
136 handle_previous_ime_count_(0), 135 handle_previous_ime_count_(0),
137 handle_switch_ime_count_(0) { 136 handle_switch_ime_count_(0) {
138 } 137 }
139 virtual ~DummyImeControlDelegate() {} 138 ~DummyImeControlDelegate() override {}
140 139
141 virtual void HandleNextIme() override { 140 void HandleNextIme() override { ++handle_next_ime_count_; }
142 ++handle_next_ime_count_; 141 bool HandlePreviousIme(const ui::Accelerator& accelerator) override {
143 }
144 virtual bool HandlePreviousIme(const ui::Accelerator& accelerator) override {
145 ++handle_previous_ime_count_; 142 ++handle_previous_ime_count_;
146 last_accelerator_ = accelerator; 143 last_accelerator_ = accelerator;
147 return consume_; 144 return consume_;
148 } 145 }
149 virtual bool HandleSwitchIme(const ui::Accelerator& accelerator) override { 146 bool HandleSwitchIme(const ui::Accelerator& accelerator) override {
150 ++handle_switch_ime_count_; 147 ++handle_switch_ime_count_;
151 last_accelerator_ = accelerator; 148 last_accelerator_ = accelerator;
152 return consume_; 149 return consume_;
153 } 150 }
154 151
155 int handle_next_ime_count() const { 152 int handle_next_ime_count() const {
156 return handle_next_ime_count_; 153 return handle_next_ime_count_;
157 } 154 }
158 int handle_previous_ime_count() const { 155 int handle_previous_ime_count() const {
159 return handle_previous_ime_count_; 156 return handle_previous_ime_count_;
160 } 157 }
161 int handle_switch_ime_count() const { 158 int handle_switch_ime_count() const {
162 return handle_switch_ime_count_; 159 return handle_switch_ime_count_;
163 } 160 }
164 const ui::Accelerator& last_accelerator() const { 161 const ui::Accelerator& last_accelerator() const {
165 return last_accelerator_; 162 return last_accelerator_;
166 } 163 }
167 virtual ui::Accelerator RemapAccelerator( 164 ui::Accelerator RemapAccelerator(
168 const ui::Accelerator& accelerator) override { 165 const ui::Accelerator& accelerator) override {
169 return ui::Accelerator(accelerator); 166 return ui::Accelerator(accelerator);
170 } 167 }
171 168
172 private: 169 private:
173 const bool consume_; 170 const bool consume_;
174 int handle_next_ime_count_; 171 int handle_next_ime_count_;
175 int handle_previous_ime_count_; 172 int handle_previous_ime_count_;
176 int handle_switch_ime_count_; 173 int handle_switch_ime_count_;
177 ui::Accelerator last_accelerator_; 174 ui::Accelerator last_accelerator_;
178 175
179 DISALLOW_COPY_AND_ASSIGN(DummyImeControlDelegate); 176 DISALLOW_COPY_AND_ASSIGN(DummyImeControlDelegate);
180 }; 177 };
181 178
182 class DummyKeyboardBrightnessControlDelegate 179 class DummyKeyboardBrightnessControlDelegate
183 : public KeyboardBrightnessControlDelegate { 180 : public KeyboardBrightnessControlDelegate {
184 public: 181 public:
185 explicit DummyKeyboardBrightnessControlDelegate(bool consume) 182 explicit DummyKeyboardBrightnessControlDelegate(bool consume)
186 : consume_(consume), 183 : consume_(consume),
187 handle_keyboard_brightness_down_count_(0), 184 handle_keyboard_brightness_down_count_(0),
188 handle_keyboard_brightness_up_count_(0) { 185 handle_keyboard_brightness_up_count_(0) {
189 } 186 }
190 virtual ~DummyKeyboardBrightnessControlDelegate() {} 187 ~DummyKeyboardBrightnessControlDelegate() override {}
191 188
192 virtual bool HandleKeyboardBrightnessDown( 189 bool HandleKeyboardBrightnessDown(
193 const ui::Accelerator& accelerator) override { 190 const ui::Accelerator& accelerator) override {
194 ++handle_keyboard_brightness_down_count_; 191 ++handle_keyboard_brightness_down_count_;
195 last_accelerator_ = accelerator; 192 last_accelerator_ = accelerator;
196 return consume_; 193 return consume_;
197 } 194 }
198 195
199 virtual bool HandleKeyboardBrightnessUp( 196 bool HandleKeyboardBrightnessUp(const ui::Accelerator& accelerator) override {
200 const ui::Accelerator& accelerator) override {
201 ++handle_keyboard_brightness_up_count_; 197 ++handle_keyboard_brightness_up_count_;
202 last_accelerator_ = accelerator; 198 last_accelerator_ = accelerator;
203 return consume_; 199 return consume_;
204 } 200 }
205 201
206 int handle_keyboard_brightness_down_count() const { 202 int handle_keyboard_brightness_down_count() const {
207 return handle_keyboard_brightness_down_count_; 203 return handle_keyboard_brightness_down_count_;
208 } 204 }
209 205
210 int handle_keyboard_brightness_up_count() const { 206 int handle_keyboard_brightness_up_count() const {
(...skipping 23 matching lines...) Expand all
234 230
235 bool TestTarget::CanHandleAccelerators() const { 231 bool TestTarget::CanHandleAccelerators() const {
236 return true; 232 return true;
237 } 233 }
238 234
239 } // namespace 235 } // namespace
240 236
241 class AcceleratorControllerTest : public test::AshTestBase { 237 class AcceleratorControllerTest : public test::AshTestBase {
242 public: 238 public:
243 AcceleratorControllerTest() {} 239 AcceleratorControllerTest() {}
244 virtual ~AcceleratorControllerTest() {} 240 ~AcceleratorControllerTest() override {}
245 241
246 protected: 242 protected:
247 void EnableInternalDisplay() { 243 void EnableInternalDisplay() {
248 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()). 244 test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()).
249 SetFirstDisplayAsInternalDisplay(); 245 SetFirstDisplayAsInternalDisplay();
250 } 246 }
251 247
252 static AcceleratorController* GetController(); 248 static AcceleratorController* GetController();
253 249
254 // Several functions to access ExitWarningHandler (as friend). 250 // Several functions to access ExitWarningHandler (as friend).
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); 1242 ui::Accelerator(ui::VKEY_A, ui::EF_NONE)));
1247 EXPECT_FALSE(GetController()->IsPreferred( 1243 EXPECT_FALSE(GetController()->IsPreferred(
1248 ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); 1244 ui::Accelerator(ui::VKEY_A, ui::EF_NONE)));
1249 } 1245 }
1250 1246
1251 namespace { 1247 namespace {
1252 1248
1253 class PreferredReservedAcceleratorsTest : public test::AshTestBase { 1249 class PreferredReservedAcceleratorsTest : public test::AshTestBase {
1254 public: 1250 public:
1255 PreferredReservedAcceleratorsTest() {} 1251 PreferredReservedAcceleratorsTest() {}
1256 virtual ~PreferredReservedAcceleratorsTest() {} 1252 ~PreferredReservedAcceleratorsTest() override {}
1257 1253
1258 // test::AshTestBase: 1254 // test::AshTestBase:
1259 virtual void SetUp() override { 1255 void SetUp() override {
1260 AshTestBase::SetUp(); 1256 AshTestBase::SetUp();
1261 Shell::GetInstance()->lock_state_controller()-> 1257 Shell::GetInstance()->lock_state_controller()->
1262 set_animator_for_test(new test::TestSessionStateAnimator); 1258 set_animator_for_test(new test::TestSessionStateAnimator);
1263 } 1259 }
1264 1260
1265 private: 1261 private:
1266 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); 1262 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest);
1267 }; 1263 };
1268 1264
1269 } // namespace 1265 } // namespace
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 1468 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
1473 wm::ActivateWindow(window.get()); 1469 wm::ActivateWindow(window.get());
1474 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); 1470 GetController()->PerformAction(WINDOW_MINIMIZE, dummy);
1475 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1471 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1476 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); 1472 GetController()->PerformAction(kActionsNeedingWindow[i], dummy);
1477 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); 1473 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED);
1478 } 1474 }
1479 } 1475 }
1480 1476
1481 } // namespace ash 1477 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.h ('k') | ash/accelerators/accelerator_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698