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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 1124963003: Remove ui::KeycodeConverter::CodeToNativeKeycode(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@x444048-3a-codes
Patch Set: rebase Created 5 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 | « content/content_renderer.gypi ('k') | content/renderer/pepper/event_conversion.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index 4132af4603f93f27daa2883094914913165ea280..9513d0e59422074bd8af4c5ba4ef47cfbde82613 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -43,6 +43,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
+#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/resources/grit/webui_resources.h"
@@ -445,7 +446,8 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
bool shift,
bool alt,
bool command) {
- int native_key_code = ui::KeycodeConverter::CodeToNativeKeycode(code);
+ int native_key_code = ui::KeycodeConverter::DomCodeToNativeKeycode(
+ ui::KeycodeConverter::CodeStringToDomCode(code));
int modifiers = 0;
@@ -453,96 +455,75 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
// For our simulation we can use either the left keys or the right keys.
if (control) {
modifiers |= blink::WebInputEvent::ControlKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_CONTROL,
- ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_CONTROL,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::CONTROL_LEFT),
+ modifiers);
}
if (shift) {
modifiers |= blink::WebInputEvent::ShiftKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_SHIFT,
- ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_SHIFT,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::SHIFT_LEFT),
+ modifiers);
}
if (alt) {
modifiers |= blink::WebInputEvent::AltKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_MENU,
- ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_MENU,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::ALT_LEFT),
+ modifiers);
}
if (command) {
modifiers |= blink::WebInputEvent::MetaKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::RawKeyDown,
- ui::VKEY_COMMAND,
- ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::RawKeyDown, ui::VKEY_COMMAND,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::OS_LEFT),
+ modifiers);
}
+ InjectRawKeyEvent(web_contents, blink::WebInputEvent::RawKeyDown, key_code,
+ native_key_code, modifiers);
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::RawKeyDown,
- key_code,
- native_key_code,
- modifiers);
-
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::Char,
- key_code,
- native_key_code,
- modifiers);
-
- InjectRawKeyEvent(
- web_contents,
- blink::WebInputEvent::KeyUp,
- key_code,
- native_key_code,
- modifiers);
+ InjectRawKeyEvent(web_contents, blink::WebInputEvent::Char, key_code,
+ native_key_code, modifiers);
+
+ InjectRawKeyEvent(web_contents, blink::WebInputEvent::KeyUp, key_code,
+ native_key_code, modifiers);
// The order of these key releases shouldn't matter for our simulation.
if (control) {
modifiers &= ~blink::WebInputEvent::ControlKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_CONTROL,
- ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_CONTROL,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::CONTROL_LEFT),
+ modifiers);
}
if (shift) {
modifiers &= ~blink::WebInputEvent::ShiftKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_SHIFT,
- ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_SHIFT,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::SHIFT_LEFT),
+ modifiers);
}
if (alt) {
modifiers &= ~blink::WebInputEvent::AltKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_MENU,
- ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_MENU,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::ALT_LEFT),
+ modifiers);
}
if (command) {
modifiers &= ~blink::WebInputEvent::MetaKey;
- InjectRawKeyEvent(web_contents,
- blink::WebInputEvent::KeyUp,
- ui::VKEY_COMMAND,
- ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
- modifiers);
+ InjectRawKeyEvent(
+ web_contents, blink::WebInputEvent::KeyUp, ui::VKEY_COMMAND,
+ ui::KeycodeConverter::DomCodeToNativeKeycode(ui::DomCode::OS_LEFT),
+ modifiers);
}
ASSERT_EQ(modifiers, 0);
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/pepper/event_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698