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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_controller_unittest.cc
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index e5dd5d96d372e4ec44b5c5426badc9ebb344b7d9..9f86b45738ccf1a88618350a60dfe76d2ba9ac63 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "ash/accelerators/accelerator_controller.h"
+#include "ash/caps_lock_delegate.h"
#include "ash/ime/event.h"
#include "ash/screenshot_delegate.h"
#include "ash/shell.h"
@@ -69,6 +70,30 @@ class DummyScreenshotDelegate : public ScreenshotDelegate {
DISALLOW_COPY_AND_ASSIGN(DummyScreenshotDelegate);
};
+class DummyCapsLockDelegate : public CapsLockDelegate {
+ public:
+ explicit DummyCapsLockDelegate(bool consume)
+ : consume_(consume),
+ handle_caps_lock_count_(0) {
+ }
+ virtual ~DummyCapsLockDelegate() {}
+
+ virtual bool HandleToggleCapsLock() OVERRIDE {
+ ++handle_caps_lock_count_;
+ return consume_;
+ }
+
+ int handle_caps_lock_count() const {
+ return handle_caps_lock_count_;
+ }
+
+ private:
+ const bool consume_;
+ int handle_caps_lock_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(DummyCapsLockDelegate);
+};
+
bool TestTarget::AcceleratorPressed(const ui::Accelerator& accelerator) {
++accelerator_pressed_count_;
return true;
@@ -248,19 +273,42 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
ui::Accelerator(ui::VKEY_TAB, false, false, true)));
// TakeScreenshot
// True should always be returned regardless of the existence of the delegate.
- EXPECT_TRUE(GetController()->Process(
- ui::Accelerator(ui::VKEY_F5, false, true, false)));
- EXPECT_TRUE(GetController()->Process(
- ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
- DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
- GetController()->SetScreenshotDelegate(delegate);
- EXPECT_EQ(0, delegate->handle_take_screenshot_count());
- EXPECT_TRUE(GetController()->Process(
- ui::Accelerator(ui::VKEY_F5, false, true, false)));
- EXPECT_EQ(1, delegate->handle_take_screenshot_count());
- EXPECT_TRUE(GetController()->Process(
- ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
- EXPECT_EQ(2, delegate->handle_take_screenshot_count());
+ {
+ EXPECT_TRUE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_F5, false, true, false)));
+ EXPECT_TRUE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
+ DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
+ GetController()->SetScreenshotDelegate(delegate);
+ EXPECT_EQ(0, delegate->handle_take_screenshot_count());
+ EXPECT_TRUE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_F5, false, true, false)));
+ EXPECT_EQ(1, delegate->handle_take_screenshot_count());
+ EXPECT_TRUE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_PRINT, false, false, false)));
+ EXPECT_EQ(2, delegate->handle_take_screenshot_count());
+ }
+ // ToggleCapsLock
+ {
+ EXPECT_FALSE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
+ DummyCapsLockDelegate* delegate = new DummyCapsLockDelegate(false);
+ GetController()->SetCapsLockDelegate(
+ scoped_ptr<CapsLockDelegate>(delegate).Pass());
+ EXPECT_EQ(0, delegate->handle_caps_lock_count());
+ EXPECT_FALSE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
+ EXPECT_EQ(1, delegate->handle_caps_lock_count());
+ }
+ {
+ DummyCapsLockDelegate* delegate = new DummyCapsLockDelegate(true);
+ GetController()->SetCapsLockDelegate(
+ scoped_ptr<CapsLockDelegate>(delegate).Pass());
+ EXPECT_EQ(0, delegate->handle_caps_lock_count());
+ EXPECT_TRUE(GetController()->Process(
+ ui::Accelerator(ui::VKEY_LWIN, true, false, false)));
+ EXPECT_EQ(1, delegate->handle_caps_lock_count());
+ }
#if !defined(NDEBUG)
// RotateScreen
EXPECT_TRUE(GetController()->Process(
« 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