Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: ui/events/x/events_x_unittest.cc

Issue 286103004: Blocked volume up/down events that originated from remapped function keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set the EF_FUNCTION_KEY flag in EventFlagsFromNative Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/x/events_x.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cstring> 5 #include <cstring>
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 InitKeyEvent(display, &event, true, x_keycode, 0); 363 InitKeyEvent(display, &event, true, x_keycode, 0);
364 // int keysym = XLookupKeysym(&event.xkey, 0); 364 // int keysym = XLookupKeysym(&event.xkey, 0);
365 // if (keysym) { 365 // if (keysym) {
366 ui::KeyEvent ui_key_event(&event, false); 366 ui::KeyEvent ui_key_event(&event, false);
367 EXPECT_EQ(keys[k].is_numpad_key ? ui::EF_NUMPAD_KEY : 0, 367 EXPECT_EQ(keys[k].is_numpad_key ? ui::EF_NUMPAD_KEY : 0,
368 ui_key_event.flags() & ui::EF_NUMPAD_KEY); 368 ui_key_event.flags() & ui::EF_NUMPAD_KEY);
369 } 369 }
370 } 370 }
371 } 371 }
372 372
373 TEST(EventsXTest, FunctionKeyEvents) {
374 XEvent event; Display* display = gfx::GetXDisplay();
oshima 2014/05/30 17:03:19 split to two lines
bruthig 2014/05/30 19:10:03 Done.
375
376 struct {
377 bool is_function_key;
378 int x_keysym;
379 ui::KeyboardCode ui_keycode;
oshima 2014/05/30 17:03:19 is this field used?
bruthig 2014/05/30 19:10:03 Done.
380 } keys[] = {
381 // Min function key code minus 1.
382 { false, XK_F1-1 },
oshima 2014/05/30 17:03:19 space before/after -
bruthig 2014/05/30 19:10:03 Done.
383 // All function keys.
384 { true, XK_F1 },
385 { true, XK_F2 },
386 { true, XK_F3 },
387 { true, XK_F4 },
388 { true, XK_F5 },
389 { true, XK_F6 },
390 { true, XK_F7 },
391 { true, XK_F8 },
392 { true, XK_F9 },
393 { true, XK_F10 },
394 { true, XK_F11 },
395 { true, XK_F12 },
396 { true, XK_F13 },
397 { true, XK_F14 },
398 { true, XK_F15 },
399 { true, XK_F16 },
400 { true, XK_F17 },
401 { true, XK_F18 },
402 { true, XK_F19 },
403 { true, XK_F20 },
404 { true, XK_F21 },
405 { true, XK_F22 },
406 { true, XK_F23 },
407 { true, XK_F24 },
408 { true, XK_F25 },
409 { true, XK_F26 },
410 { true, XK_F27 },
411 { true, XK_F28 },
412 { true, XK_F29 },
413 { true, XK_F30 },
414 { true, XK_F31 },
415 { true, XK_F32 },
416 { true, XK_F33 },
417 { true, XK_F34 },
418 { true, XK_F35 },
419 // Max function key code plus 1.
420 { false, XK_F35+1 }
oshima 2014/05/30 17:03:19 ditto
bruthig 2014/05/30 19:10:03 Done.
421 };
422
423 for (size_t k = 0; k < ARRAYSIZE_UNSAFE(keys); ++k) {
424 int x_keycode = XKeysymToKeycode(display, keys[k].x_keysym);
425 // Exclude keysyms for which the server has no corresponding keycode.
426 if (x_keycode) {
427 InitKeyEvent(display, &event, true, x_keycode, 0);
428 ui::KeyEvent ui_key_event(&event, false);
429 EXPECT_EQ(keys[k].is_function_key ? ui::EF_FUNCTION_KEY : 0,
430 ui_key_event.flags() & ui::EF_FUNCTION_KEY);
431 }
oshima 2014/05/30 17:03:19 isn't it simpler to do something like EXPECT_FALS
bruthig 2014/05/30 19:10:03 This has been re-written but this has uncovered so
432 }
433 }
434
373 } // namespace ui 435 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/events_x.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698