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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/x/events_x.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/events_x_unittest.cc
diff --git a/ui/events/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index 368682cbb1bd5fec0bb896ada960ac5c5ea5aa92..1d64c515fe4e53ed738f9dc71823a0db116e424c 100644
--- a/ui/events/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -370,4 +370,66 @@ TEST(EventsXTest, NumpadKeyEvents) {
}
}
+TEST(EventsXTest, FunctionKeyEvents) {
+ 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.
+
+ struct {
+ bool is_function_key;
+ int x_keysym;
+ ui::KeyboardCode ui_keycode;
oshima 2014/05/30 17:03:19 is this field used?
bruthig 2014/05/30 19:10:03 Done.
+ } keys[] = {
+ // Min function key code minus 1.
+ { false, XK_F1-1 },
oshima 2014/05/30 17:03:19 space before/after -
bruthig 2014/05/30 19:10:03 Done.
+ // All function keys.
+ { true, XK_F1 },
+ { true, XK_F2 },
+ { true, XK_F3 },
+ { true, XK_F4 },
+ { true, XK_F5 },
+ { true, XK_F6 },
+ { true, XK_F7 },
+ { true, XK_F8 },
+ { true, XK_F9 },
+ { true, XK_F10 },
+ { true, XK_F11 },
+ { true, XK_F12 },
+ { true, XK_F13 },
+ { true, XK_F14 },
+ { true, XK_F15 },
+ { true, XK_F16 },
+ { true, XK_F17 },
+ { true, XK_F18 },
+ { true, XK_F19 },
+ { true, XK_F20 },
+ { true, XK_F21 },
+ { true, XK_F22 },
+ { true, XK_F23 },
+ { true, XK_F24 },
+ { true, XK_F25 },
+ { true, XK_F26 },
+ { true, XK_F27 },
+ { true, XK_F28 },
+ { true, XK_F29 },
+ { true, XK_F30 },
+ { true, XK_F31 },
+ { true, XK_F32 },
+ { true, XK_F33 },
+ { true, XK_F34 },
+ { true, XK_F35 },
+ // Max function key code plus 1.
+ { false, XK_F35+1 }
oshima 2014/05/30 17:03:19 ditto
bruthig 2014/05/30 19:10:03 Done.
+ };
+
+ for (size_t k = 0; k < ARRAYSIZE_UNSAFE(keys); ++k) {
+ int x_keycode = XKeysymToKeycode(display, keys[k].x_keysym);
+ // Exclude keysyms for which the server has no corresponding keycode.
+ if (x_keycode) {
+ InitKeyEvent(display, &event, true, x_keycode, 0);
+ ui::KeyEvent ui_key_event(&event, false);
+ EXPECT_EQ(keys[k].is_function_key ? ui::EF_FUNCTION_KEY : 0,
+ ui_key_event.flags() & ui::EF_FUNCTION_KEY);
+ }
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
+ }
+}
+
} // namespace ui
« 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