OLD | NEW |
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 "chrome/browser/ui/ash/event_rewriter.h" | 5 #include "chrome/browser/ui/ash/event_rewriter.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "chrome/browser/api/prefs/pref_member.h" | 10 #include "chrome/browser/api/prefs/pref_member.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 keycode_backspace_(XKeysymToKeycode(display_, XK_BackSpace)), | 110 keycode_backspace_(XKeysymToKeycode(display_, XK_BackSpace)), |
111 keycode_up_(XKeysymToKeycode(display_, XK_Up)), | 111 keycode_up_(XKeysymToKeycode(display_, XK_Up)), |
112 keycode_down_(XKeysymToKeycode(display_, XK_Down)), | 112 keycode_down_(XKeysymToKeycode(display_, XK_Down)), |
113 keycode_left_(XKeysymToKeycode(display_, XK_Left)), | 113 keycode_left_(XKeysymToKeycode(display_, XK_Left)), |
114 keycode_right_(XKeysymToKeycode(display_, XK_Right)), | 114 keycode_right_(XKeysymToKeycode(display_, XK_Right)), |
115 keycode_prior_(XKeysymToKeycode(display_, XK_Prior)), | 115 keycode_prior_(XKeysymToKeycode(display_, XK_Prior)), |
116 keycode_next_(XKeysymToKeycode(display_, XK_Next)), | 116 keycode_next_(XKeysymToKeycode(display_, XK_Next)), |
117 keycode_home_(XKeysymToKeycode(display_, XK_Home)), | 117 keycode_home_(XKeysymToKeycode(display_, XK_Home)), |
118 keycode_end_(XKeysymToKeycode(display_, XK_End)), | 118 keycode_end_(XKeysymToKeycode(display_, XK_End)), |
119 keycode_launch7_(XKeysymToKeycode(display_, XF86XK_Launch7)), | 119 keycode_launch7_(XKeysymToKeycode(display_, XF86XK_Launch7)), |
| 120 keycode_f1_(XKeysymToKeycode(display_, XK_F1)), |
| 121 keycode_f2_(XKeysymToKeycode(display_, XK_F2)), |
| 122 keycode_f3_(XKeysymToKeycode(display_, XK_F3)), |
| 123 keycode_f4_(XKeysymToKeycode(display_, XK_F4)), |
| 124 keycode_f5_(XKeysymToKeycode(display_, XK_F5)), |
| 125 keycode_f6_(XKeysymToKeycode(display_, XK_F6)), |
| 126 keycode_f7_(XKeysymToKeycode(display_, XK_F7)), |
| 127 keycode_f8_(XKeysymToKeycode(display_, XK_F8)), |
| 128 keycode_f9_(XKeysymToKeycode(display_, XK_F9)), |
| 129 keycode_f10_(XKeysymToKeycode(display_, XK_F10)), |
| 130 keycode_f11_(XKeysymToKeycode(display_, XK_F11)), |
| 131 keycode_f12_(XKeysymToKeycode(display_, XK_F12)), |
| 132 keycode_browser_back_(XKeysymToKeycode(display_, XF86XK_Back)), |
| 133 keycode_browser_forward_(XKeysymToKeycode(display_, XF86XK_Forward)), |
| 134 keycode_browser_refresh_(XKeysymToKeycode(display_, XF86XK_Reload)), |
| 135 keycode_media_launch_app1_(XKeysymToKeycode(display_, XF86XK_LaunchA)), |
| 136 keycode_media_launch_app2_(XKeysymToKeycode(display_, XF86XK_LaunchB)), |
| 137 keycode_brightness_down_(XKeysymToKeycode( |
| 138 display_, XF86XK_MonBrightnessDown)), |
| 139 keycode_brightness_up_(XKeysymToKeycode( |
| 140 display_, XF86XK_MonBrightnessUp)), |
| 141 keycode_volume_mute_(XKeysymToKeycode(display_, XF86XK_AudioMute)), |
| 142 keycode_volume_down_(XKeysymToKeycode( |
| 143 display_, XF86XK_AudioLowerVolume)), |
| 144 keycode_volume_up_(XKeysymToKeycode( |
| 145 display_, XF86XK_AudioRaiseVolume)), |
| 146 keycode_power_(XKeysymToKeycode(display_, XF86XK_PowerOff)), |
| 147 keycode_1_(XKeysymToKeycode(display_, XK_1)), |
| 148 keycode_2_(XKeysymToKeycode(display_, XK_2)), |
| 149 keycode_3_(XKeysymToKeycode(display_, XK_3)), |
| 150 keycode_4_(XKeysymToKeycode(display_, XK_4)), |
| 151 keycode_5_(XKeysymToKeycode(display_, XK_5)), |
| 152 keycode_6_(XKeysymToKeycode(display_, XK_6)), |
| 153 keycode_7_(XKeysymToKeycode(display_, XK_7)), |
| 154 keycode_8_(XKeysymToKeycode(display_, XK_8)), |
| 155 keycode_9_(XKeysymToKeycode(display_, XK_9)), |
| 156 keycode_0_(XKeysymToKeycode(display_, XK_0)), |
| 157 keycode_minus_(XKeysymToKeycode(display_, XK_minus)), |
| 158 keycode_equal_(XKeysymToKeycode(display_, XK_equal)), |
120 input_method_manager_mock_(NULL) { | 159 input_method_manager_mock_(NULL) { |
121 } | 160 } |
122 virtual ~EventRewriterTest() {} | 161 virtual ~EventRewriterTest() {} |
123 | 162 |
124 virtual void SetUp() { | 163 virtual void SetUp() { |
125 // Mocking user manager because the real one needs to be called on UI thread | 164 // Mocking user manager because the real one needs to be called on UI thread |
126 EXPECT_CALL(*user_manager_mock_.user_manager(), IsLoggedInAsGuest()) | 165 EXPECT_CALL(*user_manager_mock_.user_manager(), IsLoggedInAsGuest()) |
127 .WillRepeatedly(testing::Return(false)); | 166 .WillRepeatedly(testing::Return(false)); |
128 input_method_manager_mock_ = | 167 input_method_manager_mock_ = |
129 new chromeos::input_method::MockInputMethodManager; | 168 new chromeos::input_method::MockInputMethodManager; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const KeyCode keycode_backspace_; | 215 const KeyCode keycode_backspace_; |
177 const KeyCode keycode_up_; | 216 const KeyCode keycode_up_; |
178 const KeyCode keycode_down_; | 217 const KeyCode keycode_down_; |
179 const KeyCode keycode_left_; | 218 const KeyCode keycode_left_; |
180 const KeyCode keycode_right_; | 219 const KeyCode keycode_right_; |
181 const KeyCode keycode_prior_; | 220 const KeyCode keycode_prior_; |
182 const KeyCode keycode_next_; | 221 const KeyCode keycode_next_; |
183 const KeyCode keycode_home_; | 222 const KeyCode keycode_home_; |
184 const KeyCode keycode_end_; | 223 const KeyCode keycode_end_; |
185 const KeyCode keycode_launch7_; // F16 | 224 const KeyCode keycode_launch7_; // F16 |
| 225 const KeyCode keycode_f1_; |
| 226 const KeyCode keycode_f2_; |
| 227 const KeyCode keycode_f3_; |
| 228 const KeyCode keycode_f4_; |
| 229 const KeyCode keycode_f5_; |
| 230 const KeyCode keycode_f6_; |
| 231 const KeyCode keycode_f7_; |
| 232 const KeyCode keycode_f8_; |
| 233 const KeyCode keycode_f9_; |
| 234 const KeyCode keycode_f10_; |
| 235 const KeyCode keycode_f11_; |
| 236 const KeyCode keycode_f12_; |
| 237 const KeyCode keycode_browser_back_; |
| 238 const KeyCode keycode_browser_forward_; |
| 239 const KeyCode keycode_browser_refresh_; |
| 240 const KeyCode keycode_media_launch_app1_; |
| 241 const KeyCode keycode_media_launch_app2_; |
| 242 const KeyCode keycode_brightness_down_; |
| 243 const KeyCode keycode_brightness_up_; |
| 244 const KeyCode keycode_volume_mute_; |
| 245 const KeyCode keycode_volume_down_; |
| 246 const KeyCode keycode_volume_up_; |
| 247 const KeyCode keycode_power_; |
| 248 const KeyCode keycode_1_; |
| 249 const KeyCode keycode_2_; |
| 250 const KeyCode keycode_3_; |
| 251 const KeyCode keycode_4_; |
| 252 const KeyCode keycode_5_; |
| 253 const KeyCode keycode_6_; |
| 254 const KeyCode keycode_7_; |
| 255 const KeyCode keycode_8_; |
| 256 const KeyCode keycode_9_; |
| 257 const KeyCode keycode_0_; |
| 258 const KeyCode keycode_minus_; |
| 259 const KeyCode keycode_equal_; |
186 chromeos::ScopedMockUserManagerEnabler user_manager_mock_; | 260 chromeos::ScopedMockUserManagerEnabler user_manager_mock_; |
187 chromeos::input_method::MockInputMethodManager* input_method_manager_mock_; | 261 chromeos::input_method::MockInputMethodManager* input_method_manager_mock_; |
188 }; | 262 }; |
189 | 263 |
190 } // namespace | 264 } // namespace |
191 #else | 265 #else |
192 class EventRewriterTest : public testing::Test { | 266 class EventRewriterTest : public testing::Test { |
193 public: | 267 public: |
194 EventRewriterTest() {} | 268 EventRewriterTest() {} |
195 virtual ~EventRewriterTest() {} | 269 virtual ~EventRewriterTest() {} |
(...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 GetRewrittenEventAsString(&rewriter, | 2061 GetRewrittenEventAsString(&rewriter, |
1988 ui::VKEY_RIGHT, | 2062 ui::VKEY_RIGHT, |
1989 0, | 2063 0, |
1990 ui::ET_KEY_PRESSED, | 2064 ui::ET_KEY_PRESSED, |
1991 keycode_right_, | 2065 keycode_right_, |
1992 Mod4Mask | ControlMask)); | 2066 Mod4Mask | ControlMask)); |
1993 | 2067 |
1994 *CommandLine::ForCurrentProcess() = original_cl; | 2068 *CommandLine::ForCurrentProcess() = original_cl; |
1995 } | 2069 } |
1996 | 2070 |
| 2071 TEST_F(EventRewriterTest, TestRewriteFunctionKeys) { |
| 2072 TestingPrefService prefs; |
| 2073 chromeos::Preferences::RegisterUserPrefs(&prefs); |
| 2074 EventRewriter rewriter; |
| 2075 rewriter.set_pref_service_for_testing(&prefs); |
| 2076 |
| 2077 // When not on a chromebook keyboard enabled, F<numbers> are not rewritten. |
| 2078 rewriter.set_force_external_keyboard_for_testing(true); |
| 2079 |
| 2080 struct { |
| 2081 ui::KeyboardCode input; |
| 2082 KeyCode input_native; |
| 2083 ui::KeyboardCode output; |
| 2084 KeyCode output_native; |
| 2085 } default_tests[] = { |
| 2086 { ui::VKEY_F1, keycode_f1_, ui::VKEY_F1, keycode_f1_, }, |
| 2087 { ui::VKEY_F2, keycode_f2_, ui::VKEY_F2, keycode_f2_, }, |
| 2088 { ui::VKEY_F3, keycode_f3_, ui::VKEY_F3, keycode_f3_, }, |
| 2089 { ui::VKEY_F4, keycode_f4_, ui::VKEY_F4, keycode_f4_, }, |
| 2090 { ui::VKEY_F5, keycode_f5_, ui::VKEY_F5, keycode_f5_, }, |
| 2091 { ui::VKEY_F6, keycode_f6_, ui::VKEY_F6, keycode_f6_, }, |
| 2092 { ui::VKEY_F7, keycode_f7_, ui::VKEY_F7, keycode_f7_, }, |
| 2093 { ui::VKEY_F8, keycode_f8_, ui::VKEY_F8, keycode_f8_, }, |
| 2094 { ui::VKEY_F9, keycode_f9_, ui::VKEY_F9, keycode_f9_, }, |
| 2095 { ui::VKEY_F10, keycode_f10_, ui::VKEY_F10, keycode_f10_, }, |
| 2096 { ui::VKEY_F11, keycode_f11_, ui::VKEY_F11, keycode_f11_, }, |
| 2097 { ui::VKEY_F12, keycode_f12_, ui::VKEY_F12, keycode_f12_, }, |
| 2098 { ui::VKEY_1, keycode_1_, ui::VKEY_1, keycode_1_, }, |
| 2099 { ui::VKEY_2, keycode_2_, ui::VKEY_2, keycode_2_, }, |
| 2100 { ui::VKEY_3, keycode_3_, ui::VKEY_3, keycode_3_, }, |
| 2101 { ui::VKEY_4, keycode_4_, ui::VKEY_4, keycode_4_, }, |
| 2102 { ui::VKEY_5, keycode_5_, ui::VKEY_5, keycode_5_, }, |
| 2103 { ui::VKEY_6, keycode_6_, ui::VKEY_6, keycode_6_, }, |
| 2104 { ui::VKEY_7, keycode_7_, ui::VKEY_7, keycode_7_, }, |
| 2105 { ui::VKEY_8, keycode_8_, ui::VKEY_8, keycode_8_, }, |
| 2106 { ui::VKEY_9, keycode_9_, ui::VKEY_9, keycode_9_, }, |
| 2107 { ui::VKEY_0, keycode_0_, ui::VKEY_0, keycode_0_, }, |
| 2108 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_OEM_MINUS, keycode_minus_, }, |
| 2109 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_OEM_PLUS, keycode_equal_, }, |
| 2110 }; |
| 2111 |
| 2112 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(default_tests); ++i) { |
| 2113 EXPECT_EQ(GetExpectedResultAsString(default_tests[i].output, |
| 2114 0, |
| 2115 ui::ET_KEY_PRESSED, |
| 2116 default_tests[i].output_native, |
| 2117 0U, |
| 2118 KeyPress), |
| 2119 GetRewrittenEventAsString(&rewriter, |
| 2120 default_tests[i].input, |
| 2121 0, |
| 2122 ui::ET_KEY_PRESSED, |
| 2123 default_tests[i].input_native, |
| 2124 0)); |
| 2125 |
| 2126 // Search key as a modifier does not change the outcome. |
| 2127 EXPECT_EQ(GetExpectedResultAsString(default_tests[i].output, |
| 2128 0, |
| 2129 ui::ET_KEY_PRESSED, |
| 2130 default_tests[i].output_native, |
| 2131 Mod4Mask, |
| 2132 KeyPress), |
| 2133 GetRewrittenEventAsString(&rewriter, |
| 2134 default_tests[i].input, |
| 2135 0, |
| 2136 ui::ET_KEY_PRESSED, |
| 2137 default_tests[i].input_native, |
| 2138 Mod4Mask)); |
| 2139 } |
| 2140 |
| 2141 // When on a chromebook keyboard, F<number> keys do special stuff. |
| 2142 rewriter.set_force_external_keyboard_for_testing(false); |
| 2143 |
| 2144 struct { |
| 2145 ui::KeyboardCode input; |
| 2146 KeyCode input_native; |
| 2147 ui::KeyboardCode output; |
| 2148 KeyCode output_native; |
| 2149 } chromeos_tests[] = { |
| 2150 { // F1 -> Back |
| 2151 ui::VKEY_F1, keycode_f1_, |
| 2152 ui::VKEY_BROWSER_BACK, keycode_browser_back_ |
| 2153 }, |
| 2154 { // F2 -> Forward |
| 2155 ui::VKEY_F2, keycode_f2_, |
| 2156 ui::VKEY_BROWSER_FORWARD, keycode_browser_forward_ |
| 2157 }, |
| 2158 { // F3 -> Refresh |
| 2159 ui::VKEY_F3, keycode_f3_, |
| 2160 ui::VKEY_BROWSER_REFRESH, keycode_browser_refresh_ |
| 2161 }, |
| 2162 { // F4 -> Launch App 2 |
| 2163 ui::VKEY_F4, keycode_f4_, |
| 2164 ui::VKEY_MEDIA_LAUNCH_APP2, keycode_media_launch_app2_ |
| 2165 }, |
| 2166 { // F5 -> Launch App 1 |
| 2167 ui::VKEY_F5, keycode_f5_, |
| 2168 ui::VKEY_MEDIA_LAUNCH_APP1, keycode_media_launch_app1_ |
| 2169 }, |
| 2170 { // F6 -> Brightness down |
| 2171 ui::VKEY_F6, keycode_f6_, |
| 2172 ui::VKEY_BRIGHTNESS_DOWN, keycode_brightness_down_ |
| 2173 }, |
| 2174 { // F7 -> Brightness up |
| 2175 ui::VKEY_F7, keycode_f7_, |
| 2176 ui::VKEY_BRIGHTNESS_UP, keycode_brightness_up_ |
| 2177 }, |
| 2178 { // F8 -> Volume Mute |
| 2179 ui::VKEY_F8, keycode_f8_, |
| 2180 ui::VKEY_VOLUME_MUTE, keycode_volume_mute_ |
| 2181 }, |
| 2182 { // F9 -> Volume Down |
| 2183 ui::VKEY_F9, keycode_f9_, |
| 2184 ui::VKEY_VOLUME_DOWN, keycode_volume_down_ |
| 2185 }, |
| 2186 { // F10 -> Volume Up |
| 2187 ui::VKEY_F10, keycode_f10_, |
| 2188 ui::VKEY_VOLUME_UP, keycode_volume_up_ |
| 2189 }, |
| 2190 { // F11 -> Power |
| 2191 ui::VKEY_F11, keycode_f11_, |
| 2192 ui::VKEY_POWER, keycode_power_ |
| 2193 }, |
| 2194 { // F12 -> F12 |
| 2195 ui::VKEY_F12, keycode_f12_, |
| 2196 ui::VKEY_F12, keycode_f12_, |
| 2197 }, |
| 2198 // The number row should not be rewritten. |
| 2199 { ui::VKEY_1, keycode_1_, ui::VKEY_1, keycode_1_, }, |
| 2200 { ui::VKEY_2, keycode_2_, ui::VKEY_2, keycode_2_, }, |
| 2201 { ui::VKEY_3, keycode_3_, ui::VKEY_3, keycode_3_, }, |
| 2202 { ui::VKEY_4, keycode_4_, ui::VKEY_4, keycode_4_, }, |
| 2203 { ui::VKEY_5, keycode_5_, ui::VKEY_5, keycode_5_, }, |
| 2204 { ui::VKEY_6, keycode_6_, ui::VKEY_6, keycode_6_, }, |
| 2205 { ui::VKEY_7, keycode_7_, ui::VKEY_7, keycode_7_, }, |
| 2206 { ui::VKEY_8, keycode_8_, ui::VKEY_8, keycode_8_, }, |
| 2207 { ui::VKEY_9, keycode_9_, ui::VKEY_9, keycode_9_, }, |
| 2208 { ui::VKEY_0, keycode_0_, ui::VKEY_0, keycode_0_, }, |
| 2209 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_OEM_MINUS, keycode_minus_, }, |
| 2210 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_OEM_PLUS, keycode_equal_, }, |
| 2211 }; |
| 2212 |
| 2213 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(chromeos_tests); ++i) { |
| 2214 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, |
| 2215 0, |
| 2216 ui::ET_KEY_PRESSED, |
| 2217 chromeos_tests[i].output_native, |
| 2218 0U, |
| 2219 KeyPress), |
| 2220 GetRewrittenEventAsString(&rewriter, |
| 2221 chromeos_tests[i].input, |
| 2222 0, |
| 2223 ui::ET_KEY_PRESSED, |
| 2224 chromeos_tests[i].input_native, |
| 2225 0)); |
| 2226 |
| 2227 // Search key as a modifier does not change the outcome. |
| 2228 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, |
| 2229 0, |
| 2230 ui::ET_KEY_PRESSED, |
| 2231 chromeos_tests[i].output_native, |
| 2232 Mod4Mask, |
| 2233 KeyPress), |
| 2234 GetRewrittenEventAsString(&rewriter, |
| 2235 chromeos_tests[i].input, |
| 2236 0, |
| 2237 ui::ET_KEY_PRESSED, |
| 2238 chromeos_tests[i].input_native, |
| 2239 Mod4Mask)); |
| 2240 } |
| 2241 |
| 2242 // Make Search key act like a Function key for accessing extended key |
| 2243 // bindings. Now Search key as a modifier will make the number row |
| 2244 // act like the F<number> row. |
| 2245 const CommandLine original_cl(*CommandLine::ForCurrentProcess()); |
| 2246 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 2247 switches::kEnableChromebookFunctionKey, ""); |
| 2248 BooleanPrefMember search_key_as_function_key; |
| 2249 search_key_as_function_key.Init(prefs::kLanguageSearchKeyActsAsFunctionKey, |
| 2250 &prefs, NULL); |
| 2251 search_key_as_function_key.SetValue(true); |
| 2252 |
| 2253 // Without a Search key modifier, the results should be the same as before. |
| 2254 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(chromeos_tests); ++i) { |
| 2255 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, |
| 2256 0, |
| 2257 ui::ET_KEY_PRESSED, |
| 2258 chromeos_tests[i].output_native, |
| 2259 0U, |
| 2260 KeyPress), |
| 2261 GetRewrittenEventAsString(&rewriter, |
| 2262 chromeos_tests[i].input, |
| 2263 0, |
| 2264 ui::ET_KEY_PRESSED, |
| 2265 chromeos_tests[i].input_native, |
| 2266 0)); |
| 2267 } |
| 2268 |
| 2269 struct { |
| 2270 ui::KeyboardCode input; |
| 2271 KeyCode input_native; |
| 2272 ui::KeyboardCode output; |
| 2273 KeyCode output_native; |
| 2274 } search_key_tests[] = { |
| 2275 // The number row should be rewritten as the F<number> row. |
| 2276 { ui::VKEY_1, keycode_1_, ui::VKEY_F1, keycode_f1_, }, |
| 2277 { ui::VKEY_2, keycode_2_, ui::VKEY_F2, keycode_f2_, }, |
| 2278 { ui::VKEY_3, keycode_3_, ui::VKEY_F3, keycode_f3_, }, |
| 2279 { ui::VKEY_4, keycode_4_, ui::VKEY_F4, keycode_f4_, }, |
| 2280 { ui::VKEY_5, keycode_5_, ui::VKEY_F5, keycode_f5_, }, |
| 2281 { ui::VKEY_6, keycode_6_, ui::VKEY_F6, keycode_f6_, }, |
| 2282 { ui::VKEY_7, keycode_7_, ui::VKEY_F7, keycode_f7_, }, |
| 2283 { ui::VKEY_8, keycode_8_, ui::VKEY_F8, keycode_f8_, }, |
| 2284 { ui::VKEY_9, keycode_9_, ui::VKEY_F9, keycode_f9_, }, |
| 2285 { ui::VKEY_0, keycode_0_, ui::VKEY_F10, keycode_f10_, }, |
| 2286 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_F11, keycode_f11_, }, |
| 2287 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_F12, keycode_f12_, }, |
| 2288 }; |
| 2289 |
| 2290 // But with a Search key as a modifier, we should have new rewrite rules now. |
| 2291 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(search_key_tests); ++i) { |
| 2292 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, |
| 2293 0, |
| 2294 ui::ET_KEY_PRESSED, |
| 2295 search_key_tests[i].output_native, |
| 2296 0, |
| 2297 KeyPress), |
| 2298 GetRewrittenEventAsString(&rewriter, |
| 2299 search_key_tests[i].input, |
| 2300 0, |
| 2301 ui::ET_KEY_PRESSED, |
| 2302 search_key_tests[i].input_native, |
| 2303 Mod4Mask)); |
| 2304 |
| 2305 // Other modifiers should be preserved. |
| 2306 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, |
| 2307 ui::EF_ALT_DOWN, |
| 2308 ui::ET_KEY_PRESSED, |
| 2309 search_key_tests[i].output_native, |
| 2310 Mod1Mask, |
| 2311 KeyPress), |
| 2312 GetRewrittenEventAsString(&rewriter, |
| 2313 search_key_tests[i].input, |
| 2314 ui::EF_ALT_DOWN, |
| 2315 ui::ET_KEY_PRESSED, |
| 2316 search_key_tests[i].input_native, |
| 2317 Mod4Mask | Mod1Mask)); |
| 2318 |
| 2319 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, |
| 2320 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, |
| 2321 ui::ET_KEY_PRESSED, |
| 2322 search_key_tests[i].output_native, |
| 2323 ControlMask | Mod1Mask, |
| 2324 KeyPress), |
| 2325 GetRewrittenEventAsString(&rewriter, |
| 2326 search_key_tests[i].input, |
| 2327 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, |
| 2328 ui::ET_KEY_PRESSED, |
| 2329 search_key_tests[i].input_native, |
| 2330 Mod4Mask | ControlMask | Mod1Mask)); |
| 2331 } |
| 2332 |
| 2333 *CommandLine::ForCurrentProcess() = original_cl; |
| 2334 } |
| 2335 |
1997 TEST_F(EventRewriterTest, TestRewriteBackspaceAndArrowKeysWithSearchRemapped) { | 2336 TEST_F(EventRewriterTest, TestRewriteBackspaceAndArrowKeysWithSearchRemapped) { |
1998 // Remap Search to Control. | 2337 // Remap Search to Control. |
1999 TestingPrefService prefs; | 2338 TestingPrefService prefs; |
2000 chromeos::Preferences::RegisterUserPrefs(&prefs); | 2339 chromeos::Preferences::RegisterUserPrefs(&prefs); |
2001 IntegerPrefMember search; | 2340 IntegerPrefMember search; |
2002 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs, NULL); | 2341 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs, NULL); |
2003 search.SetValue(chromeos::input_method::kControlKey); | 2342 search.SetValue(chromeos::input_method::kControlKey); |
2004 | 2343 |
2005 EventRewriter rewriter; | 2344 EventRewriter rewriter; |
2006 rewriter.set_pref_service_for_testing(&prefs); | 2345 rewriter.set_pref_service_for_testing(&prefs); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 // flag in the event is True. | 2404 // flag in the event is True. |
2066 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, | 2405 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
2067 ui::EF_CONTROL_DOWN, | 2406 ui::EF_CONTROL_DOWN, |
2068 ui::ET_KEY_PRESSED, | 2407 ui::ET_KEY_PRESSED, |
2069 keycode_control_l_, | 2408 keycode_control_l_, |
2070 0U, | 2409 0U, |
2071 KeyPress), | 2410 KeyPress), |
2072 rewritten_event); | 2411 rewritten_event); |
2073 } | 2412 } |
2074 #endif // OS_CHROMEOS | 2413 #endif // OS_CHROMEOS |
OLD | NEW |