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
3 // found in the LICENSE file.
8 #include <X11/extensions/XInput2.h>
10 #include <X11/Xutil.h>
11 #include <X11/XKBlib.h>
13 // Generically-named #defines from Xlib that conflict with symbols in GTest.
17 #include "base/memory/scoped_ptr.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/events/event.h"
20 #include "ui/events/event_constants.h"
21 #include "ui/events/event_utils.h"
22 #include "ui/events/test/events_test_utils_x11.h"
23 #include "ui/events/x/device_data_manager_x11.h"
24 #include "ui/events/x/touch_factory_x11.h"
25 #include "ui/gfx/point.h"
31 // Initializes the passed-in Xlib event.
32 void InitButtonEvent(XEvent
* event
,
34 const gfx::Point
& location
,
37 memset(event
, 0, sizeof(*event
));
39 // We don't bother setting fields that the event code doesn't use, such as
40 // x_root/y_root and window/root/subwindow.
41 XButtonEvent
* button_event
= &(event
->xbutton
);
42 button_event
->type
= is_press
? ButtonPress
: ButtonRelease
;
43 button_event
->x
= location
.x();
44 button_event
->y
= location
.y();
45 button_event
->button
= button
;
46 button_event
->state
= state
;
49 // Initializes the passed-in Xlib event.
50 void InitKeyEvent(Display
* display
,
55 memset(event
, 0, sizeof(*event
));
57 // We don't bother setting fields that the event code doesn't use, such as
58 // x_root/y_root and window/root/subwindow.
59 XKeyEvent
* key_event
= &(event
->xkey
);
60 key_event
->display
= display
;
61 key_event
->type
= is_press
? KeyPress
: KeyRelease
;
62 key_event
->keycode
= keycode
;
63 key_event
->state
= state
;
66 // Returns true if the keysym maps to a KeyEvent with the EF_FUNCTION_KEY
67 // flag set, or the keysym maps to a zero key code.
68 bool HasFunctionKeyFlagSetIfSupported(Display
* display
, int x_keysym
) {
70 int x_keycode
= XKeysymToKeycode(display
, x_keysym
);
71 // Exclude keysyms for which the server has no corresponding keycode.
73 InitKeyEvent(display
, &event
, true, x_keycode
, 0);
74 ui::KeyEvent
ui_key_event(&event
, false);
75 return (ui_key_event
.flags() & ui::EF_FUNCTION_KEY
);
82 class EventsXTest
: public testing::Test
{
85 virtual ~EventsXTest() {}
87 virtual void SetUp() OVERRIDE
{
88 DeviceDataManagerX11::CreateInstance();
91 DISALLOW_COPY_AND_ASSIGN(EventsXTest
);
94 TEST_F(EventsXTest
, ButtonEvents
) {
96 gfx::Point
location(5, 10);
99 InitButtonEvent(&event
, true, location
, 1, 0);
100 EXPECT_EQ(ui::ET_MOUSE_PRESSED
, ui::EventTypeFromNative(&event
));
101 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON
, ui::EventFlagsFromNative(&event
));
102 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
104 InitButtonEvent(&event
, true, location
, 2, Button1Mask
| ShiftMask
);
105 EXPECT_EQ(ui::ET_MOUSE_PRESSED
, ui::EventTypeFromNative(&event
));
106 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON
| ui::EF_MIDDLE_MOUSE_BUTTON
|
108 ui::EventFlagsFromNative(&event
));
109 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
111 InitButtonEvent(&event
, false, location
, 3, 0);
112 EXPECT_EQ(ui::ET_MOUSE_RELEASED
, ui::EventTypeFromNative(&event
));
113 EXPECT_EQ(ui::EF_RIGHT_MOUSE_BUTTON
, ui::EventFlagsFromNative(&event
));
114 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
117 InitButtonEvent(&event
, true, location
, 4, 0);
118 EXPECT_EQ(ui::ET_MOUSEWHEEL
, ui::EventTypeFromNative(&event
));
119 EXPECT_EQ(0, ui::EventFlagsFromNative(&event
));
120 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
121 offset
= ui::GetMouseWheelOffset(&event
);
122 EXPECT_GT(offset
.y(), 0);
123 EXPECT_EQ(0, offset
.x());
126 InitButtonEvent(&event
, true, location
, 5, 0);
127 EXPECT_EQ(ui::ET_MOUSEWHEEL
, ui::EventTypeFromNative(&event
));
128 EXPECT_EQ(0, ui::EventFlagsFromNative(&event
));
129 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
130 offset
= ui::GetMouseWheelOffset(&event
);
131 EXPECT_LT(offset
.y(), 0);
132 EXPECT_EQ(0, offset
.x());
135 InitButtonEvent(&event
, true, location
, 6, 0);
136 EXPECT_EQ(ui::ET_MOUSEWHEEL
, ui::EventTypeFromNative(&event
));
137 EXPECT_EQ(0, ui::EventFlagsFromNative(&event
));
138 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
139 offset
= ui::GetMouseWheelOffset(&event
);
140 EXPECT_EQ(0, offset
.y());
141 EXPECT_GT(offset
.x(), 0);
144 InitButtonEvent(&event
, true, location
, 7, 0);
145 EXPECT_EQ(ui::ET_MOUSEWHEEL
, ui::EventTypeFromNative(&event
));
146 EXPECT_EQ(0, ui::EventFlagsFromNative(&event
));
147 EXPECT_EQ(location
, ui::EventLocationFromNative(&event
));
148 offset
= ui::GetMouseWheelOffset(&event
);
149 EXPECT_EQ(0, offset
.y());
150 EXPECT_LT(offset
.x(), 0);
152 // TODO(derat): Test XInput code.
155 TEST_F(EventsXTest
, AvoidExtraEventsOnWheelRelease
) {
157 gfx::Point
location(5, 10);
159 InitButtonEvent(&event
, true, location
, 4, 0);
160 EXPECT_EQ(ui::ET_MOUSEWHEEL
, ui::EventTypeFromNative(&event
));
162 // We should return ET_UNKNOWN for the release event instead of returning
163 // ET_MOUSEWHEEL; otherwise we'll scroll twice for each scrollwheel step.
164 InitButtonEvent(&event
, false, location
, 4, 0);
165 EXPECT_EQ(ui::ET_UNKNOWN
, ui::EventTypeFromNative(&event
));
167 // TODO(derat): Test XInput code.
170 TEST_F(EventsXTest
, EnterLeaveEvent
) {
172 event
.xcrossing
.type
= EnterNotify
;
173 event
.xcrossing
.x
= 10;
174 event
.xcrossing
.y
= 20;
175 event
.xcrossing
.x_root
= 110;
176 event
.xcrossing
.y_root
= 120;
178 // Mouse enter events are converted to mouse move events to be consistent with
179 // the way views handle mouse enter. See comments for EnterNotify case in
180 // ui::EventTypeFromNative for more details.
181 EXPECT_EQ(ui::ET_MOUSE_MOVED
, ui::EventTypeFromNative(&event
));
182 EXPECT_EQ("10,20", ui::EventLocationFromNative(&event
).ToString());
183 EXPECT_EQ("110,120", ui::EventSystemLocationFromNative(&event
).ToString());
185 event
.xcrossing
.type
= LeaveNotify
;
186 event
.xcrossing
.x
= 30;
187 event
.xcrossing
.y
= 40;
188 event
.xcrossing
.x_root
= 230;
189 event
.xcrossing
.y_root
= 240;
190 EXPECT_EQ(ui::ET_MOUSE_EXITED
, ui::EventTypeFromNative(&event
));
191 EXPECT_EQ("30,40", ui::EventLocationFromNative(&event
).ToString());
192 EXPECT_EQ("230,240", ui::EventSystemLocationFromNative(&event
).ToString());
195 TEST_F(EventsXTest
, ClickCount
) {
197 gfx::Point
location(5, 10);
199 for (int i
= 1; i
<= 3; ++i
) {
200 InitButtonEvent(&event
, true, location
, 1, 0);
202 MouseEvent
mouseev(&event
);
203 EXPECT_EQ(ui::ET_MOUSE_PRESSED
, mouseev
.type());
204 EXPECT_EQ(i
, mouseev
.GetClickCount());
207 InitButtonEvent(&event
, false, location
, 1, 0);
209 MouseEvent
mouseev(&event
);
210 EXPECT_EQ(ui::ET_MOUSE_RELEASED
, mouseev
.type());
211 EXPECT_EQ(i
, mouseev
.GetClickCount());
216 #if defined(USE_XI2_MT)
217 TEST_F(EventsXTest
, TouchEventBasic
) {
218 std::vector
<unsigned int> devices
;
219 devices
.push_back(0);
220 ui::SetUpTouchDevicesForTest(devices
);
221 std::vector
<Valuator
> valuators
;
223 // Init touch begin with tracking id 5, touch id 0.
224 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR
, 20));
226 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION
, 0.3f
));
227 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_PRESSURE
, 100));
228 ui::ScopedXI2Event scoped_xevent
;
229 scoped_xevent
.InitTouchEvent(
230 0, XI_TouchBegin
, 5, gfx::Point(10, 10), valuators
);
231 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, ui::EventTypeFromNative(scoped_xevent
));
232 EXPECT_EQ("10,10", ui::EventLocationFromNative(scoped_xevent
).ToString());
233 EXPECT_EQ(GetTouchId(scoped_xevent
), 0);
234 EXPECT_EQ(GetTouchRadiusX(scoped_xevent
), 10);
235 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent
), 0.15f
);
236 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent
), 0.1f
);
238 // Touch update, with new orientation info.
241 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION
, 0.5f
));
242 scoped_xevent
.InitTouchEvent(
243 0, XI_TouchUpdate
, 5, gfx::Point(20, 20), valuators
);
244 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ui::EventTypeFromNative(scoped_xevent
));
245 EXPECT_EQ("20,20", ui::EventLocationFromNative(scoped_xevent
).ToString());
246 EXPECT_EQ(GetTouchId(scoped_xevent
), 0);
247 EXPECT_EQ(GetTouchRadiusX(scoped_xevent
), 10);
248 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent
), 0.25f
);
249 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent
), 0.1f
);
251 // Another touch with tracking id 6, touch id 1.
253 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR
, 100));
254 valuators
.push_back(Valuator(
255 DeviceDataManagerX11::DT_TOUCH_ORIENTATION
, 0.9f
));
256 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_PRESSURE
, 500));
257 scoped_xevent
.InitTouchEvent(
258 0, XI_TouchBegin
, 6, gfx::Point(200, 200), valuators
);
259 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, ui::EventTypeFromNative(scoped_xevent
));
260 EXPECT_EQ("200,200", ui::EventLocationFromNative(scoped_xevent
).ToString());
261 EXPECT_EQ(GetTouchId(scoped_xevent
), 1);
262 EXPECT_EQ(GetTouchRadiusX(scoped_xevent
), 50);
263 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent
), 0.45f
);
264 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent
), 0.5f
);
266 // Touch with tracking id 5 should have old radius/angle value and new pressue
269 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_PRESSURE
, 50));
270 scoped_xevent
.InitTouchEvent(
271 0, XI_TouchEnd
, 5, gfx::Point(30, 30), valuators
);
272 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ui::EventTypeFromNative(scoped_xevent
));
273 EXPECT_EQ("30,30", ui::EventLocationFromNative(scoped_xevent
).ToString());
274 EXPECT_EQ(GetTouchId(scoped_xevent
), 0);
275 EXPECT_EQ(GetTouchRadiusX(scoped_xevent
), 10);
276 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent
), 0.25f
);
277 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent
), 0.05f
);
279 // Touch with tracking id 6 should have old angle/pressure value and new
282 valuators
.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR
, 50));
283 scoped_xevent
.InitTouchEvent(
284 0, XI_TouchEnd
, 6, gfx::Point(200, 200), valuators
);
285 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ui::EventTypeFromNative(scoped_xevent
));
286 EXPECT_EQ("200,200", ui::EventLocationFromNative(scoped_xevent
).ToString());
287 EXPECT_EQ(GetTouchId(scoped_xevent
), 1);
288 EXPECT_EQ(GetTouchRadiusX(scoped_xevent
), 25);
289 EXPECT_FLOAT_EQ(GetTouchAngle(scoped_xevent
), 0.45f
);
290 EXPECT_FLOAT_EQ(GetTouchForce(scoped_xevent
), 0.5f
);
294 TEST_F(EventsXTest
, NumpadKeyEvents
) {
296 Display
* display
= gfx::GetXDisplay();
302 // XK_KP_Space and XK_KP_Equal are the extrema in the conventional
303 // keysymdef.h numbering.
304 { true, XK_KP_Space
},
305 { true, XK_KP_Equal
},
306 // Other numpad keysyms. (This is actually exhaustive in the current list.)
308 { true, XK_KP_Enter
},
313 { true, XK_KP_Home
},
314 { true, XK_KP_Left
},
316 { true, XK_KP_Right
},
317 { true, XK_KP_Down
},
318 { true, XK_KP_Prior
},
319 { true, XK_KP_Page_Up
},
320 { true, XK_KP_Next
},
321 { true, XK_KP_Page_Down
},
323 { true, XK_KP_Begin
},
324 { true, XK_KP_Insert
},
325 { true, XK_KP_Delete
},
326 { true, XK_KP_Multiply
},
328 { true, XK_KP_Separator
},
329 { true, XK_KP_Subtract
},
330 { true, XK_KP_Decimal
},
331 { true, XK_KP_Divide
},
342 // Largest keysym preceding XK_KP_Space.
343 { false, XK_Num_Lock
},
344 // Smallest keysym following XK_KP_Equal.
346 // Non-numpad analogues of numpad keysyms.
348 { false, XK_Return
},
359 { false, XK_Page_Up
},
361 { false, XK_Page_Down
},
363 { false, XK_Insert
},
364 { false, XK_Delete
},
365 { false, XK_multiply
},
368 { false, XK_period
},
380 // Miscellaneous other keysyms.
381 { false, XK_BackSpace
},
382 { false, XK_Scroll_Lock
},
383 { false, XK_Multi_key
},
384 { false, XK_Select
},
385 { false, XK_Num_Lock
},
386 { false, XK_Shift_L
},
391 for (size_t k
= 0; k
< ARRAYSIZE_UNSAFE(keys
); ++k
) {
392 int x_keycode
= XKeysymToKeycode(display
, keys
[k
].x_keysym
);
393 // Exclude keysyms for which the server has no corresponding keycode.
395 InitKeyEvent(display
, &event
, true, x_keycode
, 0);
396 // int keysym = XLookupKeysym(&event.xkey, 0);
398 ui::KeyEvent
ui_key_event(&event
, false);
399 EXPECT_EQ(keys
[k
].is_numpad_key
? ui::EF_NUMPAD_KEY
: 0,
400 ui_key_event
.flags() & ui::EF_NUMPAD_KEY
);
405 TEST_F(EventsXTest
, FunctionKeyEvents
) {
406 Display
* display
= gfx::GetXDisplay();
408 // Min function key code minus 1.
409 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display
, XK_F1
- 1));
410 // All function keys.
411 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F1
));
412 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F2
));
413 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F3
));
414 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F4
));
415 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F5
));
416 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F6
));
417 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F7
));
418 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F8
));
419 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F9
));
420 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F10
));
421 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F11
));
422 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F12
));
423 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F13
));
424 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F14
));
425 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F15
));
426 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F16
));
427 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F17
));
428 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F18
));
429 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F19
));
430 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F20
));
431 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F21
));
432 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F22
));
433 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F23
));
434 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F24
));
435 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F25
));
436 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F26
));
437 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F27
));
438 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F28
));
439 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F29
));
440 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F30
));
441 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F31
));
442 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F32
));
443 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F33
));
444 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F34
));
445 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display
, XK_F35
));
446 // Max function key code plus 1.
447 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display
, XK_F35
+ 1));
450 // Verifies that the type of events from a disabled keyboard is ET_UNKNOWN, but
451 // that an exception list of keys can still be processed.
452 TEST_F(EventsXTest
, DisableKeyboard
) {
453 DeviceDataManagerX11
* device_data_manager
=
454 static_cast<DeviceDataManagerX11
*>(
455 DeviceDataManager::GetInstance());
456 scoped_ptr
<std::set
<KeyboardCode
> > excepted_keys(new std::set
<KeyboardCode
>);
457 excepted_keys
->insert(VKEY_B
);
458 device_data_manager
->DisableKeyboard(excepted_keys
.Pass());
460 Display
* display
= gfx::GetXDisplay();
463 // A is not allowed on the blocked keyboard, and should return ET_UNKNOWN.
464 InitKeyEvent(display
, &event
, true, XKeysymToKeycode(display
, XK_A
), 0);
465 EXPECT_EQ(ui::ET_UNKNOWN
, ui::EventTypeFromNative(&event
));
467 // The B key is allowed as an exception, and should return KEY_PRESSED.
468 InitKeyEvent(display
, &event
, true, XKeysymToKeycode(display
, XK_B
), 0);
469 EXPECT_EQ(ui::ET_KEY_PRESSED
, ui::EventTypeFromNative(&event
));
471 device_data_manager
->EnableKeyboard();
473 // A key returns KEY_PRESSED as per usual now that keyboard was re-enabled.
474 InitKeyEvent(display
, &event
, true, XKeysymToKeycode(display
, XK_A
), 0);
475 EXPECT_EQ(ui::ET_KEY_PRESSED
, ui::EventTypeFromNative(&event
));
478 #if defined(USE_XI2_MT)
479 // Verifies that the type of events from a disabled mouse is ET_UNKNOWN.
480 TEST_F(EventsXTest
, DisableMouse
) {
481 DeviceDataManagerX11
* device_data_manager
=
482 static_cast<DeviceDataManagerX11
*>(
483 DeviceDataManager::GetInstance());
484 unsigned int blocked_device_id
= 1;
485 unsigned int other_device_id
= 2;
486 std::vector
<unsigned int> device_list
;
487 device_list
.push_back(blocked_device_id
);
488 device_list
.push_back(other_device_id
);
489 TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list
);
491 device_data_manager
->DisableDevice(blocked_device_id
);
494 xev
.InitGenericButtonEvent(blocked_device_id
, ET_MOUSE_PRESSED
, gfx::Point(),
495 EF_LEFT_MOUSE_BUTTON
);
496 EXPECT_EQ(ui::ET_UNKNOWN
, ui::EventTypeFromNative(xev
));
498 xev
.InitGenericButtonEvent(other_device_id
, ET_MOUSE_PRESSED
, gfx::Point(),
499 EF_LEFT_MOUSE_BUTTON
);
500 EXPECT_EQ(ui::ET_MOUSE_PRESSED
, ui::EventTypeFromNative(xev
));
502 device_data_manager
->EnableDevice(blocked_device_id
);
504 xev
.InitGenericButtonEvent(blocked_device_id
, ET_MOUSE_PRESSED
, gfx::Point(),
505 EF_LEFT_MOUSE_BUTTON
);
506 EXPECT_EQ(ui::ET_MOUSE_PRESSED
, ui::EventTypeFromNative(xev
));
508 #endif // defined(USE_XI2_MT)
510 #if !defined(OS_CHROMEOS)
511 TEST_F(EventsXTest
, ImeFabricatedKeyEvents
) {
512 Display
* display
= gfx::GetXDisplay();
514 unsigned int state_to_be_fabricated
[] = {
515 0, ShiftMask
, LockMask
, ShiftMask
| LockMask
,
517 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(state_to_be_fabricated
); ++i
) {
518 unsigned int state
= state_to_be_fabricated
[i
];
519 for (int is_char
= 0; is_char
< 2; ++is_char
) {
521 InitKeyEvent(display
, &x_event
, true, 0, state
);
522 ui::KeyEvent
key_event(&x_event
, is_char
);
523 EXPECT_TRUE(key_event
.flags() & ui::EF_IME_FABRICATED_KEY
);
527 unsigned int state_to_be_not_fabricated
[] = {
528 ControlMask
, Mod1Mask
, Mod2Mask
, ShiftMask
| ControlMask
,
530 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(state_to_be_not_fabricated
); ++i
) {
531 unsigned int state
= state_to_be_not_fabricated
[i
];
532 for (int is_char
= 0; is_char
< 2; ++is_char
) {
534 InitKeyEvent(display
, &x_event
, true, 0, state
);
535 ui::KeyEvent
key_event(&x_event
, is_char
);
536 EXPECT_FALSE(key_event
.flags() & ui::EF_IME_FABRICATED_KEY
);