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

Unified Diff: remoting/test/remote_desktop_browsertest.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: remoting/test/remote_desktop_browsertest.cc
diff --git a/remoting/test/remote_desktop_browsertest.cc b/remoting/test/remote_desktop_browsertest.cc
index 94f248962a2bb362c39d60d9d85fc7dda0b92cc7..c03a72a624021d70ed5562b4c9db6a3795fd978a 100644
--- a/remoting/test/remote_desktop_browsertest.cc
+++ b/remoting/test/remote_desktop_browsertest.cc
@@ -17,88 +17,6 @@ using extensions::Extension;
namespace remoting {
-// BuildSimpleWebKeyEvent and SimulateKeyPress below are adapted from
-// content/public/test/browser_test_utils.cc.
-// TODO: Move this to browser_test_utils.cc after the support is added for
-// the UIEvent key |code|.
-void BuildSimpleWebKeyEvent(WebKit::WebInputEvent::Type type,
- ui::KeyboardCode key,
- int nativeKeyCode,
- bool control,
- bool shift,
- bool alt,
- bool command,
- content::NativeWebKeyboardEvent* event) {
- event->nativeKeyCode = nativeKeyCode;
- event->windowsKeyCode = key;
- event->setKeyIdentifierFromWindowsKeyCode();
- event->type = type;
- event->modifiers = 0;
- event->isSystemKey = false;
- event->timeStampSeconds = base::Time::Now().ToDoubleT();
- event->skip_in_browser = true;
-
- if (type == WebKit::WebInputEvent::Char ||
- type == WebKit::WebInputEvent::RawKeyDown) {
- event->text[0] = key;
- event->unmodifiedText[0] = key;
- }
-
- if (control)
- event->modifiers |= WebKit::WebInputEvent::ControlKey;
-
- if (shift)
- event->modifiers |= WebKit::WebInputEvent::ShiftKey;
-
- if (alt)
- event->modifiers |= WebKit::WebInputEvent::AltKey;
-
- if (command)
- event->modifiers |= WebKit::WebInputEvent::MetaKey;
-}
-
-void SimulateKeyPress(content::WebContents* web_contents,
- ui::KeyboardCode key,
- int nativeKeyCode,
- bool control,
- bool shift,
- bool alt,
- bool command) {
- content::NativeWebKeyboardEvent event_down;
- BuildSimpleWebKeyEvent(
- WebKit::WebInputEvent::RawKeyDown,
- key, nativeKeyCode,
- control,
- shift,
- alt,
- command,
- &event_down);
- web_contents->GetRenderViewHost()->ForwardKeyboardEvent(event_down);
-
- content::NativeWebKeyboardEvent char_event;
- BuildSimpleWebKeyEvent(
- WebKit::WebInputEvent::Char,
- key, nativeKeyCode,
- control,
- shift,
- alt,
- command,
- &char_event);
- web_contents->GetRenderViewHost()->ForwardKeyboardEvent(char_event);
-
- content::NativeWebKeyboardEvent event_up;
- BuildSimpleWebKeyEvent(
- WebKit::WebInputEvent::KeyUp,
- key,
- nativeKeyCode,
- control,
- shift,
- alt,
- command,
- &event_up);
- web_contents->GetRenderViewHost()->ForwardKeyboardEvent(event_up);
-}
-
RemoteDesktopBrowserTest::RemoteDesktopBrowserTest() {}
RemoteDesktopBrowserTest::~RemoteDesktopBrowserTest() {}
@@ -282,25 +200,23 @@ void RemoteDesktopBrowserTest::StartMe2Me() {
EXPECT_FALSE(HtmlElementVisible("me2me-first-run"));
}
-void RemoteDesktopBrowserTest::SimulateKeyPress(
- ui::KeyboardCode key,
- int nativeKeyCode) {
- SimulateKeyPress(key, nativeKeyCode, false, false, false, false);
+void RemoteDesktopBrowserTest::SimulateSimpleKeyPress(
+ ui::KeyboardCode keyCode,
+ const char* code) {
+ SimulateKeyPress(keyCode, code, false, false, false, false);
}
void RemoteDesktopBrowserTest::SimulateKeyPress(
- ui::KeyboardCode key,
- int nativeKeyCode,
+ ui::KeyboardCode keyCode,
+ const char* code,
bool control,
bool shift,
bool alt,
bool command) {
- // TODO: Switch to content::SimulateKeyPress when an overload of it is
- // added to take the UIEvent key |code| string.
- remoting::SimulateKeyPress(
+ content::SimulateKeyPressWithCode(
browser()->tab_strip_model()->GetActiveWebContents(),
- key,
- nativeKeyCode,
+ keyCode,
+ code,
control,
shift,
alt,

Powered by Google App Engine
This is Rietveld 408576698