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

Unified Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 10878058: Move functions for controlling Caps Lock to CapsLockDelegate from SystemTrayDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comment Created 8 years, 4 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 d78b750bd732321dd8befa2387dd0e8b0041118e..9173a60b569be185f2d837c70f29c04bcb08b493 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -93,30 +93,6 @@ 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);
-};
-
class DummyVolumeControlDelegate : public VolumeControlDelegate {
public:
explicit DummyVolumeControlDelegate(bool consume)
@@ -600,46 +576,50 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
EXPECT_TRUE(GetController()->Process(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE)));
}
- // DisableCapsLock
+ // CapsLock
Yusuke Sato 2012/08/27 16:45:39 What is this test for? Testing VKEY_[LR]?SHIFT for
mazda 2012/08/27 16:58:58 This block is testing DISABLE_CAPSLOCK and TOGGLE_
{
+ // Disable Caps Lock
+ CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate();
+ delegate->SetCapsLockEnabled(true);
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
// Handled only on key release.
EXPECT_FALSE(GetController()->Process(
ui::Accelerator(ui::VKEY_LSHIFT, ui::EF_NONE)));
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
EXPECT_TRUE(GetController()->Process(
ReleaseAccelerator(ui::VKEY_SHIFT, ui::EF_NONE)));
+ EXPECT_FALSE(delegate->IsCapsLockEnabled());
+ delegate->SetCapsLockEnabled(true);
EXPECT_FALSE(GetController()->Process(
ui::Accelerator(ui::VKEY_RSHIFT, ui::EF_NONE)));
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
EXPECT_TRUE(GetController()->Process(
ReleaseAccelerator(ui::VKEY_LSHIFT, ui::EF_NONE)));
+ EXPECT_FALSE(delegate->IsCapsLockEnabled());
+ delegate->SetCapsLockEnabled(true);
EXPECT_FALSE(GetController()->Process(
ui::Accelerator(ui::VKEY_SHIFT, ui::EF_NONE)));
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
EXPECT_TRUE(GetController()->Process(
ReleaseAccelerator(ui::VKEY_RSHIFT, ui::EF_NONE)));
+ EXPECT_FALSE(delegate->IsCapsLockEnabled());
// Do not handle when a shift pressed with other keys.
+ delegate->SetCapsLockEnabled(true);
EXPECT_FALSE(GetController()->Process(
- ReleaseAccelerator(ui::VKEY_A, ui::EF_SHIFT_DOWN)));
- }
- // ToggleCapsLock
- {
- EXPECT_FALSE(GetController()->Process(
- ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)));
- DummyCapsLockDelegate* delegate = new DummyCapsLockDelegate(false);
- GetController()->SetCapsLockDelegate(
- scoped_ptr<CapsLockDelegate>(delegate).Pass());
- EXPECT_EQ(0, delegate->handle_caps_lock_count());
+ ui::Accelerator(ui::VKEY_A, ui::EF_SHIFT_DOWN)));
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
EXPECT_FALSE(GetController()->Process(
+ ReleaseAccelerator(ui::VKEY_A, ui::EF_SHIFT_DOWN)));
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
+
+ // ToggleCapsLock
+ EXPECT_TRUE(GetController()->Process(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)));
- 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_FALSE(delegate->IsCapsLockEnabled());
EXPECT_TRUE(GetController()->Process(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)));
- EXPECT_EQ(1, delegate->handle_caps_lock_count());
+ EXPECT_TRUE(delegate->IsCapsLockEnabled());
}
// Volume
const ui::Accelerator f8(ui::VKEY_F8, ui::EF_NONE);
« 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