Chromium Code Reviews| 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)), | |
|
Yusuke Sato
2012/11/26 07:28:19
Using XF86XK keysyms probably has the same issue a
danakj
2012/11/26 17:50:38
Oh darn :( Okay, I'll make this work for now, and
| |
| 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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1982 ControlMask, | 2056 ControlMask, |
| 1983 KeyPress), | 2057 KeyPress), |
| 1984 GetRewrittenEventAsString(&rewriter, | 2058 GetRewrittenEventAsString(&rewriter, |
| 1985 ui::VKEY_RIGHT, | 2059 ui::VKEY_RIGHT, |
| 1986 0, | 2060 0, |
| 1987 ui::ET_KEY_PRESSED, | 2061 ui::ET_KEY_PRESSED, |
| 1988 keycode_right_, | 2062 keycode_right_, |
| 1989 Mod4Mask | ControlMask)); | 2063 Mod4Mask | ControlMask)); |
| 1990 } | 2064 } |
| 1991 | 2065 |
| 2066 TEST_F(EventRewriterTest, TestRewriteFunctionKeys) { | |
| 2067 TestingPrefService prefs; | |
| 2068 chromeos::Preferences::RegisterUserPrefs(&prefs); | |
| 2069 EventRewriter rewriter; | |
| 2070 rewriter.set_pref_service_for_testing(&prefs); | |
| 2071 | |
| 2072 // When --has-chromeos-keyboard is not enabled, F<numbers> are not rewritten. | |
| 2073 | |
| 2074 struct { | |
| 2075 ui::KeyboardCode input; | |
| 2076 KeyCode input_native; | |
| 2077 ui::KeyboardCode output; | |
| 2078 KeyCode output_native; | |
| 2079 } default_tests[] = { | |
| 2080 { ui::VKEY_F1, keycode_f1_, ui::VKEY_F1, keycode_f1_, }, | |
| 2081 { ui::VKEY_F2, keycode_f2_, ui::VKEY_F2, keycode_f2_, }, | |
| 2082 { ui::VKEY_F3, keycode_f3_, ui::VKEY_F3, keycode_f3_, }, | |
| 2083 { ui::VKEY_F4, keycode_f4_, ui::VKEY_F4, keycode_f4_, }, | |
| 2084 { ui::VKEY_F5, keycode_f5_, ui::VKEY_F5, keycode_f5_, }, | |
| 2085 { ui::VKEY_F6, keycode_f6_, ui::VKEY_F6, keycode_f6_, }, | |
| 2086 { ui::VKEY_F7, keycode_f7_, ui::VKEY_F7, keycode_f7_, }, | |
| 2087 { ui::VKEY_F8, keycode_f8_, ui::VKEY_F8, keycode_f8_, }, | |
| 2088 { ui::VKEY_F9, keycode_f9_, ui::VKEY_F9, keycode_f9_, }, | |
| 2089 { ui::VKEY_F10, keycode_f10_, ui::VKEY_F10, keycode_f10_, }, | |
| 2090 { ui::VKEY_F11, keycode_f11_, ui::VKEY_F11, keycode_f11_, }, | |
| 2091 { ui::VKEY_F12, keycode_f12_, ui::VKEY_F12, keycode_f12_, }, | |
| 2092 { ui::VKEY_1, keycode_1_, ui::VKEY_1, keycode_1_, }, | |
| 2093 { ui::VKEY_2, keycode_2_, ui::VKEY_2, keycode_2_, }, | |
| 2094 { ui::VKEY_3, keycode_3_, ui::VKEY_3, keycode_3_, }, | |
| 2095 { ui::VKEY_4, keycode_4_, ui::VKEY_4, keycode_4_, }, | |
| 2096 { ui::VKEY_5, keycode_5_, ui::VKEY_5, keycode_5_, }, | |
| 2097 { ui::VKEY_6, keycode_6_, ui::VKEY_6, keycode_6_, }, | |
| 2098 { ui::VKEY_7, keycode_7_, ui::VKEY_7, keycode_7_, }, | |
| 2099 { ui::VKEY_8, keycode_8_, ui::VKEY_8, keycode_8_, }, | |
| 2100 { ui::VKEY_9, keycode_9_, ui::VKEY_9, keycode_9_, }, | |
| 2101 { ui::VKEY_0, keycode_0_, ui::VKEY_0, keycode_0_, }, | |
| 2102 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_OEM_MINUS, keycode_minus_, }, | |
| 2103 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_OEM_PLUS, keycode_equal_, }, | |
| 2104 }; | |
| 2105 | |
| 2106 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(default_tests); ++i) { | |
| 2107 EXPECT_EQ(GetExpectedResultAsString(default_tests[i].output, | |
| 2108 0, | |
| 2109 ui::ET_KEY_PRESSED, | |
| 2110 default_tests[i].output_native, | |
| 2111 0U, | |
| 2112 KeyPress), | |
| 2113 GetRewrittenEventAsString(&rewriter, | |
| 2114 default_tests[i].input, | |
| 2115 0, | |
| 2116 ui::ET_KEY_PRESSED, | |
| 2117 default_tests[i].input_native, | |
| 2118 0)); | |
| 2119 | |
| 2120 // Search key as a modifier does not change the outcome. | |
| 2121 EXPECT_EQ(GetExpectedResultAsString(default_tests[i].output, | |
| 2122 0, | |
| 2123 ui::ET_KEY_PRESSED, | |
| 2124 default_tests[i].output_native, | |
| 2125 Mod4Mask, | |
| 2126 KeyPress), | |
| 2127 GetRewrittenEventAsString(&rewriter, | |
| 2128 default_tests[i].input, | |
| 2129 0, | |
| 2130 ui::ET_KEY_PRESSED, | |
| 2131 default_tests[i].input_native, | |
| 2132 Mod4Mask)); | |
| 2133 } | |
| 2134 | |
| 2135 // When --has-chromeos-keyboard is enabled, F<number> keys do special stuff. | |
| 2136 const CommandLine original_cl(*CommandLine::ForCurrentProcess()); | |
| 2137 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 2138 switches::kHasChromeOSKeyboard, ""); | |
| 2139 | |
| 2140 struct { | |
| 2141 ui::KeyboardCode input; | |
| 2142 KeyCode input_native; | |
| 2143 ui::KeyboardCode output; | |
| 2144 KeyCode output_native; | |
| 2145 } chromeos_tests[] = { | |
| 2146 { // F1 -> Back | |
| 2147 ui::VKEY_F1, keycode_f1_, | |
| 2148 ui::VKEY_BROWSER_BACK, keycode_browser_back_ | |
| 2149 }, | |
| 2150 { // F2 -> Forward | |
| 2151 ui::VKEY_F2, keycode_f2_, | |
| 2152 ui::VKEY_BROWSER_FORWARD, keycode_browser_forward_ | |
| 2153 }, | |
| 2154 { // F3 -> Refresh | |
| 2155 ui::VKEY_F3, keycode_f3_, | |
| 2156 ui::VKEY_BROWSER_REFRESH, keycode_browser_refresh_ | |
| 2157 }, | |
| 2158 { // F4 -> Launch App 2 | |
| 2159 ui::VKEY_F4, keycode_f4_, | |
| 2160 ui::VKEY_MEDIA_LAUNCH_APP2, keycode_media_launch_app2_ | |
| 2161 }, | |
| 2162 { // F5 -> Launch App 1 | |
| 2163 ui::VKEY_F5, keycode_f5_, | |
| 2164 ui::VKEY_MEDIA_LAUNCH_APP1, keycode_media_launch_app1_ | |
| 2165 }, | |
| 2166 { // F6 -> Brightness down | |
| 2167 ui::VKEY_F6, keycode_f6_, | |
| 2168 ui::VKEY_BRIGHTNESS_DOWN, keycode_brightness_down_ | |
| 2169 }, | |
| 2170 { // F7 -> Brightness up | |
| 2171 ui::VKEY_F7, keycode_f7_, | |
| 2172 ui::VKEY_BRIGHTNESS_UP, keycode_brightness_up_ | |
| 2173 }, | |
| 2174 { // F8 -> Volume Mute | |
| 2175 ui::VKEY_F8, keycode_f8_, | |
| 2176 ui::VKEY_VOLUME_MUTE, keycode_volume_mute_ | |
| 2177 }, | |
| 2178 { // F9 -> Volume Down | |
| 2179 ui::VKEY_F9, keycode_f9_, | |
| 2180 ui::VKEY_VOLUME_DOWN, keycode_volume_down_ | |
| 2181 }, | |
| 2182 { // F10 -> Volume Up | |
| 2183 ui::VKEY_F10, keycode_f10_, | |
| 2184 ui::VKEY_VOLUME_UP, keycode_volume_up_ | |
| 2185 }, | |
| 2186 { // F11 -> Power | |
| 2187 ui::VKEY_F11, keycode_f11_, | |
| 2188 ui::VKEY_POWER, keycode_power_ | |
| 2189 }, | |
| 2190 { // F12 -> F12 | |
| 2191 ui::VKEY_F12, keycode_f12_, | |
| 2192 ui::VKEY_F12, keycode_f12_, | |
| 2193 }, | |
| 2194 // The number row should not be rewritten. | |
| 2195 { ui::VKEY_1, keycode_1_, ui::VKEY_1, keycode_1_, }, | |
| 2196 { ui::VKEY_2, keycode_2_, ui::VKEY_2, keycode_2_, }, | |
| 2197 { ui::VKEY_3, keycode_3_, ui::VKEY_3, keycode_3_, }, | |
| 2198 { ui::VKEY_4, keycode_4_, ui::VKEY_4, keycode_4_, }, | |
| 2199 { ui::VKEY_5, keycode_5_, ui::VKEY_5, keycode_5_, }, | |
| 2200 { ui::VKEY_6, keycode_6_, ui::VKEY_6, keycode_6_, }, | |
| 2201 { ui::VKEY_7, keycode_7_, ui::VKEY_7, keycode_7_, }, | |
| 2202 { ui::VKEY_8, keycode_8_, ui::VKEY_8, keycode_8_, }, | |
| 2203 { ui::VKEY_9, keycode_9_, ui::VKEY_9, keycode_9_, }, | |
| 2204 { ui::VKEY_0, keycode_0_, ui::VKEY_0, keycode_0_, }, | |
| 2205 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_OEM_MINUS, keycode_minus_, }, | |
| 2206 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_OEM_PLUS, keycode_equal_, }, | |
| 2207 }; | |
| 2208 | |
| 2209 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(chromeos_tests); ++i) { | |
| 2210 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, | |
| 2211 0, | |
| 2212 ui::ET_KEY_PRESSED, | |
| 2213 chromeos_tests[i].output_native, | |
| 2214 0U, | |
| 2215 KeyPress), | |
| 2216 GetRewrittenEventAsString(&rewriter, | |
| 2217 chromeos_tests[i].input, | |
| 2218 0, | |
| 2219 ui::ET_KEY_PRESSED, | |
| 2220 chromeos_tests[i].input_native, | |
| 2221 0)); | |
| 2222 | |
| 2223 // Search key as a modifier does not change the outcome. | |
| 2224 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, | |
| 2225 0, | |
| 2226 ui::ET_KEY_PRESSED, | |
| 2227 chromeos_tests[i].output_native, | |
| 2228 Mod4Mask, | |
| 2229 KeyPress), | |
| 2230 GetRewrittenEventAsString(&rewriter, | |
| 2231 chromeos_tests[i].input, | |
| 2232 0, | |
| 2233 ui::ET_KEY_PRESSED, | |
| 2234 chromeos_tests[i].input_native, | |
| 2235 Mod4Mask)); | |
| 2236 } | |
| 2237 | |
| 2238 // Make Search key act like a Function key for accessing extended key | |
| 2239 // bindings. Now Search key as a modifier will make the number row | |
| 2240 // act like the F<number> row. | |
| 2241 BooleanPrefMember search_key_as_function_key; | |
| 2242 search_key_as_function_key.Init(prefs::kLanguageSearchKeyActsAsFunctionKey, | |
| 2243 &prefs, NULL); | |
| 2244 search_key_as_function_key.SetValue(true); | |
| 2245 | |
| 2246 // Without a Search key modifier, the results should be the same as before. | |
| 2247 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(chromeos_tests); ++i) { | |
| 2248 EXPECT_EQ(GetExpectedResultAsString(chromeos_tests[i].output, | |
| 2249 0, | |
| 2250 ui::ET_KEY_PRESSED, | |
| 2251 chromeos_tests[i].output_native, | |
| 2252 0U, | |
| 2253 KeyPress), | |
| 2254 GetRewrittenEventAsString(&rewriter, | |
| 2255 chromeos_tests[i].input, | |
| 2256 0, | |
| 2257 ui::ET_KEY_PRESSED, | |
| 2258 chromeos_tests[i].input_native, | |
| 2259 0)); | |
| 2260 } | |
| 2261 | |
| 2262 struct { | |
| 2263 ui::KeyboardCode input; | |
| 2264 KeyCode input_native; | |
| 2265 ui::KeyboardCode output; | |
| 2266 KeyCode output_native; | |
| 2267 } search_key_tests[] = { | |
| 2268 // The number row should be rewritten as the F<number> row. | |
| 2269 { ui::VKEY_1, keycode_1_, ui::VKEY_F1, keycode_f1_, }, | |
| 2270 { ui::VKEY_2, keycode_2_, ui::VKEY_F2, keycode_f2_, }, | |
| 2271 { ui::VKEY_3, keycode_3_, ui::VKEY_F3, keycode_f3_, }, | |
| 2272 { ui::VKEY_4, keycode_4_, ui::VKEY_F4, keycode_f4_, }, | |
| 2273 { ui::VKEY_5, keycode_5_, ui::VKEY_F5, keycode_f5_, }, | |
| 2274 { ui::VKEY_6, keycode_6_, ui::VKEY_F6, keycode_f6_, }, | |
| 2275 { ui::VKEY_7, keycode_7_, ui::VKEY_F7, keycode_f7_, }, | |
| 2276 { ui::VKEY_8, keycode_8_, ui::VKEY_F8, keycode_f8_, }, | |
| 2277 { ui::VKEY_9, keycode_9_, ui::VKEY_F9, keycode_f9_, }, | |
| 2278 { ui::VKEY_0, keycode_0_, ui::VKEY_F10, keycode_f10_, }, | |
| 2279 { ui::VKEY_OEM_MINUS, keycode_minus_, ui::VKEY_F11, keycode_f11_, }, | |
| 2280 { ui::VKEY_OEM_PLUS, keycode_equal_, ui::VKEY_F12, keycode_f12_, }, | |
| 2281 }; | |
| 2282 | |
| 2283 // But with a Search key as a modifier, we should have new rewrite rules now. | |
| 2284 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(search_key_tests); ++i) { | |
| 2285 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, | |
| 2286 0, | |
| 2287 ui::ET_KEY_PRESSED, | |
| 2288 search_key_tests[i].output_native, | |
| 2289 0, | |
| 2290 KeyPress), | |
| 2291 GetRewrittenEventAsString(&rewriter, | |
| 2292 search_key_tests[i].input, | |
| 2293 0, | |
| 2294 ui::ET_KEY_PRESSED, | |
| 2295 search_key_tests[i].input_native, | |
| 2296 Mod4Mask)); | |
| 2297 | |
| 2298 // Other modifiers should be preserved. | |
| 2299 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, | |
| 2300 ui::EF_ALT_DOWN, | |
| 2301 ui::ET_KEY_PRESSED, | |
| 2302 search_key_tests[i].output_native, | |
| 2303 Mod1Mask, | |
| 2304 KeyPress), | |
| 2305 GetRewrittenEventAsString(&rewriter, | |
| 2306 search_key_tests[i].input, | |
| 2307 ui::EF_ALT_DOWN, | |
| 2308 ui::ET_KEY_PRESSED, | |
| 2309 search_key_tests[i].input_native, | |
| 2310 Mod4Mask | Mod1Mask)); | |
| 2311 | |
| 2312 EXPECT_EQ(GetExpectedResultAsString(search_key_tests[i].output, | |
| 2313 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, | |
| 2314 ui::ET_KEY_PRESSED, | |
| 2315 search_key_tests[i].output_native, | |
| 2316 ControlMask | Mod1Mask, | |
| 2317 KeyPress), | |
| 2318 GetRewrittenEventAsString(&rewriter, | |
| 2319 search_key_tests[i].input, | |
| 2320 ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, | |
| 2321 ui::ET_KEY_PRESSED, | |
| 2322 search_key_tests[i].input_native, | |
| 2323 Mod4Mask | ControlMask | Mod1Mask)); | |
| 2324 } | |
| 2325 | |
| 2326 *CommandLine::ForCurrentProcess() = original_cl; | |
| 2327 } | |
| 2328 | |
| 1992 TEST_F(EventRewriterTest, TestRewriteBackspaceAndArrowKeysWithSearchRemapped) { | 2329 TEST_F(EventRewriterTest, TestRewriteBackspaceAndArrowKeysWithSearchRemapped) { |
| 1993 // Remap Search to Control. | 2330 // Remap Search to Control. |
| 1994 TestingPrefService prefs; | 2331 TestingPrefService prefs; |
| 1995 chromeos::Preferences::RegisterUserPrefs(&prefs); | 2332 chromeos::Preferences::RegisterUserPrefs(&prefs); |
| 1996 IntegerPrefMember search; | 2333 IntegerPrefMember search; |
| 1997 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs, NULL); | 2334 search.Init(prefs::kLanguageRemapSearchKeyTo, &prefs, NULL); |
| 1998 search.SetValue(chromeos::input_method::kControlKey); | 2335 search.SetValue(chromeos::input_method::kControlKey); |
| 1999 | 2336 |
| 2000 EventRewriter rewriter; | 2337 EventRewriter rewriter; |
| 2001 rewriter.set_pref_service_for_testing(&prefs); | 2338 rewriter.set_pref_service_for_testing(&prefs); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2060 // flag in the event is True. | 2397 // flag in the event is True. |
| 2061 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, | 2398 EXPECT_EQ(GetExpectedResultAsString(ui::VKEY_CONTROL, |
| 2062 ui::EF_CONTROL_DOWN, | 2399 ui::EF_CONTROL_DOWN, |
| 2063 ui::ET_KEY_PRESSED, | 2400 ui::ET_KEY_PRESSED, |
| 2064 keycode_control_l_, | 2401 keycode_control_l_, |
| 2065 0U, | 2402 0U, |
| 2066 KeyPress), | 2403 KeyPress), |
| 2067 rewritten_event); | 2404 rewritten_event); |
| 2068 } | 2405 } |
| 2069 #endif // OS_CHROMEOS | 2406 #endif // OS_CHROMEOS |
| OLD | NEW |