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

Unified Diff: ui/base/keycodes/usb_keycode_map_unittest.cc

Issue 23542008: Add a CodeToNativeKeycode helper that converts UIEvent code to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR feedback. Created 7 years, 3 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
Index: ui/base/keycodes/usb_keycode_map_unittest.cc
diff --git a/ui/base/keycodes/usb_keycode_map_unittest.cc b/ui/base/keycodes/usb_keycode_map_unittest.cc
index 5b09715ae98ebecffa5706012789f022386bc59d..14b41786049e6263513931c61b2b1f754a81f165 100644
--- a/ui/base/keycodes/usb_keycode_map_unittest.cc
+++ b/ui/base/keycodes/usb_keycode_map_unittest.cc
@@ -33,6 +33,8 @@ TEST(UsbKeycodeMap, Basic) {
// Verify that the first element in the table is the "invalid" code.
EXPECT_EQ(InvalidUsbKeycode(), usb_keycode_map[0].usb_keycode);
EXPECT_EQ(InvalidNativeKeycode(), usb_keycode_map[0].native_keycode);
+ EXPECT_EQ(InvalidKeyboardEventCode(), "Unidentified");
+ EXPECT_EQ(InvalidNativeKeycode(), CodeToNativeKeycode("Unidentified"));
// Verify that there are no duplicate entries in the mapping.
std::map<uint32_t, uint16_t> usb_to_native;
@@ -46,6 +48,18 @@ TEST(UsbKeycodeMap, Basic) {
EXPECT_EQ(usb_keycode_map[i].native_keycode,
UsbKeycodeToNativeKeycode(usb_keycode_map[i].usb_keycode));
+ // Verify CodeToNativeKeycode and NativeKeycodeToCode work correctly.
+ if (usb_keycode_map[i].code) {
+ EXPECT_EQ(usb_keycode_map[i].native_keycode,
+ CodeToNativeKeycode(usb_keycode_map[i].code));
+ EXPECT_EQ(usb_keycode_map[i].code,
+ NativeKeycodeToCode(usb_keycode_map[i].native_keycode));
+ }
+ else {
+ EXPECT_EQ(InvalidNativeKeycode(),
+ CodeToNativeKeycode(usb_keycode_map[i].code));
+ }
+
// Verify that the USB or native codes aren't duplicated.
EXPECT_EQ(0U, usb_to_native.count(usb_keycode_map[i].usb_keycode))
<< " duplicate of USB code 0x" << std::hex << std::setfill('0')
« content/public/test/browser_test_utils.cc ('K') | « ui/base/keycodes/usb_keycode_map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698