1 // Copyright 2015 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.
5 #include "ui/events/keycodes/keyboard_code_conversion.h"
7 #include "base/basictypes.h"
8 #include "base/strings/stringprintf.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/events/event_constants.h"
11 #include "ui/events/keycodes/dom/dom_code.h"
12 #include "ui/events/keycodes/dom/dom_key.h"
13 #include "ui/events/keycodes/dom/keycode_converter.h"
14 #include "ui/events/keycodes/dom_us_layout_data.h"
15 #include "ui/events/keycodes/keyboard_codes.h"
21 ui::DomKey::Base dom_key
;
22 ui::KeyboardCode key_code
;
25 const Meaning kUndefined
= {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
};
27 void CheckDomCodeToMeaning(const char* label
,
28 bool f(ui::DomCode dom_code
,
30 ui::DomKey
* out_dom_key
,
31 ui::KeyboardCode
* out_key_code
),
34 const Meaning
& result
) {
35 ui::DomKey result_dom_key
= ui::DomKey::NONE
;
36 ui::KeyboardCode result_key_code
= ui::VKEY_UNKNOWN
;
37 bool success
= f(dom_code
, event_flags
, &result_dom_key
, &result_key_code
);
39 base::StringPrintf("%s %s %06X:%04X", label
,
40 ui::KeycodeConverter::DomCodeToCodeString(dom_code
),
41 static_cast<int>(dom_code
), event_flags
));
42 EXPECT_EQ(result
.defined
, success
);
44 EXPECT_EQ(result
.dom_key
, result_dom_key
)
46 << ui::KeycodeConverter::DomKeyToKeyString(result
.dom_key
)
48 << ui::KeycodeConverter::DomKeyToKeyString(result_dom_key
) << "'";
49 EXPECT_EQ(result
.key_code
, result_key_code
);
51 // Should not have touched output parameters.
52 EXPECT_EQ(ui::DomKey::NONE
, result_dom_key
);
53 EXPECT_EQ(ui::VKEY_UNKNOWN
, result_key_code
);
57 TEST(KeyboardCodeConversion
, ControlCharacters
) {
58 // The codes in this table are handled by |DomCodeToControlCharacter()|.
62 Meaning control_shift
;
63 } kControlCharacters
[] = {
65 {true, ui::DomKey::Constant
<0x01>::Character
, ui::VKEY_A
},
66 {true, ui::DomKey::Constant
<0x01>::Character
, ui::VKEY_A
}},
68 {true, ui::DomKey::Constant
<0x02>::Character
, ui::VKEY_B
},
69 {true, ui::DomKey::Constant
<0x02>::Character
, ui::VKEY_B
}},
71 {true, ui::DomKey::Constant
<0x03>::Character
, ui::VKEY_C
},
72 {true, ui::DomKey::Constant
<0x03>::Character
, ui::VKEY_C
}},
74 {true, ui::DomKey::Constant
<0x04>::Character
, ui::VKEY_D
},
75 {true, ui::DomKey::Constant
<0x04>::Character
, ui::VKEY_D
}},
77 {true, ui::DomKey::Constant
<0x05>::Character
, ui::VKEY_E
},
78 {true, ui::DomKey::Constant
<0x05>::Character
, ui::VKEY_E
}},
80 {true, ui::DomKey::Constant
<0x06>::Character
, ui::VKEY_F
},
81 {true, ui::DomKey::Constant
<0x06>::Character
, ui::VKEY_F
}},
83 {true, ui::DomKey::Constant
<0x07>::Character
, ui::VKEY_G
},
84 {true, ui::DomKey::Constant
<0x07>::Character
, ui::VKEY_G
}},
86 {true, ui::DomKey::BACKSPACE
, ui::VKEY_BACK
},
87 {true, ui::DomKey::BACKSPACE
, ui::VKEY_BACK
}},
89 {true, ui::DomKey::TAB
, ui::VKEY_TAB
},
90 {true, ui::DomKey::TAB
, ui::VKEY_TAB
}},
92 {true, ui::DomKey::Constant
<0x0A>::Character
, ui::VKEY_J
},
93 {true, ui::DomKey::Constant
<0x0A>::Character
, ui::VKEY_J
}},
95 {true, ui::DomKey::Constant
<0x0B>::Character
, ui::VKEY_K
},
96 {true, ui::DomKey::Constant
<0x0B>::Character
, ui::VKEY_K
}},
98 {true, ui::DomKey::Constant
<0x0C>::Character
, ui::VKEY_L
},
99 {true, ui::DomKey::Constant
<0x0C>::Character
, ui::VKEY_L
}},
101 {true, ui::DomKey::ENTER
, ui::VKEY_RETURN
},
102 {true, ui::DomKey::ENTER
, ui::VKEY_RETURN
}},
104 {true, ui::DomKey::Constant
<0x0E>::Character
, ui::VKEY_N
},
105 {true, ui::DomKey::Constant
<0x0E>::Character
, ui::VKEY_N
}},
107 {true, ui::DomKey::Constant
<0x0F>::Character
, ui::VKEY_O
},
108 {true, ui::DomKey::Constant
<0x0F>::Character
, ui::VKEY_O
}},
110 {true, ui::DomKey::Constant
<0x10>::Character
, ui::VKEY_P
},
111 {true, ui::DomKey::Constant
<0x10>::Character
, ui::VKEY_P
}},
113 {true, ui::DomKey::Constant
<0x11>::Character
, ui::VKEY_Q
},
114 {true, ui::DomKey::Constant
<0x11>::Character
, ui::VKEY_Q
}},
116 {true, ui::DomKey::Constant
<0x12>::Character
, ui::VKEY_R
},
117 {true, ui::DomKey::Constant
<0x12>::Character
, ui::VKEY_R
}},
119 {true, ui::DomKey::Constant
<0x13>::Character
, ui::VKEY_S
},
120 {true, ui::DomKey::Constant
<0x13>::Character
, ui::VKEY_S
}},
122 {true, ui::DomKey::Constant
<0x14>::Character
, ui::VKEY_T
},
123 {true, ui::DomKey::Constant
<0x14>::Character
, ui::VKEY_T
}},
125 {true, ui::DomKey::Constant
<0x15>::Character
, ui::VKEY_U
},
126 {true, ui::DomKey::Constant
<0x15>::Character
, ui::VKEY_U
}},
128 {true, ui::DomKey::Constant
<0x16>::Character
, ui::VKEY_V
},
129 {true, ui::DomKey::Constant
<0x16>::Character
, ui::VKEY_V
}},
131 {true, ui::DomKey::Constant
<0x17>::Character
, ui::VKEY_W
},
132 {true, ui::DomKey::Constant
<0x17>::Character
, ui::VKEY_W
}},
134 {true, ui::DomKey::Constant
<0x18>::Character
, ui::VKEY_X
},
135 {true, ui::DomKey::Constant
<0x18>::Character
, ui::VKEY_X
}},
137 {true, ui::DomKey::Constant
<0x19>::Character
, ui::VKEY_Y
},
138 {true, ui::DomKey::Constant
<0x19>::Character
, ui::VKEY_Y
}},
140 {true, ui::DomKey::Constant
<0x1A>::Character
, ui::VKEY_Z
},
141 {true, ui::DomKey::Constant
<0x1A>::Character
, ui::VKEY_Z
}},
143 for (const auto& it
: kControlCharacters
) {
144 // Verify |DomCodeToControlCharacter()|.
145 CheckDomCodeToMeaning("c_cc_n", ui::DomCodeToControlCharacter
, it
.dom_code
,
146 ui::EF_NONE
, kUndefined
);
147 CheckDomCodeToMeaning("c_cc_c", ui::DomCodeToControlCharacter
, it
.dom_code
,
148 ui::EF_CONTROL_DOWN
, it
.control
);
149 CheckDomCodeToMeaning("c_cc_cs", ui::DomCodeToControlCharacter
, it
.dom_code
,
150 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
,
152 // Verify |DomCodeToUsLayoutDomKey()|.
153 CheckDomCodeToMeaning("c_us_c", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
154 ui::EF_CONTROL_DOWN
, it
.control
);
155 CheckDomCodeToMeaning("c_us_cs", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
156 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
,
160 // The codes in this table are sensitive to the Shift state, so they are
161 // handled differently by |DomCodeToControlCharacter()|, which returns false
162 // for unknown combinations, vs |DomCodeToUsLayoutDomKey()|, which returns
163 // true with DomKey::UNIDENTIFIED.
164 static const struct {
165 ui::DomCode dom_code
;
167 Meaning cc_control_shift
;
169 Meaning us_control_shift
;
170 } kShiftControlCharacters
[] = {
171 {ui::DomCode::DIGIT2
,
172 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
173 {true, ui::DomKey::Constant
<0>::Character
, ui::VKEY_2
},
174 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_2
},
175 {true, ui::DomKey::Constant
<0>::Character
, ui::VKEY_2
}},
176 {ui::DomCode::DIGIT6
,
177 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
178 {true, ui::DomKey::Constant
<0x1E>::Character
, ui::VKEY_6
},
179 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_6
},
180 {true, ui::DomKey::Constant
<0x1E>::Character
, ui::VKEY_6
}},
182 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
183 {true, ui::DomKey::Constant
<0x1F>::Character
, ui::VKEY_OEM_MINUS
},
184 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_OEM_MINUS
},
185 {true, ui::DomKey::Constant
<0x1F>::Character
, ui::VKEY_OEM_MINUS
}},
187 {true, ui::DomKey::Constant
<0x0A>::Character
, ui::VKEY_RETURN
},
188 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
189 {true, ui::DomKey::Constant
<0x0A>::Character
, ui::VKEY_RETURN
},
190 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_RETURN
}},
191 {ui::DomCode::BRACKET_LEFT
,
192 {true, ui::DomKey::ESCAPE
, ui::VKEY_OEM_4
},
193 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
194 {true, ui::DomKey::ESCAPE
, ui::VKEY_OEM_4
},
195 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_OEM_4
}},
196 {ui::DomCode::BACKSLASH
,
197 {true, ui::DomKey::Constant
<0x1C>::Character
, ui::VKEY_OEM_5
},
198 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
199 {true, ui::DomKey::Constant
<0x1C>::Character
, ui::VKEY_OEM_5
},
200 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_OEM_5
}},
201 {ui::DomCode::BRACKET_RIGHT
,
202 {true, ui::DomKey::Constant
<0x1D>::Character
, ui::VKEY_OEM_6
},
203 {false, ui::DomKey::NONE
, ui::VKEY_UNKNOWN
},
204 {true, ui::DomKey::Constant
<0x1D>::Character
, ui::VKEY_OEM_6
},
205 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_OEM_6
}},
207 for (const auto& it
: kShiftControlCharacters
) {
208 // Verify |DomCodeToControlCharacter()|.
209 CheckDomCodeToMeaning("s_cc_n", ui::DomCodeToControlCharacter
, it
.dom_code
,
210 ui::EF_NONE
, kUndefined
);
211 CheckDomCodeToMeaning("s_cc_c", ui::DomCodeToControlCharacter
, it
.dom_code
,
212 ui::EF_CONTROL_DOWN
, it
.cc_control
);
213 CheckDomCodeToMeaning("s_cc_cs", ui::DomCodeToControlCharacter
, it
.dom_code
,
214 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
,
215 it
.cc_control_shift
);
216 // Verify |DomCodeToUsLayoutDomKey()|.
217 CheckDomCodeToMeaning("s_us_c", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
218 ui::EF_CONTROL_DOWN
, it
.us_control
);
219 CheckDomCodeToMeaning("s_us_cs", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
220 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
,
221 it
.us_control_shift
);
224 // These codes are not handled by |DomCodeToControlCharacter()| directly.
225 static const struct {
226 ui::DomCode dom_code
;
229 } kNonControlCharacters
[] = {
230 // Modifiers are handled by |DomCodeToUsLayoutDomKey()| without regard
231 // to whether Control is down.
232 {ui::DomCode::CONTROL_LEFT
,
233 {true, ui::DomKey::CONTROL
, ui::VKEY_CONTROL
},
234 {true, ui::DomKey::CONTROL
, ui::VKEY_CONTROL
}},
235 {ui::DomCode::CONTROL_RIGHT
,
236 {true, ui::DomKey::CONTROL
, ui::VKEY_CONTROL
},
237 {true, ui::DomKey::CONTROL
, ui::VKEY_CONTROL
}},
238 {ui::DomCode::SHIFT_LEFT
,
239 {true, ui::DomKey::SHIFT
, ui::VKEY_SHIFT
},
240 {true, ui::DomKey::SHIFT
, ui::VKEY_SHIFT
}},
241 {ui::DomCode::SHIFT_RIGHT
,
242 {true, ui::DomKey::SHIFT
, ui::VKEY_SHIFT
},
243 {true, ui::DomKey::SHIFT
, ui::VKEY_SHIFT
}},
244 {ui::DomCode::ALT_LEFT
,
245 {true, ui::DomKey::ALT
, ui::VKEY_MENU
},
246 {true, ui::DomKey::ALT
, ui::VKEY_MENU
}},
247 {ui::DomCode::ALT_RIGHT
,
248 {true, ui::DomKey::ALT
, ui::VKEY_MENU
},
249 {true, ui::DomKey::ALT
, ui::VKEY_MENU
}},
250 {ui::DomCode::OS_LEFT
,
251 {true, ui::DomKey::OS
, ui::VKEY_LWIN
},
252 {true, ui::DomKey::OS
, ui::VKEY_LWIN
}},
253 {ui::DomCode::OS_RIGHT
,
254 {true, ui::DomKey::OS
, ui::VKEY_LWIN
},
255 {true, ui::DomKey::OS
, ui::VKEY_LWIN
}},
256 // Non-modifiers (a representative sample here) succeed with
257 // DomKey::UNIDENTIFIED when Control is down.
258 {ui::DomCode::DIGIT1
,
259 {true, ui::DomKey::Constant
<'1'>::Character
, ui::VKEY_1
},
260 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_1
}},
262 {true, ui::DomKey::Constant
<'='>::Character
, ui::VKEY_OEM_PLUS
},
263 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_OEM_PLUS
}},
265 {true, ui::DomKey::TAB
, ui::VKEY_TAB
},
266 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_TAB
}},
268 {true, ui::DomKey::F1
, ui::VKEY_F1
},
269 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_F1
}},
270 {ui::DomCode::VOLUME_UP
,
271 {true, ui::DomKey::VOLUME_UP
, ui::VKEY_VOLUME_UP
},
272 {true, ui::DomKey::UNIDENTIFIED
, ui::VKEY_VOLUME_UP
}},
274 for (const auto& it
: kNonControlCharacters
) {
275 // Verify |DomCodeToControlCharacter()|.
276 CheckDomCodeToMeaning("n_cc_n", ui::DomCodeToControlCharacter
, it
.dom_code
,
277 ui::EF_NONE
, kUndefined
);
278 CheckDomCodeToMeaning("n_cc_c", ui::DomCodeToControlCharacter
, it
.dom_code
,
279 ui::EF_CONTROL_DOWN
, kUndefined
);
280 CheckDomCodeToMeaning("n_cc_cs", ui::DomCodeToControlCharacter
, it
.dom_code
,
281 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
, kUndefined
);
282 // Verify |DomCodeToUsLayoutDomKey()|.
283 CheckDomCodeToMeaning("n_us_n", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
284 ui::EF_NONE
, it
.normal
);
285 CheckDomCodeToMeaning("n_us_c", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
286 ui::EF_CONTROL_DOWN
, it
.control
);
287 CheckDomCodeToMeaning("n_us_cs", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
288 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
, it
.control
);
292 TEST(KeyboardCodeConversion
, UsLayout
) {
293 static const struct {
294 ui::DomCode dom_code
;
297 } kPrintableUsLayout
[] = {
299 {true, ui::DomKey::Constant
<'a'>::Character
, ui::VKEY_A
},
300 {true, ui::DomKey::Constant
<'A'>::Character
, ui::VKEY_A
}},
302 {true, ui::DomKey::Constant
<'b'>::Character
, ui::VKEY_B
},
303 {true, ui::DomKey::Constant
<'B'>::Character
, ui::VKEY_B
}},
305 {true, ui::DomKey::Constant
<'c'>::Character
, ui::VKEY_C
},
306 {true, ui::DomKey::Constant
<'C'>::Character
, ui::VKEY_C
}},
308 {true, ui::DomKey::Constant
<'d'>::Character
, ui::VKEY_D
},
309 {true, ui::DomKey::Constant
<'D'>::Character
, ui::VKEY_D
}},
311 {true, ui::DomKey::Constant
<'e'>::Character
, ui::VKEY_E
},
312 {true, ui::DomKey::Constant
<'E'>::Character
, ui::VKEY_E
}},
314 {true, ui::DomKey::Constant
<'f'>::Character
, ui::VKEY_F
},
315 {true, ui::DomKey::Constant
<'F'>::Character
, ui::VKEY_F
}},
317 {true, ui::DomKey::Constant
<'g'>::Character
, ui::VKEY_G
},
318 {true, ui::DomKey::Constant
<'G'>::Character
, ui::VKEY_G
}},
320 {true, ui::DomKey::Constant
<'h'>::Character
, ui::VKEY_H
},
321 {true, ui::DomKey::Constant
<'H'>::Character
, ui::VKEY_H
}},
323 {true, ui::DomKey::Constant
<'i'>::Character
, ui::VKEY_I
},
324 {true, ui::DomKey::Constant
<'I'>::Character
, ui::VKEY_I
}},
326 {true, ui::DomKey::Constant
<'j'>::Character
, ui::VKEY_J
},
327 {true, ui::DomKey::Constant
<'J'>::Character
, ui::VKEY_J
}},
329 {true, ui::DomKey::Constant
<'k'>::Character
, ui::VKEY_K
},
330 {true, ui::DomKey::Constant
<'K'>::Character
, ui::VKEY_K
}},
332 {true, ui::DomKey::Constant
<'l'>::Character
, ui::VKEY_L
},
333 {true, ui::DomKey::Constant
<'L'>::Character
, ui::VKEY_L
}},
335 {true, ui::DomKey::Constant
<'m'>::Character
, ui::VKEY_M
},
336 {true, ui::DomKey::Constant
<'M'>::Character
, ui::VKEY_M
}},
338 {true, ui::DomKey::Constant
<'n'>::Character
, ui::VKEY_N
},
339 {true, ui::DomKey::Constant
<'N'>::Character
, ui::VKEY_N
}},
341 {true, ui::DomKey::Constant
<'o'>::Character
, ui::VKEY_O
},
342 {true, ui::DomKey::Constant
<'O'>::Character
, ui::VKEY_O
}},
344 {true, ui::DomKey::Constant
<'p'>::Character
, ui::VKEY_P
},
345 {true, ui::DomKey::Constant
<'P'>::Character
, ui::VKEY_P
}},
347 {true, ui::DomKey::Constant
<'q'>::Character
, ui::VKEY_Q
},
348 {true, ui::DomKey::Constant
<'Q'>::Character
, ui::VKEY_Q
}},
350 {true, ui::DomKey::Constant
<'r'>::Character
, ui::VKEY_R
},
351 {true, ui::DomKey::Constant
<'R'>::Character
, ui::VKEY_R
}},
353 {true, ui::DomKey::Constant
<'s'>::Character
, ui::VKEY_S
},
354 {true, ui::DomKey::Constant
<'S'>::Character
, ui::VKEY_S
}},
356 {true, ui::DomKey::Constant
<'t'>::Character
, ui::VKEY_T
},
357 {true, ui::DomKey::Constant
<'T'>::Character
, ui::VKEY_T
}},
359 {true, ui::DomKey::Constant
<'u'>::Character
, ui::VKEY_U
},
360 {true, ui::DomKey::Constant
<'U'>::Character
, ui::VKEY_U
}},
362 {true, ui::DomKey::Constant
<'v'>::Character
, ui::VKEY_V
},
363 {true, ui::DomKey::Constant
<'V'>::Character
, ui::VKEY_V
}},
365 {true, ui::DomKey::Constant
<'w'>::Character
, ui::VKEY_W
},
366 {true, ui::DomKey::Constant
<'W'>::Character
, ui::VKEY_W
}},
368 {true, ui::DomKey::Constant
<'x'>::Character
, ui::VKEY_X
},
369 {true, ui::DomKey::Constant
<'X'>::Character
, ui::VKEY_X
}},
371 {true, ui::DomKey::Constant
<'y'>::Character
, ui::VKEY_Y
},
372 {true, ui::DomKey::Constant
<'Y'>::Character
, ui::VKEY_Y
}},
374 {true, ui::DomKey::Constant
<'z'>::Character
, ui::VKEY_Z
},
375 {true, ui::DomKey::Constant
<'Z'>::Character
, ui::VKEY_Z
}},
376 {ui::DomCode::DIGIT1
,
377 {true, ui::DomKey::Constant
<'1'>::Character
, ui::VKEY_1
},
378 {true, ui::DomKey::Constant
<'!'>::Character
, ui::VKEY_1
}},
379 {ui::DomCode::DIGIT2
,
380 {true, ui::DomKey::Constant
<'2'>::Character
, ui::VKEY_2
},
381 {true, ui::DomKey::Constant
<'@'>::Character
, ui::VKEY_2
}},
382 {ui::DomCode::DIGIT3
,
383 {true, ui::DomKey::Constant
<'3'>::Character
, ui::VKEY_3
},
384 {true, ui::DomKey::Constant
<'#'>::Character
, ui::VKEY_3
}},
385 {ui::DomCode::DIGIT4
,
386 {true, ui::DomKey::Constant
<'4'>::Character
, ui::VKEY_4
},
387 {true, ui::DomKey::Constant
<'$'>::Character
, ui::VKEY_4
}},
388 {ui::DomCode::DIGIT5
,
389 {true, ui::DomKey::Constant
<'5'>::Character
, ui::VKEY_5
},
390 {true, ui::DomKey::Constant
<'%'>::Character
, ui::VKEY_5
}},
391 {ui::DomCode::DIGIT6
,
392 {true, ui::DomKey::Constant
<'6'>::Character
, ui::VKEY_6
},
393 {true, ui::DomKey::Constant
<'^'>::Character
, ui::VKEY_6
}},
394 {ui::DomCode::DIGIT7
,
395 {true, ui::DomKey::Constant
<'7'>::Character
, ui::VKEY_7
},
396 {true, ui::DomKey::Constant
<'&'>::Character
, ui::VKEY_7
}},
397 {ui::DomCode::DIGIT8
,
398 {true, ui::DomKey::Constant
<'8'>::Character
, ui::VKEY_8
},
399 {true, ui::DomKey::Constant
<'*'>::Character
, ui::VKEY_8
}},
400 {ui::DomCode::DIGIT9
,
401 {true, ui::DomKey::Constant
<'9'>::Character
, ui::VKEY_9
},
402 {true, ui::DomKey::Constant
<'('>::Character
, ui::VKEY_9
}},
403 {ui::DomCode::DIGIT0
,
404 {true, ui::DomKey::Constant
<'0'>::Character
, ui::VKEY_0
},
405 {true, ui::DomKey::Constant
<')'>::Character
, ui::VKEY_0
}},
407 {true, ui::DomKey::Constant
<' '>::Character
, ui::VKEY_SPACE
},
408 {true, ui::DomKey::Constant
<' '>::Character
, ui::VKEY_SPACE
}},
410 {true, ui::DomKey::Constant
<'-'>::Character
, ui::VKEY_OEM_MINUS
},
411 {true, ui::DomKey::Constant
<'_'>::Character
, ui::VKEY_OEM_MINUS
}},
413 {true, ui::DomKey::Constant
<'='>::Character
, ui::VKEY_OEM_PLUS
},
414 {true, ui::DomKey::Constant
<'+'>::Character
, ui::VKEY_OEM_PLUS
}},
415 {ui::DomCode::BRACKET_LEFT
,
416 {true, ui::DomKey::Constant
<'['>::Character
, ui::VKEY_OEM_4
},
417 {true, ui::DomKey::Constant
<'{'>::Character
, ui::VKEY_OEM_4
}},
418 {ui::DomCode::BRACKET_RIGHT
,
419 {true, ui::DomKey::Constant
<']'>::Character
, ui::VKEY_OEM_6
},
420 {true, ui::DomKey::Constant
<'}'>::Character
, ui::VKEY_OEM_6
}},
421 {ui::DomCode::BACKSLASH
,
422 {true, ui::DomKey::Constant
<'\\'>::Character
, ui::VKEY_OEM_5
},
423 {true, ui::DomKey::Constant
<'|'>::Character
, ui::VKEY_OEM_5
}},
424 {ui::DomCode::SEMICOLON
,
425 {true, ui::DomKey::Constant
<';'>::Character
, ui::VKEY_OEM_1
},
426 {true, ui::DomKey::Constant
<':'>::Character
, ui::VKEY_OEM_1
}},
428 {true, ui::DomKey::Constant
<'\''>::Character
, ui::VKEY_OEM_7
},
429 {true, ui::DomKey::Constant
<'"'>::Character
, ui::VKEY_OEM_7
}},
430 {ui::DomCode::BACKQUOTE
,
431 {true, ui::DomKey::Constant
<'`'>::Character
, ui::VKEY_OEM_3
},
432 {true, ui::DomKey::Constant
<'~'>::Character
, ui::VKEY_OEM_3
}},
434 {true, ui::DomKey::Constant
<','>::Character
, ui::VKEY_OEM_COMMA
},
435 {true, ui::DomKey::Constant
<'<'>::Character
, ui::VKEY_OEM_COMMA
}},
436 {ui::DomCode::PERIOD
,
437 {true, ui::DomKey::Constant
<'.'>::Character
, ui::VKEY_OEM_PERIOD
},
438 {true, ui::DomKey::Constant
<'>'>::Character
, ui::VKEY_OEM_PERIOD
}},
440 {true, ui::DomKey::Constant
<'/'>::Character
, ui::VKEY_OEM_2
},
441 {true, ui::DomKey::Constant
<'?'>::Character
, ui::VKEY_OEM_2
}},
442 {ui::DomCode::INTL_BACKSLASH
,
443 {true, ui::DomKey::Constant
<'<'>::Character
, ui::VKEY_OEM_102
},
444 {true, ui::DomKey::Constant
<'>'>::Character
, ui::VKEY_OEM_102
}},
445 {ui::DomCode::INTL_YEN
,
446 {true, ui::DomKey::Constant
<0x00A5>::Character
, ui::VKEY_OEM_5
},
447 {true, ui::DomKey::Constant
<'|'>::Character
, ui::VKEY_OEM_5
}},
448 {ui::DomCode::NUMPAD_DIVIDE
,
449 {true, ui::DomKey::Constant
<'/'>::Character
, ui::VKEY_DIVIDE
},
450 {true, ui::DomKey::Constant
<'/'>::Character
, ui::VKEY_DIVIDE
}},
451 {ui::DomCode::NUMPAD_MULTIPLY
,
452 {true, ui::DomKey::Constant
<'*'>::Character
, ui::VKEY_MULTIPLY
},
453 {true, ui::DomKey::Constant
<'*'>::Character
, ui::VKEY_MULTIPLY
}},
454 {ui::DomCode::NUMPAD_SUBTRACT
,
455 {true, ui::DomKey::Constant
<'-'>::Character
, ui::VKEY_SUBTRACT
},
456 {true, ui::DomKey::Constant
<'-'>::Character
, ui::VKEY_SUBTRACT
}},
457 {ui::DomCode::NUMPAD_ADD
,
458 {true, ui::DomKey::Constant
<'+'>::Character
, ui::VKEY_ADD
},
459 {true, ui::DomKey::Constant
<'+'>::Character
, ui::VKEY_ADD
}},
460 {ui::DomCode::NUMPAD1
,
461 {true, ui::DomKey::Constant
<'1'>::Character
, ui::VKEY_1
},
462 {true, ui::DomKey::Constant
<'1'>::Character
, ui::VKEY_1
}},
463 {ui::DomCode::NUMPAD2
,
464 {true, ui::DomKey::Constant
<'2'>::Character
, ui::VKEY_2
},
465 {true, ui::DomKey::Constant
<'2'>::Character
, ui::VKEY_2
}},
466 {ui::DomCode::NUMPAD3
,
467 {true, ui::DomKey::Constant
<'3'>::Character
, ui::VKEY_3
},
468 {true, ui::DomKey::Constant
<'3'>::Character
, ui::VKEY_3
}},
469 {ui::DomCode::NUMPAD4
,
470 {true, ui::DomKey::Constant
<'4'>::Character
, ui::VKEY_4
},
471 {true, ui::DomKey::Constant
<'4'>::Character
, ui::VKEY_4
}},
472 {ui::DomCode::NUMPAD5
,
473 {true, ui::DomKey::Constant
<'5'>::Character
, ui::VKEY_5
},
474 {true, ui::DomKey::Constant
<'5'>::Character
, ui::VKEY_5
}},
475 {ui::DomCode::NUMPAD6
,
476 {true, ui::DomKey::Constant
<'6'>::Character
, ui::VKEY_6
},
477 {true, ui::DomKey::Constant
<'6'>::Character
, ui::VKEY_6
}},
478 {ui::DomCode::NUMPAD7
,
479 {true, ui::DomKey::Constant
<'7'>::Character
, ui::VKEY_7
},
480 {true, ui::DomKey::Constant
<'7'>::Character
, ui::VKEY_7
}},
481 {ui::DomCode::NUMPAD8
,
482 {true, ui::DomKey::Constant
<'8'>::Character
, ui::VKEY_8
},
483 {true, ui::DomKey::Constant
<'8'>::Character
, ui::VKEY_8
}},
484 {ui::DomCode::NUMPAD9
,
485 {true, ui::DomKey::Constant
<'9'>::Character
, ui::VKEY_9
},
486 {true, ui::DomKey::Constant
<'9'>::Character
, ui::VKEY_9
}},
487 {ui::DomCode::NUMPAD0
,
488 {true, ui::DomKey::Constant
<'0'>::Character
, ui::VKEY_0
},
489 {true, ui::DomKey::Constant
<'0'>::Character
, ui::VKEY_0
}},
490 {ui::DomCode::NUMPAD_DECIMAL
,
491 {true, ui::DomKey::Constant
<'.'>::Character
, ui::VKEY_DECIMAL
},
492 {true, ui::DomKey::Constant
<'.'>::Character
, ui::VKEY_DECIMAL
}},
493 {ui::DomCode::NUMPAD_EQUAL
,
494 {true, ui::DomKey::Constant
<'='>::Character
, ui::VKEY_UNKNOWN
},
495 {true, ui::DomKey::Constant
<'='>::Character
, ui::VKEY_UNKNOWN
}},
496 {ui::DomCode::NUMPAD_COMMA
,
497 {true, ui::DomKey::Constant
<','>::Character
, ui::VKEY_OEM_COMMA
},
498 {true, ui::DomKey::Constant
<','>::Character
, ui::VKEY_OEM_COMMA
}},
499 {ui::DomCode::NUMPAD_PAREN_LEFT
,
500 {true, ui::DomKey::Constant
<'('>::Character
, ui::VKEY_UNKNOWN
},
501 {true, ui::DomKey::Constant
<'('>::Character
, ui::VKEY_UNKNOWN
}},
502 {ui::DomCode::NUMPAD_PAREN_RIGHT
,
503 {true, ui::DomKey::Constant
<')'>::Character
, ui::VKEY_UNKNOWN
},
504 {true, ui::DomKey::Constant
<')'>::Character
, ui::VKEY_UNKNOWN
}},
505 {ui::DomCode::NUMPAD_SIGN_CHANGE
,
506 {true, ui::DomKey::Constant
<0xB1>::Character
, ui::VKEY_UNKNOWN
},
507 {true, ui::DomKey::Constant
<0xB1>::Character
, ui::VKEY_UNKNOWN
}},
510 for (const auto& it
: kPrintableUsLayout
) {
511 CheckDomCodeToMeaning("p_us_n", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
512 ui::EF_NONE
, it
.normal
);
513 CheckDomCodeToMeaning("p_us_s", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
514 ui::EF_SHIFT_DOWN
, it
.shift
);
515 CheckDomCodeToMeaning("p_us_a", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
516 ui::EF_ALTGR_DOWN
, it
.normal
);
517 CheckDomCodeToMeaning("p_us_a", ui::DomCodeToUsLayoutDomKey
, it
.dom_code
,
518 ui::EF_ALTGR_DOWN
|ui::EF_SHIFT_DOWN
, it
.shift
);
522 TEST(KeyboardCodeConversion
, Tables
) {
523 // Verify that kDomCodeToKeyboardCodeMap is ordered by DomCode value.
524 uint32_t previous
= 0;
525 for (const auto& it
: ui::kDomCodeToKeyboardCodeMap
) {
526 uint32_t current
= static_cast<uint32_t>(it
.dom_code
);
527 EXPECT_LT(previous
, current
);