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

Unified Diff: trunk/src/remoting/test/remote_desktop_browsertest.cc

Issue 23451030: Revert 222168 "Add a CodeToNativeKeycode helper that converts UI..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « trunk/src/remoting/test/remote_desktop_browsertest.h ('k') | trunk/src/ui/base/keycodes/usb_keycode_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/remoting/test/remote_desktop_browsertest.cc
===================================================================
--- trunk/src/remoting/test/remote_desktop_browsertest.cc (revision 222198)
+++ trunk/src/remoting/test/remote_desktop_browsertest.cc (working copy)
@@ -17,6 +17,88 @@
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() {}
@@ -200,23 +282,25 @@
EXPECT_FALSE(HtmlElementVisible("me2me-first-run"));
}
-void RemoteDesktopBrowserTest::SimulateKeyPressWithCode(
- ui::KeyboardCode keyCode,
- const char* code) {
- SimulateKeyPressWithCode(keyCode, code, false, false, false, false);
+void RemoteDesktopBrowserTest::SimulateKeyPress(
+ ui::KeyboardCode key,
+ int nativeKeyCode) {
+ SimulateKeyPress(key, nativeKeyCode, false, false, false, false);
}
-void RemoteDesktopBrowserTest::SimulateKeyPressWithCode(
- ui::KeyboardCode keyCode,
- const char* code,
+void RemoteDesktopBrowserTest::SimulateKeyPress(
+ ui::KeyboardCode key,
+ int nativeKeyCode,
bool control,
bool shift,
bool alt,
bool command) {
- content::SimulateKeyPressWithCode(
+ // TODO: Switch to content::SimulateKeyPress when an overload of it is
+ // added to take the UIEvent key |code| string.
+ remoting::SimulateKeyPress(
browser()->tab_strip_model()->GetActiveWebContents(),
- keyCode,
- code,
+ key,
+ nativeKeyCode,
control,
shift,
alt,
« no previous file with comments | « trunk/src/remoting/test/remote_desktop_browsertest.h ('k') | trunk/src/ui/base/keycodes/usb_keycode_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698