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

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

Issue 2891263002: chromeos: Remove some IME methods from ash::SystemTrayDelegate (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ime/ime_switch_type.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/accessibility_types.h" 9 #include "ash/accessibility_types.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/ime_control_delegate.h"
12 #include "ash/public/cpp/config.h" 11 #include "ash/public/cpp/config.h"
13 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
14 #include "ash/session/session_controller.h" 13 #include "ash/session/session_controller.h"
15 #include "ash/shell.h" 14 #include "ash/shell.h"
16 #include "ash/shell_port.h" 15 #include "ash/shell_port.h"
17 #include "ash/system/brightness_control_delegate.h" 16 #include "ash/system/brightness_control_delegate.h"
18 #include "ash/system/keyboard_brightness_control_delegate.h" 17 #include "ash/system/keyboard_brightness_control_delegate.h"
19 #include "ash/system/tray/system_tray_delegate.h" 18 #include "ash/system/tray/system_tray_delegate.h"
20 #include "ash/test/ash_test_base.h" 19 #include "ash/test/ash_test_base.h"
21 #include "ash/test/lock_state_controller_test_api.h" 20 #include "ash/test/lock_state_controller_test_api.h"
(...skipping 25 matching lines...) Expand all
47 #include "ui/events/event_sink.h" 46 #include "ui/events/event_sink.h"
48 #include "ui/events/test/event_generator.h" 47 #include "ui/events/test/event_generator.h"
49 #include "ui/message_center/message_center.h" 48 #include "ui/message_center/message_center.h"
50 #include "ui/views/widget/widget.h" 49 #include "ui/views/widget/widget.h"
51 50
52 #if defined(USE_X11) 51 #if defined(USE_X11)
53 #include <X11/Xlib.h> 52 #include <X11/Xlib.h>
54 #include "ui/events/test/events_test_utils_x11.h" 53 #include "ui/events/test/events_test_utils_x11.h"
55 #endif 54 #endif
56 55
56 using chromeos::input_method::InputMethodManager;
57
57 namespace ash { 58 namespace ash {
58 59
59 namespace { 60 namespace {
60 61
61 class TestTarget : public ui::AcceleratorTarget { 62 class TestTarget : public ui::AcceleratorTarget {
62 public: 63 public:
63 TestTarget() : accelerator_pressed_count_(0), accelerator_repeat_count_(0) {} 64 TestTarget() : accelerator_pressed_count_(0), accelerator_repeat_count_(0) {}
64 ~TestTarget() override {} 65 ~TestTarget() override {}
65 66
66 int accelerator_pressed_count() const { return accelerator_pressed_count_; } 67 int accelerator_pressed_count() const { return accelerator_pressed_count_; }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const ui::Accelerator& last_accelerator() const { return last_accelerator_; } 118 const ui::Accelerator& last_accelerator() const { return last_accelerator_; }
118 119
119 private: 120 private:
120 int handle_brightness_down_count_; 121 int handle_brightness_down_count_;
121 int handle_brightness_up_count_; 122 int handle_brightness_up_count_;
122 ui::Accelerator last_accelerator_; 123 ui::Accelerator last_accelerator_;
123 124
124 DISALLOW_COPY_AND_ASSIGN(DummyBrightnessControlDelegate); 125 DISALLOW_COPY_AND_ASSIGN(DummyBrightnessControlDelegate);
125 }; 126 };
126 127
127 class DummyImeControlDelegate : public ImeControlDelegate { 128 class TestInputMethodManagerState
129 : public chromeos::input_method::MockInputMethodManager::State {
128 public: 130 public:
129 DummyImeControlDelegate() 131 TestInputMethodManagerState() = default;
130 : handle_next_ime_count_(0),
131 handle_previous_ime_count_(0),
132 handle_switch_ime_count_(0) {}
133 ~DummyImeControlDelegate() override {}
134 132
135 bool CanCycleIme() override { return true; } 133 // InputMethodManager::State:
136 void HandleNextIme() override { ++handle_next_ime_count_; } 134 bool CanCycleInputMethod() override { return can_change_input_method_; }
137 void HandlePreviousIme() override { ++handle_previous_ime_count_; } 135 void SwitchToNextInputMethod() override { next_ime_count_++; }
138 bool CanSwitchIme(const ui::Accelerator& accelerator) override { 136 void SwitchToPreviousInputMethod() override { previous_ime_count_++; }
139 return true; 137 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override {
138 return can_change_input_method_;
140 } 139 }
141 void HandleSwitchIme(const ui::Accelerator& accelerator) override { 140 void SwitchInputMethod(const ui::Accelerator& accelerator) override {
142 ++handle_switch_ime_count_; 141 switch_ime_count_++;
143 } 142 }
144 143
145 int handle_next_ime_count() const { return handle_next_ime_count_; } 144 bool can_change_input_method_ = true;
146 int handle_previous_ime_count() const { return handle_previous_ime_count_; } 145 int next_ime_count_ = 0;
147 int handle_switch_ime_count() const { return handle_switch_ime_count_; } 146 int previous_ime_count_ = 0;
147 int switch_ime_count_ = 0;
148 148
149 private: 149 private:
150 int handle_next_ime_count_; 150 // Base class is ref-counted.
151 int handle_previous_ime_count_; 151 ~TestInputMethodManagerState() override = default;
152 int handle_switch_ime_count_;
153 152
154 DISALLOW_COPY_AND_ASSIGN(DummyImeControlDelegate); 153 DISALLOW_COPY_AND_ASSIGN(TestInputMethodManagerState);
154 };
155
156 class TestInputMethodManager
157 : public chromeos::input_method::MockInputMethodManager {
158 public:
159 TestInputMethodManager() : state_(new TestInputMethodManagerState) {}
160 ~TestInputMethodManager() override = default;
161
162 void SetCanChangeInputMethod(bool can_change) {
163 state_->can_change_input_method_ = can_change;
164 }
165
166 // MockInputMethodManager:
167 chromeos::input_method::ImeKeyboard* GetImeKeyboard() override {
168 return &keyboard_;
169 }
170 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override {
171 return state_;
172 }
173
174 chromeos::input_method::FakeImeKeyboard keyboard_;
175 scoped_refptr<TestInputMethodManagerState> state_;
176
177 private:
178 DISALLOW_COPY_AND_ASSIGN(TestInputMethodManager);
155 }; 179 };
156 180
157 class DummyKeyboardBrightnessControlDelegate 181 class DummyKeyboardBrightnessControlDelegate
158 : public KeyboardBrightnessControlDelegate { 182 : public KeyboardBrightnessControlDelegate {
159 public: 183 public:
160 DummyKeyboardBrightnessControlDelegate() 184 DummyKeyboardBrightnessControlDelegate()
161 : handle_keyboard_brightness_down_count_(0), 185 : handle_keyboard_brightness_down_count_(0),
162 handle_keyboard_brightness_up_count_(0) {} 186 handle_keyboard_brightness_up_count_(0) {}
163 ~DummyKeyboardBrightnessControlDelegate() override {} 187 ~DummyKeyboardBrightnessControlDelegate() override {}
164 188
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 224 }
201 225
202 bool TestTarget::CanHandleAccelerators() const { 226 bool TestTarget::CanHandleAccelerators() const {
203 return true; 227 return true;
204 } 228 }
205 229
206 } // namespace 230 } // namespace
207 231
208 class AcceleratorControllerTest : public test::AshTestBase { 232 class AcceleratorControllerTest : public test::AshTestBase {
209 public: 233 public:
210 AcceleratorControllerTest() {} 234 AcceleratorControllerTest() = default;
211 ~AcceleratorControllerTest() override {} 235 ~AcceleratorControllerTest() override = default;
236
237 void SetUp() override {
238 test::AshTestBase::SetUp();
239 test_input_method_manager_ = new TestInputMethodManager;
240 // Takes ownership.
241 InputMethodManager::Initialize(test_input_method_manager_);
242 }
243
244 void TearDown() override {
245 InputMethodManager::Shutdown();
246 test::AshTestBase::TearDown();
247 }
212 248
213 protected: 249 protected:
214 static AcceleratorController* GetController(); 250 static AcceleratorController* GetController();
215 251
216 static bool ProcessInController(const ui::Accelerator& accelerator) { 252 static bool ProcessInController(const ui::Accelerator& accelerator) {
217 if (accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { 253 if (accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) {
218 // If the |accelerator| should trigger on release, then we store the 254 // If the |accelerator| should trigger on release, then we store the
219 // pressed version of it first in history then the released one to 255 // pressed version of it first in history then the released one to
220 // simulate what happens in reality. 256 // simulate what happens in reality.
221 ui::Accelerator pressed_accelerator = accelerator; 257 ui::Accelerator pressed_accelerator = accelerator;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void SetBrightnessControlDelegate( 293 void SetBrightnessControlDelegate(
258 std::unique_ptr<BrightnessControlDelegate> delegate) { 294 std::unique_ptr<BrightnessControlDelegate> delegate) {
259 Shell::Get()->brightness_control_delegate_ = std::move(delegate); 295 Shell::Get()->brightness_control_delegate_ = std::move(delegate);
260 } 296 }
261 297
262 void SetKeyboardBrightnessControlDelegate( 298 void SetKeyboardBrightnessControlDelegate(
263 std::unique_ptr<KeyboardBrightnessControlDelegate> delegate) { 299 std::unique_ptr<KeyboardBrightnessControlDelegate> delegate) {
264 Shell::Get()->keyboard_brightness_control_delegate_ = std::move(delegate); 300 Shell::Get()->keyboard_brightness_control_delegate_ = std::move(delegate);
265 } 301 }
266 302
303 // Owned by InputMethodManager.
304 TestInputMethodManager* test_input_method_manager_ = nullptr;
305
267 private: 306 private:
268 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest); 307 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest);
269 }; 308 };
270 309
271 AcceleratorController* AcceleratorControllerTest::GetController() { 310 AcceleratorController* AcceleratorControllerTest::GetController() {
272 return Shell::Get()->accelerator_controller(); 311 return Shell::Get()->accelerator_controller();
273 } 312 }
274 313
275 // Double press of exit shortcut => exiting 314 // Double press of exit shortcut => exiting
276 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestDoublePress) { 315 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestDoublePress) {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); 881 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE)));
843 RunAllPendingInMessageLoop(); 882 RunAllPendingInMessageLoop();
844 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); 883 EXPECT_EQ(3u, test_app_list_presenter.toggle_count());
845 EXPECT_FALSE(ProcessInController( 884 EXPECT_FALSE(ProcessInController(
846 CreateReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); 885 CreateReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE)));
847 RunAllPendingInMessageLoop(); 886 RunAllPendingInMessageLoop();
848 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); 887 EXPECT_EQ(3u, test_app_list_presenter.toggle_count());
849 } 888 }
850 889
851 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { 890 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) {
852 // Test IME shortcuts. 891 TestInputMethodManagerState* test_state =
892 test_input_method_manager_->state_.get();
893
894 // Test IME shortcuts when cycling IME is blocked.
895 test_state->can_change_input_method_ = false;
853 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 896 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
854 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); 897 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN);
855 control_space_up.set_key_state(ui::Accelerator::KeyState::RELEASED); 898 control_space_up.set_key_state(ui::Accelerator::KeyState::RELEASED);
856 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); 899 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE);
857 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); 900 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE);
858 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); 901 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE);
859 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); 902 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE);
860 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); 903 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE);
861 EXPECT_FALSE(ProcessInController(control_space_down)); 904 EXPECT_FALSE(ProcessInController(control_space_down));
862 EXPECT_FALSE(ProcessInController(control_space_up)); 905 EXPECT_FALSE(ProcessInController(control_space_up));
863 EXPECT_FALSE(ProcessInController(convert)); 906 EXPECT_FALSE(ProcessInController(convert));
864 EXPECT_FALSE(ProcessInController(non_convert)); 907 EXPECT_FALSE(ProcessInController(non_convert));
865 EXPECT_FALSE(ProcessInController(wide_half_1)); 908 EXPECT_FALSE(ProcessInController(wide_half_1));
866 EXPECT_FALSE(ProcessInController(wide_half_2)); 909 EXPECT_FALSE(ProcessInController(wide_half_2));
867 EXPECT_FALSE(ProcessInController(hangul)); 910 EXPECT_FALSE(ProcessInController(hangul));
868 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; 911
869 GetController()->SetImeControlDelegate( 912 // Test IME shortcuts when cycling IME is allowed.
870 std::unique_ptr<ImeControlDelegate>(delegate)); 913 test_state->can_change_input_method_ = true;
871 EXPECT_EQ(0, delegate->handle_previous_ime_count()); 914 EXPECT_EQ(0, test_state->previous_ime_count_);
872 EXPECT_TRUE(ProcessInController(control_space_down)); 915 EXPECT_TRUE(ProcessInController(control_space_down));
873 EXPECT_EQ(1, delegate->handle_previous_ime_count()); 916 EXPECT_EQ(1, test_state->previous_ime_count_);
874 EXPECT_TRUE(ProcessInController(control_space_up)); 917 EXPECT_TRUE(ProcessInController(control_space_up));
875 EXPECT_EQ(1, delegate->handle_previous_ime_count()); 918 EXPECT_EQ(1, test_state->previous_ime_count_);
876 EXPECT_EQ(0, delegate->handle_switch_ime_count()); 919 EXPECT_EQ(0, test_state->switch_ime_count_);
877 EXPECT_TRUE(ProcessInController(convert)); 920 EXPECT_TRUE(ProcessInController(convert));
878 EXPECT_EQ(1, delegate->handle_switch_ime_count()); 921 EXPECT_EQ(1, test_state->switch_ime_count_);
879 EXPECT_TRUE(ProcessInController(non_convert)); 922 EXPECT_TRUE(ProcessInController(non_convert));
880 EXPECT_EQ(2, delegate->handle_switch_ime_count()); 923 EXPECT_EQ(2, test_state->switch_ime_count_);
881 EXPECT_TRUE(ProcessInController(wide_half_1)); 924 EXPECT_TRUE(ProcessInController(wide_half_1));
882 EXPECT_EQ(3, delegate->handle_switch_ime_count()); 925 EXPECT_EQ(3, test_state->switch_ime_count_);
883 EXPECT_TRUE(ProcessInController(wide_half_2)); 926 EXPECT_TRUE(ProcessInController(wide_half_2));
884 EXPECT_EQ(4, delegate->handle_switch_ime_count()); 927 EXPECT_EQ(4, test_state->switch_ime_count_);
885 EXPECT_TRUE(ProcessInController(hangul)); 928 EXPECT_TRUE(ProcessInController(hangul));
886 EXPECT_EQ(5, delegate->handle_switch_ime_count()); 929 EXPECT_EQ(5, test_state->switch_ime_count_);
887 } 930 }
888 931
889 // TODO(nona|mazda): Remove this when crbug.com/139556 in a better way. 932 // TODO(nona|mazda): Remove this when crbug.com/139556 in a better way.
890 TEST_F(AcceleratorControllerTest, ImeGlobalAcceleratorsWorkaround139556) { 933 TEST_F(AcceleratorControllerTest, ImeGlobalAcceleratorsWorkaround139556) {
891 // The workaround for crbug.com/139556 depends on the fact that we don't 934 // The workaround for crbug.com/139556 depends on the fact that we don't
892 // use Shift+Alt+Enter/Space with ET_KEY_PRESSED as an accelerator. Test it. 935 // use Shift+Alt+Enter/Space with ET_KEY_PRESSED as an accelerator. Test it.
893 const ui::Accelerator shift_alt_return_press( 936 const ui::Accelerator shift_alt_return_press(
894 ui::VKEY_RETURN, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); 937 ui::VKEY_RETURN, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN);
895 EXPECT_FALSE(ProcessInController(shift_alt_return_press)); 938 EXPECT_FALSE(ProcessInController(shift_alt_return_press));
896 const ui::Accelerator shift_alt_space_press( 939 const ui::Accelerator shift_alt_space_press(
(...skipping 28 matching lines...) Expand all
925 EXPECT_FALSE( 968 EXPECT_FALSE(
926 GetController()->IsPreferred(ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE))); 969 GetController()->IsPreferred(ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE)));
927 EXPECT_FALSE( 970 EXPECT_FALSE(
928 GetController()->IsReserved(ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); 971 GetController()->IsReserved(ui::Accelerator(ui::VKEY_A, ui::EF_NONE)));
929 EXPECT_FALSE( 972 EXPECT_FALSE(
930 GetController()->IsPreferred(ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); 973 GetController()->IsPreferred(ui::Accelerator(ui::VKEY_A, ui::EF_NONE)));
931 } 974 }
932 975
933 namespace { 976 namespace {
934 977
935 class TestInputMethodManager
936 : public chromeos::input_method::MockInputMethodManager {
937 public:
938 TestInputMethodManager() = default;
939 ~TestInputMethodManager() override = default;
940
941 // MockInputMethodManager:
942 chromeos::input_method::ImeKeyboard* GetImeKeyboard() override {
943 return &keyboard_;
944 }
945
946 private:
947 chromeos::input_method::FakeImeKeyboard keyboard_;
948
949 DISALLOW_COPY_AND_ASSIGN(TestInputMethodManager);
950 };
951
952 class ToggleCapsLockTest : public AcceleratorControllerTest {
953 public:
954 ToggleCapsLockTest() = default;
955 ~ToggleCapsLockTest() override = default;
956
957 void SetUp() override {
958 AcceleratorControllerTest::SetUp();
959 chromeos::input_method::InputMethodManager::Initialize(
960 new TestInputMethodManager);
961 }
962
963 void TearDown() override {
964 chromeos::input_method::InputMethodManager::Shutdown();
965 AcceleratorControllerTest::TearDown();
966 }
967
968 private:
969 DISALLOW_COPY_AND_ASSIGN(ToggleCapsLockTest);
970 };
971
972 // Tests the five combinations of the TOGGLE_CAPS_LOCK accelerator. 978 // Tests the five combinations of the TOGGLE_CAPS_LOCK accelerator.
973 TEST_F(ToggleCapsLockTest, ToggleCapsLockAccelerators) { 979 TEST_F(AcceleratorControllerTest, ToggleCapsLockAccelerators) {
974 chromeos::input_method::InputMethodManager* input_method_manager = 980 chromeos::input_method::InputMethodManager* input_method_manager =
975 chromeos::input_method::InputMethodManager::Get(); 981 chromeos::input_method::InputMethodManager::Get();
976 ASSERT_TRUE(input_method_manager); 982 ASSERT_TRUE(input_method_manager);
977 EXPECT_FALSE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); 983 EXPECT_FALSE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled());
978 984
979 // 1. Press Alt, Press Search, Release Search, Release Alt. 985 // 1. Press Alt, Press Search, Release Search, Release Alt.
980 // Note when you press Alt then press search, the key_code at this point is 986 // Note when you press Alt then press search, the key_code at this point is
981 // VKEY_LWIN (for search) and Alt is the modifier. 987 // VKEY_LWIN (for search) and Alt is the modifier.
982 const ui::Accelerator press_alt_then_search(ui::VKEY_LWIN, ui::EF_ALT_DOWN); 988 const ui::Accelerator press_alt_then_search(ui::VKEY_LWIN, ui::EF_ALT_DOWN);
983 EXPECT_FALSE(ProcessInController(press_alt_then_search)); 989 EXPECT_FALSE(ProcessInController(press_alt_then_search));
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); 1261 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]);
1256 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); 1262 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED);
1257 } 1263 }
1258 } 1264 }
1259 1265
1260 namespace { 1266 namespace {
1261 1267
1262 // defines a class to test the behavior of deprecated accelerators. 1268 // defines a class to test the behavior of deprecated accelerators.
1263 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { 1269 class DeprecatedAcceleratorTester : public AcceleratorControllerTest {
1264 public: 1270 public:
1265 DeprecatedAcceleratorTester() {} 1271 DeprecatedAcceleratorTester() = default;
1266 ~DeprecatedAcceleratorTester() override {} 1272 ~DeprecatedAcceleratorTester() override = default;
1267
1268 void SetUp() override {
1269 AcceleratorControllerTest::SetUp();
1270
1271 // For testing the deprecated and new IME shortcuts.
1272 DummyImeControlDelegate* delegate = new DummyImeControlDelegate;
1273 GetController()->SetImeControlDelegate(
1274 std::unique_ptr<ImeControlDelegate>(delegate));
1275 }
1276 1273
1277 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const { 1274 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const {
1278 ui::Accelerator result(data.keycode, data.modifiers); 1275 ui::Accelerator result(data.keycode, data.modifiers);
1279 result.set_key_state(data.trigger_on_press 1276 result.set_key_state(data.trigger_on_press
1280 ? ui::Accelerator::KeyState::PRESSED 1277 ? ui::Accelerator::KeyState::PRESSED
1281 : ui::Accelerator::KeyState::RELEASED); 1278 : ui::Accelerator::KeyState::RELEASED);
1282 return result; 1279 return result;
1283 } 1280 }
1284 1281
1285 void ResetStateIfNeeded() { 1282 void ResetStateIfNeeded() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 // Expect no notifications from the new accelerators. 1357 // Expect no notifications from the new accelerators.
1361 EXPECT_TRUE(IsMessageCenterEmpty()); 1358 EXPECT_TRUE(IsMessageCenterEmpty());
1362 1359
1363 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1360 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1364 // screen before we proceed testing the rest of accelerators. 1361 // screen before we proceed testing the rest of accelerators.
1365 ResetStateIfNeeded(); 1362 ResetStateIfNeeded();
1366 } 1363 }
1367 } 1364 }
1368 1365
1369 } // namespace ash 1366 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ime/ime_switch_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698