diff options
author | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-11 01:02:10 +0000 |
---|---|---|
committer | weitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-11 01:02:10 +0000 |
commit | 6dc5a3358d77de58daf276ad72c63c9fea5ff7e8 (patch) | |
tree | f5453ebce1803d6c763b622a2578322d1c1c1d33 /remoting | |
parent | f0d06048947fa2ee0e088e13f085f01359a10416 (diff) | |
download | chromium_src-6dc5a3358d77de58daf276ad72c63c9fea5ff7e8.zip chromium_src-6dc5a3358d77de58daf276ad72c63c9fea5ff7e8.tar.gz chromium_src-6dc5a3358d77de58daf276ad72c63c9fea5ff7e8.tar.bz2 |
Add a CodeToNativeKeycode helper that converts UIEvent code to native code.
Also add a SimulateKeyPress helper for browser_tests that takes both a UIEvent |code| and a ui::KeyboardCode.
BUG=284754
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=222168
Review URL: https://chromiumcodereview.appspot.com/23542008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/test/remote_desktop_browsertest.cc | 104 | ||||
-rw-r--r-- | remoting/test/remote_desktop_browsertest.h | 16 |
2 files changed, 18 insertions, 102 deletions
diff --git a/remoting/test/remote_desktop_browsertest.cc b/remoting/test/remote_desktop_browsertest.cc index 94f2489..d389788 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::SimulateKeyPressWithCode( + ui::KeyboardCode keyCode, + const char* code) { + SimulateKeyPressWithCode(keyCode, code, false, false, false, false); } -void RemoteDesktopBrowserTest::SimulateKeyPress( - ui::KeyboardCode key, - int nativeKeyCode, +void RemoteDesktopBrowserTest::SimulateKeyPressWithCode( + 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, diff --git a/remoting/test/remote_desktop_browsertest.h b/remoting/test/remote_desktop_browsertest.h index ab8cf86..a9922b8 100644 --- a/remoting/test/remote_desktop_browsertest.h +++ b/remoting/test/remote_desktop_browsertest.h @@ -82,14 +82,14 @@ class RemoteDesktopBrowserTest : public ExtensionBrowserTest { void StartMe2Me(); // Simulate a key event. - void SimulateKeyPress(ui::KeyboardCode key, int nativeKeyCode); - - void SimulateKeyPress(ui::KeyboardCode key, - int nativeKeyCode, - bool control, - bool shift, - bool alt, - bool command); + void SimulateKeyPressWithCode(ui::KeyboardCode keyCode, const char* code); + + void SimulateKeyPressWithCode(ui::KeyboardCode keyCode, + const char* code, + bool control, + bool shift, + bool alt, + bool command); /* */ |