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

Side by Side Diff: ui/events/keycodes/platform_key_map_win_unittest.cc

Issue 2025733002: [DomKey] Use VK->DomKey mapping for non-printable keys (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wez's review Created 4 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/keycodes/platform_key_map_win.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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "ui/events/keycodes/platform_key_map_win.h" 5 #include "ui/events/keycodes/platform_key_map_win.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string16.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
10 #include "ui/events/keycodes/dom/dom_code.h" 11 #include "ui/events/keycodes/dom/dom_code.h"
11 #include "ui/events/keycodes/dom/dom_key.h" 12 #include "ui/events/keycodes/dom/dom_key.h"
12 #include "ui/events/keycodes/dom/keycode_converter.h" 13 #include "ui/events/keycodes/dom/keycode_converter.h"
14 #include "ui/events/keycodes/dom_us_layout_data.h"
13 15
14 namespace ui { 16 namespace ui {
15 17
16 namespace { 18 namespace {
17 19
18 const wchar_t* LAYOUT_US = L"00000409"; 20 const wchar_t* LAYOUT_US = L"00000409";
19 const wchar_t* LAYOUT_FR = L"0000040c"; 21 const wchar_t* LAYOUT_FR = L"0000040c";
20 22
21 struct TestKey { 23 struct TestKey {
22 // Have to use KeyboardCode instead of DomCode because we don't know the 24 // Have to use KeyboardCode instead of DomCode because we don't know the
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_EQ(test_case.key, 242 EXPECT_EQ(test_case.key,
241 DomKeyFromNativeImpl(keymap, dom_code, key_code, EF_CONTROL_DOWN)) 243 DomKeyFromNativeImpl(keymap, dom_code, key_code, EF_CONTROL_DOWN))
242 << key_code; 244 << key_code;
243 EXPECT_EQ(test_case.key, 245 EXPECT_EQ(test_case.key,
244 DomKeyFromNativeImpl(keymap, dom_code, key_code, 246 DomKeyFromNativeImpl(keymap, dom_code, key_code,
245 EF_ALTGR_DOWN | EF_CONTROL_DOWN)) 247 EF_ALTGR_DOWN | EF_CONTROL_DOWN))
246 << key_code; 248 << key_code;
247 } 249 }
248 } 250 }
249 251
252 TEST_F(PlatformKeyMapTest, NonPrintableKey) {
253 HKL layout = ::LoadKeyboardLayout(LAYOUT_US, 0);
254 PlatformKeyMap keymap(layout);
255
256 for (const auto& test_case : kNonPrintableCodeMap) {
257 // Not available on |LAYOUT_US|.
258 if (test_case.dom_code == DomCode::PAUSE ||
259 test_case.dom_code == DomCode::LANG2 ||
260 test_case.dom_code == DomCode::NON_CONVERT)
261 continue;
262
263 int scan_code =
264 ui::KeycodeConverter::DomCodeToNativeKeycode(test_case.dom_code);
265 KeyboardCode key_code = static_cast<KeyboardCode>(
266 ::MapVirtualKeyEx(scan_code, MAPVK_VSC_TO_VK, layout));
267
268 if (!key_code)
Wez 2016/06/03 00:00:52 nit: I'd explicitly test against VKEY_UNKNOWN here
269 continue;
270
271 EXPECT_EQ(test_case.dom_key,
272 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_NONE))
273 << key_code << ", " << scan_code;
274 EXPECT_EQ(test_case.dom_key, DomKeyFromNativeImpl(keymap, DomCode::NONE,
275 key_code, EF_ALTGR_DOWN))
276 << key_code << ", " << scan_code;
277 EXPECT_EQ(
278 test_case.dom_key,
279 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code, EF_CONTROL_DOWN))
280 << key_code << ", " << scan_code;
281 EXPECT_EQ(test_case.dom_key,
282 DomKeyFromNativeImpl(keymap, DomCode::NONE, key_code,
283 EF_ALTGR_DOWN | EF_CONTROL_DOWN))
284 << key_code << ", " << scan_code;
285 }
286 }
287
250 } // namespace ui 288 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698