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.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/events/event.h"
8 #include "ui/events/event_utils.h"
9 #include "ui/events/keycodes/dom4/keycode_converter.h"
10 #include "ui/events/test/events_test_utils.h"
11
12 #if defined(USE_X11)
13 #include <X11/Xlib.h>
14 #include "ui/events/test/events_test_utils_x11.h"
15 #include "ui/gfx/x/x11_types.h"
16 #endif
17
18 namespace ui {
19
TEST(EventTest,NoNativeEvent)20 TEST(EventTest, NoNativeEvent) {
21 KeyEvent keyev(ET_KEY_PRESSED, VKEY_SPACE, 0, false);
22 EXPECT_FALSE(keyev.HasNativeEvent());
23 }
24
TEST(EventTest,NativeEvent)25 TEST(EventTest, NativeEvent) {
26 #if defined(OS_WIN)
27 MSG native_event = { NULL, WM_KEYUP, VKEY_A, 0 };
28 KeyEvent keyev(native_event, false);
29 EXPECT_TRUE(keyev.HasNativeEvent());
30 #elif defined(USE_X11)
31 ScopedXI2Event event;
32 event.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, 0);
33 KeyEvent keyev(event, false);
34 EXPECT_TRUE(keyev.HasNativeEvent());
35 #endif
36 }
37
TEST(EventTest,GetCharacter)38 TEST(EventTest, GetCharacter) {
39 // Check if Control+Enter returns 10.
40 KeyEvent keyev1(ET_KEY_PRESSED, VKEY_RETURN, EF_CONTROL_DOWN, false);
41 EXPECT_EQ(10, keyev1.GetCharacter());
42 // Check if Enter returns 13.
43 KeyEvent keyev2(ET_KEY_PRESSED, VKEY_RETURN, 0, false);
44 EXPECT_EQ(13, keyev2.GetCharacter());
45
46 #if defined(USE_X11)
47 // For X11, test the functions with native_event() as well. crbug.com/107837
48 ScopedXI2Event event;
49 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, EF_CONTROL_DOWN);
50 KeyEvent keyev3(event, false);
51 EXPECT_EQ(10, keyev3.GetCharacter());
52
53 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, 0);
54 KeyEvent keyev4(event, false);
55 EXPECT_EQ(13, keyev4.GetCharacter());
56 #endif
57 }
58
TEST(EventTest,ClickCount)59 TEST(EventTest, ClickCount) {
60 const gfx::Point origin(0, 0);
61 MouseEvent mouseev(ET_MOUSE_PRESSED, origin, origin, 0, 0);
62 for (int i = 1; i <=3 ; ++i) {
63 mouseev.SetClickCount(i);
64 EXPECT_EQ(i, mouseev.GetClickCount());
65 }
66 }
67
TEST(EventTest,RepeatedClick)68 TEST(EventTest, RepeatedClick) {
69 const gfx::Point origin(0, 0);
70 MouseEvent mouse_ev1(ET_MOUSE_PRESSED, origin, origin, 0, 0);
71 MouseEvent mouse_ev2(ET_MOUSE_PRESSED, origin, origin, 0, 0);
72 LocatedEventTestApi test_ev1(&mouse_ev1);
73 LocatedEventTestApi test_ev2(&mouse_ev2);
74
75 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0);
76 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1);
77 base::TimeDelta later = start + base::TimeDelta::FromMilliseconds(1000);
78
79 // Close point.
80 test_ev1.set_location(gfx::Point(0, 0));
81 test_ev2.set_location(gfx::Point(1, 0));
82 test_ev1.set_time_stamp(start);
83 test_ev2.set_time_stamp(soon);
84 EXPECT_TRUE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2));
85
86 // Too far.
87 test_ev1.set_location(gfx::Point(0, 0));
88 test_ev2.set_location(gfx::Point(10, 0));
89 test_ev1.set_time_stamp(start);
90 test_ev2.set_time_stamp(soon);
91 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2));
92
93 // Too long a time between clicks.
94 test_ev1.set_location(gfx::Point(0, 0));
95 test_ev2.set_location(gfx::Point(0, 0));
96 test_ev1.set_time_stamp(start);
97 test_ev2.set_time_stamp(later);
98 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2));
99 }
100
101 // Tests that an event only increases the click count and gets marked as a
102 // double click if a release event was seen for the previous click. This
103 // prevents the same PRESSED event from being processed twice:
104 // http://crbug.com/389162
TEST(EventTest,DoubleClickRequiresRelease)105 TEST(EventTest, DoubleClickRequiresRelease) {
106 const gfx::Point origin1(0, 0);
107 const gfx::Point origin2(100, 0);
108 scoped_ptr<MouseEvent> ev;
109 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0);
110
111 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0));
112 ev->set_time_stamp(start);
113 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
114 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, 0, 0));
115 ev->set_time_stamp(start);
116 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
117
118 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0));
119 ev->set_time_stamp(start);
120 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
121 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, 0, 0));
122 ev->set_time_stamp(start);
123 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
124 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin2, origin2, 0, 0));
125 ev->set_time_stamp(start);
126 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev));
127 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, 0, 0));
128 ev->set_time_stamp(start);
129 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev));
130 MouseEvent::ResetLastClickForTest();
131 }
132
133 // Tests that clicking right and then left clicking does not generate a double
134 // click.
TEST(EventTest,SingleClickRightLeft)135 TEST(EventTest, SingleClickRightLeft) {
136 const gfx::Point origin(0, 0);
137 scoped_ptr<MouseEvent> ev;
138 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0);
139
140 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin,
141 ui::EF_RIGHT_MOUSE_BUTTON,
142 ui::EF_RIGHT_MOUSE_BUTTON));
143 ev->set_time_stamp(start);
144 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
145 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin,
146 ui::EF_LEFT_MOUSE_BUTTON,
147 ui::EF_LEFT_MOUSE_BUTTON));
148 ev->set_time_stamp(start);
149 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
150 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin, origin,
151 ui::EF_LEFT_MOUSE_BUTTON,
152 ui::EF_LEFT_MOUSE_BUTTON));
153 ev->set_time_stamp(start);
154 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev));
155 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin,
156 ui::EF_LEFT_MOUSE_BUTTON,
157 ui::EF_LEFT_MOUSE_BUTTON));
158 ev->set_time_stamp(start);
159 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev));
160 MouseEvent::ResetLastClickForTest();
161 }
162
TEST(EventTest,KeyEvent)163 TEST(EventTest, KeyEvent) {
164 static const struct {
165 KeyboardCode key_code;
166 int flags;
167 uint16 character;
168 } kTestData[] = {
169 { VKEY_A, 0, 'a' },
170 { VKEY_A, EF_SHIFT_DOWN, 'A' },
171 { VKEY_A, EF_CAPS_LOCK_DOWN, 'A' },
172 { VKEY_A, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, 'a' },
173 { VKEY_A, EF_CONTROL_DOWN, 0x01 },
174 { VKEY_A, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\x01' },
175 { VKEY_Z, 0, 'z' },
176 { VKEY_Z, EF_SHIFT_DOWN, 'Z' },
177 { VKEY_Z, EF_CAPS_LOCK_DOWN, 'Z' },
178 { VKEY_Z, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, 'z' },
179 { VKEY_Z, EF_CONTROL_DOWN, '\x1A' },
180 { VKEY_Z, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\x1A' },
181
182 { VKEY_2, EF_CONTROL_DOWN, '\0' },
183 { VKEY_2, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
184 { VKEY_6, EF_CONTROL_DOWN, '\0' },
185 { VKEY_6, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\x1E' },
186 { VKEY_OEM_MINUS, EF_CONTROL_DOWN, '\0' },
187 { VKEY_OEM_MINUS, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\x1F' },
188 { VKEY_OEM_4, EF_CONTROL_DOWN, '\x1B' },
189 { VKEY_OEM_4, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
190 { VKEY_OEM_5, EF_CONTROL_DOWN, '\x1C' },
191 { VKEY_OEM_5, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
192 { VKEY_OEM_6, EF_CONTROL_DOWN, '\x1D' },
193 { VKEY_OEM_6, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
194 { VKEY_RETURN, EF_CONTROL_DOWN, '\x0A' },
195
196 { VKEY_0, 0, '0' },
197 { VKEY_0, EF_SHIFT_DOWN, ')' },
198 { VKEY_0, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, ')' },
199 { VKEY_0, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
200
201 { VKEY_9, 0, '9' },
202 { VKEY_9, EF_SHIFT_DOWN, '(' },
203 { VKEY_9, EF_SHIFT_DOWN | EF_CAPS_LOCK_DOWN, '(' },
204 { VKEY_9, EF_SHIFT_DOWN | EF_CONTROL_DOWN, '\0' },
205
206 { VKEY_NUMPAD0, EF_CONTROL_DOWN, '\0' },
207 { VKEY_NUMPAD0, EF_SHIFT_DOWN, '0' },
208
209 { VKEY_NUMPAD9, EF_CONTROL_DOWN, '\0' },
210 { VKEY_NUMPAD9, EF_SHIFT_DOWN, '9' },
211
212 { VKEY_TAB, EF_CONTROL_DOWN, '\0' },
213 { VKEY_TAB, EF_SHIFT_DOWN, '\t' },
214
215 { VKEY_MULTIPLY, EF_CONTROL_DOWN, '\0' },
216 { VKEY_MULTIPLY, EF_SHIFT_DOWN, '*' },
217 { VKEY_ADD, EF_CONTROL_DOWN, '\0' },
218 { VKEY_ADD, EF_SHIFT_DOWN, '+' },
219 { VKEY_SUBTRACT, EF_CONTROL_DOWN, '\0' },
220 { VKEY_SUBTRACT, EF_SHIFT_DOWN, '-' },
221 { VKEY_DECIMAL, EF_CONTROL_DOWN, '\0' },
222 { VKEY_DECIMAL, EF_SHIFT_DOWN, '.' },
223 { VKEY_DIVIDE, EF_CONTROL_DOWN, '\0' },
224 { VKEY_DIVIDE, EF_SHIFT_DOWN, '/' },
225
226 { VKEY_OEM_1, EF_CONTROL_DOWN, '\0' },
227 { VKEY_OEM_1, EF_SHIFT_DOWN, ':' },
228 { VKEY_OEM_PLUS, EF_CONTROL_DOWN, '\0' },
229 { VKEY_OEM_PLUS, EF_SHIFT_DOWN, '+' },
230 { VKEY_OEM_COMMA, EF_CONTROL_DOWN, '\0' },
231 { VKEY_OEM_COMMA, EF_SHIFT_DOWN, '<' },
232 { VKEY_OEM_PERIOD, EF_CONTROL_DOWN, '\0' },
233 { VKEY_OEM_PERIOD, EF_SHIFT_DOWN, '>' },
234 { VKEY_OEM_3, EF_CONTROL_DOWN, '\0' },
235 { VKEY_OEM_3, EF_SHIFT_DOWN, '~' },
236 };
237
238 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestData); ++i) {
239 KeyEvent key(ET_KEY_PRESSED,
240 kTestData[i].key_code,
241 kTestData[i].flags,
242 false);
243 EXPECT_EQ(kTestData[i].character, key.GetCharacter())
244 << " Index:" << i << " key_code:" << kTestData[i].key_code;
245 }
246 }
247
TEST(EventTest,KeyEventDirectUnicode)248 TEST(EventTest, KeyEventDirectUnicode) {
249 KeyEvent key(ET_KEY_PRESSED, VKEY_UNKNOWN, EF_SHIFT_DOWN, false);
250 key.set_character(0x1234U);
251 EXPECT_EQ(0x1234U, key.GetCharacter());
252 KeyEvent key2(ET_KEY_RELEASED, VKEY_UNKNOWN, EF_CONTROL_DOWN, false);
253 key2.set_character(0x4321U);
254 EXPECT_EQ(0x4321U, key2.GetCharacter());
255 }
256
TEST(EventTest,NormalizeKeyEventFlags)257 TEST(EventTest, NormalizeKeyEventFlags) {
258 #if defined(USE_X11)
259 // Normalize flags when KeyEvent is created from XEvent.
260 ScopedXI2Event event;
261 {
262 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_SHIFT, EF_SHIFT_DOWN);
263 KeyEvent keyev(event, false);
264 EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
265 }
266 {
267 event.InitKeyEvent(ET_KEY_RELEASED, VKEY_SHIFT, EF_SHIFT_DOWN);
268 KeyEvent keyev(event, false);
269 EXPECT_EQ(EF_NONE, keyev.flags());
270 }
271 {
272 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_CONTROL, EF_CONTROL_DOWN);
273 KeyEvent keyev(event, false);
274 EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
275 }
276 {
277 event.InitKeyEvent(ET_KEY_RELEASED, VKEY_CONTROL, EF_CONTROL_DOWN);
278 KeyEvent keyev(event, false);
279 EXPECT_EQ(EF_NONE, keyev.flags());
280 }
281 {
282 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_MENU, EF_ALT_DOWN);
283 KeyEvent keyev(event, false);
284 EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
285 }
286 {
287 event.InitKeyEvent(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN);
288 KeyEvent keyev(event, false);
289 EXPECT_EQ(EF_NONE, keyev.flags());
290 }
291 #endif
292
293 // Do not normalize flags for synthesized events without
294 // KeyEvent::NormalizeFlags called explicitly.
295 {
296 KeyEvent keyev(ET_KEY_PRESSED, VKEY_SHIFT, EF_SHIFT_DOWN, false);
297 EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
298 }
299 {
300 KeyEvent keyev(ET_KEY_RELEASED, VKEY_SHIFT, EF_SHIFT_DOWN, false);
301 EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
302 keyev.NormalizeFlags();
303 EXPECT_EQ(EF_NONE, keyev.flags());
304 }
305 {
306 KeyEvent keyev(ET_KEY_PRESSED, VKEY_CONTROL, EF_CONTROL_DOWN, false);
307 EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
308 }
309 {
310 KeyEvent keyev(ET_KEY_RELEASED, VKEY_CONTROL, EF_CONTROL_DOWN, false);
311 EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
312 keyev.NormalizeFlags();
313 EXPECT_EQ(EF_NONE, keyev.flags());
314 }
315 {
316 KeyEvent keyev(ET_KEY_PRESSED, VKEY_MENU, EF_ALT_DOWN, false);
317 EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
318 }
319 {
320 KeyEvent keyev(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN, false);
321 EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
322 keyev.NormalizeFlags();
323 EXPECT_EQ(EF_NONE, keyev.flags());
324 }
325 }
326
TEST(EventTest,KeyEventCopy)327 TEST(EventTest, KeyEventCopy) {
328 KeyEvent key(ET_KEY_PRESSED, VKEY_A, EF_NONE, false);
329 scoped_ptr<KeyEvent> copied_key(new KeyEvent(key));
330 EXPECT_EQ(copied_key->type(), key.type());
331 EXPECT_EQ(copied_key->key_code(), key.key_code());
332 }
333
TEST(EventTest,KeyEventCode)334 TEST(EventTest, KeyEventCode) {
335 KeycodeConverter* conv = KeycodeConverter::GetInstance();
336
337 const char kCodeForSpace[] = "Space";
338 const uint16 kNativeCodeSpace = conv->CodeToNativeKeycode(kCodeForSpace);
339 ASSERT_NE(conv->InvalidNativeKeycode(), kNativeCodeSpace);
340
341 {
342 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kCodeForSpace, EF_NONE, false);
343 EXPECT_EQ(kCodeForSpace, key.code());
344 }
345 {
346 // Regardless the KeyEvent.key_code (VKEY_RETURN), code should be
347 // the specified value.
348 KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kCodeForSpace, EF_NONE, false);
349 EXPECT_EQ(kCodeForSpace, key.code());
350 }
351 {
352 // If the synthetic event is initialized without code, it returns
353 // an empty string.
354 // TODO(komatsu): Fill a fallback value assuming the US keyboard layout.
355 KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE, false);
356 EXPECT_TRUE(key.code().empty());
357 }
358 #if defined(USE_X11)
359 {
360 // KeyEvent converts from the native keycode (XKB) to the code.
361 ScopedXI2Event xevent;
362 xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace);
363 KeyEvent key(xevent, false);
364 EXPECT_EQ(kCodeForSpace, key.code());
365 }
366 #endif // USE_X11
367 #if defined(OS_WIN)
368 {
369 // Test a non extended key.
370 ASSERT_EQ((kNativeCodeSpace & 0xFF), kNativeCodeSpace);
371
372 const LPARAM lParam = GetLParamFromScanCode(kNativeCodeSpace);
373 MSG native_event = { NULL, WM_KEYUP, VKEY_SPACE, lParam };
374 KeyEvent key(native_event, false);
375
376 // KeyEvent converts from the native keycode (scan code) to the code.
377 EXPECT_EQ(kCodeForSpace, key.code());
378 }
379 {
380 const char kCodeForHome[] = "Home";
381 const uint16 kNativeCodeHome = 0xe047;
382
383 // 'Home' is an extended key with 0xe000 bits.
384 ASSERT_NE((kNativeCodeHome & 0xFF), kNativeCodeHome);
385 const LPARAM lParam = GetLParamFromScanCode(kNativeCodeHome);
386
387 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam };
388 KeyEvent key(native_event, false);
389
390 // KeyEvent converts from the native keycode (scan code) to the code.
391 EXPECT_EQ(kCodeForHome, key.code());
392 }
393 #endif // OS_WIN
394 }
395
396 #if defined(USE_X11) || defined(OS_WIN)
TEST(EventTest,AutoRepeat)397 TEST(EventTest, AutoRepeat) {
398 KeycodeConverter* conv = KeycodeConverter::GetInstance();
399
400 const uint16 kNativeCodeA = conv->CodeToNativeKeycode("KeyA");
401 const uint16 kNativeCodeB = conv->CodeToNativeKeycode("KeyB");
402 #if defined(USE_X11)
403 ScopedXI2Event native_event_a_pressed;
404 native_event_a_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_A, kNativeCodeA);
405 ScopedXI2Event native_event_a_released;
406 native_event_a_released.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, kNativeCodeA);
407 ScopedXI2Event native_event_b_pressed;
408 native_event_b_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_B, kNativeCodeB);
409 ScopedXI2Event native_event_a_pressed_nonstandard_state;
410 native_event_a_pressed_nonstandard_state.InitKeyEvent(
411 ET_KEY_PRESSED, VKEY_A, kNativeCodeA);
412 // IBUS-GTK uses the mask (1 << 25) to detect reposted event.
413 static_cast<XEvent*>(native_event_a_pressed_nonstandard_state)->xkey.state |=
414 1 << 25;
415 #elif defined(OS_WIN)
416 const LPARAM lParam_a = GetLParamFromScanCode(kNativeCodeA);
417 const LPARAM lParam_b = GetLParamFromScanCode(kNativeCodeB);
418 MSG native_event_a_pressed = { NULL, WM_KEYDOWN, VKEY_A, lParam_a };
419 MSG native_event_a_released = { NULL, WM_KEYUP, VKEY_A, lParam_a };
420 MSG native_event_b_pressed = { NULL, WM_KEYUP, VKEY_B, lParam_b };
421 #endif
422 KeyEvent key_a1(native_event_a_pressed, false);
423 EXPECT_FALSE(key_a1.IsRepeat());
424 KeyEvent key_a1_released(native_event_a_released, false);
425 EXPECT_FALSE(key_a1_released.IsRepeat());
426
427 KeyEvent key_a2(native_event_a_pressed, false);
428 EXPECT_FALSE(key_a2.IsRepeat());
429 KeyEvent key_a2_repeated(native_event_a_pressed, false);
430 EXPECT_TRUE(key_a2_repeated.IsRepeat());
431 KeyEvent key_a2_released(native_event_a_released, false);
432 EXPECT_FALSE(key_a2_released.IsRepeat());
433
434 KeyEvent key_a3(native_event_a_pressed, false);
435 EXPECT_FALSE(key_a3.IsRepeat());
436 KeyEvent key_b(native_event_b_pressed, false);
437 EXPECT_FALSE(key_b.IsRepeat());
438 KeyEvent key_a3_again(native_event_a_pressed, false);
439 EXPECT_FALSE(key_a3_again.IsRepeat());
440 KeyEvent key_a3_repeated(native_event_a_pressed, false);
441 EXPECT_TRUE(key_a3_repeated.IsRepeat());
442 KeyEvent key_a3_repeated2(native_event_a_pressed, false);
443 EXPECT_TRUE(key_a3_repeated2.IsRepeat());
444 KeyEvent key_a3_released(native_event_a_released, false);
445 EXPECT_FALSE(key_a3_released.IsRepeat());
446
447 #if defined(USE_X11)
448 KeyEvent key_a4_pressed(native_event_a_pressed, false);
449 EXPECT_FALSE(key_a4_pressed.IsRepeat());
450
451 KeyEvent key_a4_pressed_nonstandard_state(
452 native_event_a_pressed_nonstandard_state, false);
453 EXPECT_FALSE(key_a4_pressed_nonstandard_state.IsRepeat());
454 #endif
455 }
456 #endif // USE_X11 || OS_WIN
457
458 } // namespace ui
459