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

Side by Side Diff: chrome/browser/ui/views/aura/caps_lock_handler_browsertest.cc

Issue 9225004: Handle Caps Lock short cut (Shift+Search) in ash [part 2 of 2]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/aura/caps_lock_handler.h"
6 #include "chrome/test/base/in_process_browser_test.h"
7 #include "chrome/test/base/ui_test_utils.h"
8
9 #if defined(OS_CHROMEOS)
10 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
11 using namespace chromeos::input_method;
12 #endif
13
14 namespace {
15
16 #if defined(OS_CHROMEOS)
17 class DummyXKeyboard : public XKeyboard {
18 public:
19 explicit DummyXKeyboard(bool initial_caps_lock_state)
20 : caps_lock_is_enabled_(initial_caps_lock_state) {}
21 virtual ~DummyXKeyboard() {}
22
23 // Overridden from chrome::input_method::XKeyboard:
24 virtual bool SetCurrentKeyboardLayoutByName(
25 const std::string& layout_name) OVERRIDE {
26 return true;
27 }
28 virtual bool RemapModifierKeys(const ModifierMap& modifier_map) OVERRIDE {
29 return true;
30 }
31 virtual bool ReapplyCurrentKeyboardLayout() OVERRIDE {
32 return true;
33 }
34 virtual void ReapplyCurrentModifierLockStatus() OVERRIDE {}
35 virtual void SetLockedModifiers(
36 ModifierLockStatus new_caps_lock_status,
37 ModifierLockStatus new_num_lock_status) OVERRIDE {}
38 virtual void SetNumLockEnabled(bool enable_num_lock) OVERRIDE {}
39 virtual void SetCapsLockEnabled(bool enable_caps_lock) OVERRIDE {
40 caps_lock_is_enabled_ = enable_caps_lock;
41 }
42 virtual bool NumLockIsEnabled() OVERRIDE {
43 return true;
44 }
45 virtual bool CapsLockIsEnabled() OVERRIDE {
46 return caps_lock_is_enabled_;
47 }
48 virtual std::string CreateFullXkbLayoutName(
49 const std::string& layout_name,
50 const ModifierMap& modifire_map) OVERRIDE {
51 return "";
52 }
53 virtual unsigned int GetNumLockMask() OVERRIDE {
54 return 0;
55 }
56 virtual void GetLockedModifiers(bool* out_caps_lock_enabled,
57 bool* out_num_lock_enabled) OVERRIDE {}
58
59 private:
60 bool caps_lock_is_enabled_;
61
62 DISALLOW_COPY_AND_ASSIGN(DummyXKeyboard);
63 };
64
65 class CapsLockHandlerTest : public InProcessBrowserTest {
66 public:
67 CapsLockHandlerTest()
68 : initial_caps_lock_state_(false),
69 xkeyboard_(initial_caps_lock_state_) {
70 }
71 virtual void SetUp() OVERRIDE {
72 handler_.reset(new CapsLockHandler(&xkeyboard_));
73 // Force CapsLockHandler::HandleToggleCapsLock() to toggle the lock state.
74 handler_->set_is_running_on_chromeos_for_test(true);
75 }
76 virtual void TearDown() OVERRIDE {
77 handler_.reset();
78 }
79
80 protected:
81 const bool initial_caps_lock_state_;
82 DummyXKeyboard xkeyboard_;
83 scoped_ptr<CapsLockHandler> handler_;
84
85 DISALLOW_COPY_AND_ASSIGN(CapsLockHandlerTest);
86 };
87 #endif
88
89 } // namespace
90
91 // Check if HandleToggleCapsLock() really changes the lock state.
92 IN_PROC_BROWSER_TEST_F(CapsLockHandlerTest, TestCapsLock) {
93 #if defined(OS_CHROMEOS)
94 EXPECT_EQ(initial_caps_lock_state_, handler_->caps_lock_is_on_for_test());
95 EXPECT_TRUE(handler_->HandleToggleCapsLock());
96 EXPECT_EQ(!initial_caps_lock_state_, xkeyboard_.CapsLockIsEnabled());
97 handler_->OnCapsLockChange(!initial_caps_lock_state_);
98 EXPECT_EQ(!initial_caps_lock_state_, handler_->caps_lock_is_on_for_test());
99 EXPECT_TRUE(handler_->HandleToggleCapsLock());
100 handler_->OnCapsLockChange(initial_caps_lock_state_);
101 EXPECT_EQ(initial_caps_lock_state_, xkeyboard_.CapsLockIsEnabled());
102 EXPECT_EQ(initial_caps_lock_state_, handler_->caps_lock_is_on_for_test());
103 #endif
104 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/aura/caps_lock_handler.cc ('k') | chrome/browser/ui/views/aura/screenshot_taker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698