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

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

Issue 9242003: Handle Caps Lock short cut (Shift+Search) in ash [part 1 of 2]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('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 #include "ash/caps_lock_delegate.h"
6 #include "ash/ime/event.h" 7 #include "ash/ime/event.h"
7 #include "ash/screenshot_delegate.h" 8 #include "ash/screenshot_delegate.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
10 #include "ash/test/aura_shell_test_base.h" 11 #include "ash/test/aura_shell_test_base.h"
11 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
12 #include "ui/aura/event.h" 13 #include "ui/aura/event.h"
13 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
14 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/test/test_windows.h" 16 #include "ui/aura/test/test_windows.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 int handle_take_screenshot_count() const { 63 int handle_take_screenshot_count() const {
63 return handle_take_screenshot_count_; 64 return handle_take_screenshot_count_;
64 } 65 }
65 66
66 private: 67 private:
67 int handle_take_screenshot_count_; 68 int handle_take_screenshot_count_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(DummyScreenshotDelegate); 70 DISALLOW_COPY_AND_ASSIGN(DummyScreenshotDelegate);
70 }; 71 };
71 72
73 class DummyCapsLockDelegate : public CapsLockDelegate {
74 public:
75 explicit DummyCapsLockDelegate(bool consume)
76 : consume_(consume),
77 handle_caps_lock_count_(0) {
78 }
79 virtual ~DummyCapsLockDelegate() {}
80
81 virtual bool HandleToggleCapsLock() OVERRIDE {
82 ++handle_caps_lock_count_;
83 return consume_;
84 }
85
86 int handle_caps_lock_count() const {
87 return handle_caps_lock_count_;
88 }
89
90 private:
91 const bool consume_;
92 int handle_caps_lock_count_;
93
94 DISALLOW_COPY_AND_ASSIGN(DummyCapsLockDelegate);
95 };
96
72 bool TestTarget::AcceleratorPressed(const ui::Accelerator& accelerator) { 97 bool TestTarget::AcceleratorPressed(const ui::Accelerator& accelerator) {
73 ++accelerator_pressed_count_; 98 ++accelerator_pressed_count_;
74 return true; 99 return true;
75 } 100 }
76 101
77 bool TestTarget::CanHandleAccelerators() const { 102 bool TestTarget::CanHandleAccelerators() const {
78 return true; 103 return true;
79 } 104 }
80 105
81 } // namespace 106 } // namespace
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 ui::Accelerator(ui::VKEY_F5, true, false, false))); 266 ui::Accelerator(ui::VKEY_F5, true, false, false)));
242 EXPECT_TRUE(GetController()->Process( 267 EXPECT_TRUE(GetController()->Process(
243 ui::Accelerator(ui::VKEY_TAB, true, false, true))); 268 ui::Accelerator(ui::VKEY_TAB, true, false, true)));
244 // CycleForward 269 // CycleForward
245 EXPECT_TRUE(GetController()->Process( 270 EXPECT_TRUE(GetController()->Process(
246 ui::Accelerator(ui::VKEY_F5, false, false, false))); 271 ui::Accelerator(ui::VKEY_F5, false, false, false)));
247 EXPECT_TRUE(GetController()->Process( 272 EXPECT_TRUE(GetController()->Process(
248 ui::Accelerator(ui::VKEY_TAB, false, false, true))); 273 ui::Accelerator(ui::VKEY_TAB, false, false, true)));
249 // TakeScreenshot 274 // TakeScreenshot
250 // True should always be returned regardless of the existence of the delegate. 275 // True should always be returned regardless of the existence of the delegate.
251 EXPECT_TRUE(GetController()->Process( 276 {
252 ui::Accelerator(ui::VKEY_F5, false, true, false))); 277 EXPECT_TRUE(GetController()->Process(
253 EXPECT_TRUE(GetController()->Process( 278 ui::Accelerator(ui::VKEY_F5, false, true, false)));
254 ui::Accelerator(ui::VKEY_PRINT, false, false, false))); 279 EXPECT_TRUE(GetController()->Process(
255 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate; 280 ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
256 GetController()->SetScreenshotDelegate(delegate); 281 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
257 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); 282 GetController()->SetScreenshotDelegate(delegate);
258 EXPECT_TRUE(GetController()->Process( 283 EXPECT_EQ(0, delegate->handle_take_screenshot_count());
259 ui::Accelerator(ui::VKEY_F5, false, true, false))); 284 EXPECT_TRUE(GetController()->Process(
260 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); 285 ui::Accelerator(ui::VKEY_F5, false, true, false)));
261 EXPECT_TRUE(GetController()->Process( 286 EXPECT_EQ(1, delegate->handle_take_screenshot_count());
262 ui::Accelerator(ui::VKEY_PRINT, false, false, false))); 287 EXPECT_TRUE(GetController()->Process(
263 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 288 ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
289 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
290 }
291 // ToggleCapsLock
292 {
293 EXPECT_FALSE(GetController()->Process(
294 ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
295 DummyCapsLockDelegate* delegate = new DummyCapsLockDelegate(false);
296 GetController()->SetCapsLockDelegate(
297 scoped_ptr<CapsLockDelegate>(delegate).Pass());
298 EXPECT_EQ(0, delegate->handle_caps_lock_count());
299 EXPECT_FALSE(GetController()->Process(
300 ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
301 EXPECT_EQ(1, delegate->handle_caps_lock_count());
302 }
303 {
304 DummyCapsLockDelegate* delegate = new DummyCapsLockDelegate(true);
305 GetController()->SetCapsLockDelegate(
306 scoped_ptr<CapsLockDelegate>(delegate).Pass());
307 EXPECT_EQ(0, delegate->handle_caps_lock_count());
308 EXPECT_TRUE(GetController()->Process(
309 ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
310 EXPECT_EQ(1, delegate->handle_caps_lock_count());
311 }
264 #if !defined(NDEBUG) 312 #if !defined(NDEBUG)
265 // RotateScreen 313 // RotateScreen
266 EXPECT_TRUE(GetController()->Process( 314 EXPECT_TRUE(GetController()->Process(
267 ui::Accelerator(ui::VKEY_HOME, false, true, false))); 315 ui::Accelerator(ui::VKEY_HOME, false, true, false)));
268 #if !defined(OS_LINUX) 316 #if !defined(OS_LINUX)
269 // ToggleDesktopFullScreen (not implemented yet on Linux) 317 // ToggleDesktopFullScreen (not implemented yet on Linux)
270 EXPECT_TRUE(GetController()->Process( 318 EXPECT_TRUE(GetController()->Process(
271 ui::Accelerator(ui::VKEY_F11, false, true, false))); 319 ui::Accelerator(ui::VKEY_F11, false, true, false)));
272 #endif 320 #endif
273 #endif 321 #endif
274 } 322 }
275 323
276 } // namespace test 324 } // namespace test
277 } // namespace ash 325 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698