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

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

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