diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 21:28:11 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 21:28:11 +0000 |
commit | 97d0b9e24a70d04d51242f8c7b3a587a5ba6444f (patch) | |
tree | bd4c4c91e0241cea85b2b6850d42324d3d246eb3 | |
parent | 3e1cde62becabdb60f92914b7baaa3f1db71b1e0 (diff) | |
download | chromium_src-97d0b9e24a70d04d51242f8c7b3a587a5ba6444f.zip chromium_src-97d0b9e24a70d04d51242f8c7b3a587a5ba6444f.tar.gz chromium_src-97d0b9e24a70d04d51242f8c7b3a587a5ba6444f.tar.bz2 |
Use content instead of WebKit for synthesizing keycodes
Also removes unused automation provider code related to key synthesis.
BUG=237267
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/20581002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213987 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 33 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 2 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 32 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.h | 12 | ||||
-rw-r--r-- | chrome/common/automation_messages_internal.h | 8 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 4 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 3 | ||||
-rw-r--r-- | chrome/test/reliability/automated_ui_tests.cc | 54 | ||||
-rw-r--r-- | chrome/test/reliability/automated_ui_tests.h | 35 | ||||
-rw-r--r-- | chrome/test/reliability/page_load_test.cc | 25 | ||||
-rw-r--r-- | content/browser/renderer_host/input/web_input_event_builders_win.cc | 8 |
11 files changed, 8 insertions, 208 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 0793da1..c6cf17f 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -419,7 +419,6 @@ bool AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) - IPC_MESSAGE_HANDLER(AutomationMsg_KeyPress, KeyPress) IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) @@ -668,38 +667,6 @@ void AutomationProvider::Paste(int tab_handle) { view->Paste(); } - - -void AutomationProvider::KeyPress(int tab_handle, int key) { - RenderViewHost* view = GetViewForTab(tab_handle); - if (!view) { - NOTREACHED(); - return; - } - - content::NativeWebKeyboardEvent event; - event.nativeKeyCode = 0; - event.windowsKeyCode = key; - event.setKeyIdentifierFromWindowsKeyCode(); - event.modifiers = 0; - event.isSystemKey = false; - event.timeStampSeconds = base::Time::Now().ToDoubleT(); - event.skip_in_browser = true; - - event.text[0] = key; - event.unmodifiedText[0] = key; - event.type = WebKit::WebInputEvent::RawKeyDown; - view->ForwardKeyboardEvent(event); - - event.type = WebKit::WebInputEvent::Char; - view->ForwardKeyboardEvent(event); - - event.type = WebKit::WebInputEvent::KeyUp; - event.text[0] = 0; - event.unmodifiedText[0] = 0; - view->ForwardKeyboardEvent(event); -} - void AutomationProvider::ReloadAsync(int tab_handle) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* tab = tab_tracker_->GetResource(tab_handle); diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index ac7ad28..93d6ede 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -276,8 +276,6 @@ class AutomationProvider void Copy(int tab_handle); void Paste(int tab_handle); - void KeyPress(int tab_handle, int key); - void ReloadAsync(int tab_handle); void StopAsync(int tab_handle); void SaveAsAsync(int tab_handle); diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 55b25f9..3dc3d20 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -4158,7 +4158,8 @@ bool TestingAutomationProvider::BuildWebKeyEventFromArgs( key_identifier.c_str(), WebKit::WebKeyboardEvent::keyIdentifierLengthCap); } else { - event->setKeyIdentifierFromWindowsKeyCode(); + *error = "'keyIdentifier' missing or invalid."; + return false; } if (type == automation::kRawKeyDownType) { @@ -4199,35 +4200,6 @@ bool TestingAutomationProvider::BuildWebKeyEventFromArgs( return true; } -void TestingAutomationProvider::BuildSimpleWebKeyEvent( - WebKit::WebInputEvent::Type type, - int windows_key_code, - NativeWebKeyboardEvent* event) { - event->nativeKeyCode = 0; - event->windowsKeyCode = windows_key_code; - event->setKeyIdentifierFromWindowsKeyCode(); - event->type = type; - event->modifiers = 0; - event->isSystemKey = false; - event->timeStampSeconds = base::Time::Now().ToDoubleT(); - event->skip_in_browser = true; -} - -void TestingAutomationProvider::SendWebKeyPressEventAsync( - int key_code, - WebContents* web_contents) { - // Create and send a "key down" event for the specified key code. - NativeWebKeyboardEvent event_down; - BuildSimpleWebKeyEvent(WebKit::WebInputEvent::RawKeyDown, key_code, - &event_down); - web_contents->GetRenderViewHost()->ForwardKeyboardEvent(event_down); - - // Create and send a corresponding "key up" event. - NativeWebKeyboardEvent event_up; - BuildSimpleWebKeyEvent(WebKit::WebInputEvent::KeyUp, key_code, &event_up); - web_contents->GetRenderViewHost()->ForwardKeyboardEvent(event_up); -} - void TestingAutomationProvider::SendWebkitKeyEvent( DictionaryValue* args, IPC::Message* reply_message) { diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index 7aad785..a095c56 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -579,18 +579,6 @@ class TestingAutomationProvider : public AutomationProvider, std::string* error, content::NativeWebKeyboardEvent* event); - // Populates the fields of the event parameter with default data, except for - // the specified key type and key code. - void BuildSimpleWebKeyEvent(WebKit::WebInputEvent::Type type, - int windows_key_code, - content::NativeWebKeyboardEvent* event); - - // Sends a key press event using the given key code to the specified tab. - // A key press is a combination of a "key down" event and a "key up" event. - // This function does not wait before returning. - void SendWebKeyPressEventAsync(int key_code, - content::WebContents* web_contents); - // Launches the specified app from the currently-selected tab. void LaunchApp(Browser* browser, base::DictionaryValue* args, diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index f8da54e..79ee7857 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -957,11 +957,3 @@ IPC_SYNC_MESSAGE_CONTROL2_2(AutomationMsg_SendJSONRequest, std::string /* JSON request */, std::string /* JSON response */, bool /* success */) - -// This message requests that a key press be performed. -// Request: -// int - tab handle -// int - the ui::KeyboardCode of the key that was pressed. -IPC_MESSAGE_CONTROL2(AutomationMsg_KeyPress, - int /* tab_handle */, - int /* key */) diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 29bf9a6..fa1fb6e 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -411,10 +411,6 @@ void TabProxy::Paste() { sender_->Send(new AutomationMsg_Paste(handle_)); } -void TabProxy::SimulateKeyPress(ui::KeyboardCode key) { - sender_->Send(new AutomationMsg_KeyPress(handle_, key)); -} - void TabProxy::ReloadAsync() { sender_->Send(new AutomationMsg_ReloadAsync(handle_)); } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index dff1344..ed8b12d 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -224,9 +224,6 @@ class TabProxy : public AutomationResourceProxy { void Copy(); void Paste(); - // Simulates a key press. |key| is the virtual key code of the key pressed. - void SimulateKeyPress(ui::KeyboardCode key); - // These handlers issue asynchronous Reload, Stop and SaveAs notifications to // the chrome instance. void ReloadAsync(); diff --git a/chrome/test/reliability/automated_ui_tests.cc b/chrome/test/reliability/automated_ui_tests.cc index 0c36fff..2f43c29 100644 --- a/chrome/test/reliability/automated_ui_tests.cc +++ b/chrome/test/reliability/automated_ui_tests.cc @@ -388,8 +388,6 @@ bool AutomatedUITest::DoAction(const std::string& action) { did_complete_action = ForceCrash(); } else if (LowerCaseEqualsASCII(action, "dialog")) { did_complete_action = ExerciseDialog(); - } else if (LowerCaseEqualsASCII(action, "downarrow")) { - did_complete_action = PressDownArrow(); } else if (LowerCaseEqualsASCII(action, "downloads")) { did_complete_action = ShowDownloads(); } else if (LowerCaseEqualsASCII(action, "duplicatetab")) { @@ -423,18 +421,6 @@ bool AutomatedUITest::DoAction(const std::string& action) { did_complete_action = OpenAndActivateNewBrowserWindow(NULL); } else if (LowerCaseEqualsASCII(action, "options")) { did_complete_action = Options(); - } else if (LowerCaseEqualsASCII(action, "pagedown")) { - did_complete_action = PressPageDown(); - } else if (LowerCaseEqualsASCII(action, "pageup")) { - did_complete_action = PressPageUp(); - } else if (LowerCaseEqualsASCII(action, "pressenterkey")) { - did_complete_action = PressEnterKey(); - } else if (LowerCaseEqualsASCII(action, "pressescapekey")) { - did_complete_action = PressEscapeKey(); - } else if (LowerCaseEqualsASCII(action, "pressspacebar")) { - did_complete_action = PressSpaceBar(); - } else if (LowerCaseEqualsASCII(action, "presstabkey")) { - did_complete_action = PressTabKey(); } else if (LowerCaseEqualsASCII(action, "reload")) { did_complete_action = ReloadPage(); } else if (LowerCaseEqualsASCII(action, "restoretab")) { @@ -472,8 +458,6 @@ bool AutomatedUITest::DoAction(const std::string& action) { did_complete_action = TestTaskManager(); } else if (LowerCaseEqualsASCII(action, "testviewpasswords")) { did_complete_action = TestViewPasswords(); - } else if (LowerCaseEqualsASCII(action, "uparrow")) { - did_complete_action = PressUpArrow(); } else if (LowerCaseEqualsASCII(action, "viewpasswords")) { did_complete_action = OpenViewPasswordsDialog(); } else if (LowerCaseEqualsASCII(action, "viewsource")) { @@ -553,38 +537,6 @@ bool AutomatedUITest::Options() { return RunCommandAsync(IDC_OPTIONS); } -bool AutomatedUITest::PressDownArrow() { - return SimulateKeyPress(ui::VKEY_DOWN); -} - -bool AutomatedUITest::PressEnterKey() { - return SimulateKeyPress(ui::VKEY_RETURN); -} - -bool AutomatedUITest::PressEscapeKey() { - return SimulateKeyPress(ui::VKEY_ESCAPE); -} - -bool AutomatedUITest::PressPageDown() { - return SimulateKeyPress(ui::VKEY_PRIOR); -} - -bool AutomatedUITest::PressPageUp() { - return SimulateKeyPress(ui::VKEY_NEXT); -} - -bool AutomatedUITest::PressSpaceBar() { - return SimulateKeyPress(ui::VKEY_SPACE); -} - -bool AutomatedUITest::PressTabKey() { - return SimulateKeyPress(ui::VKEY_TAB); -} - -bool AutomatedUITest::PressUpArrow() { - return SimulateKeyPress(ui::VKEY_UP); -} - bool AutomatedUITest::StarPage() { return RunCommandAsync(IDC_BOOKMARK_PAGE); } @@ -672,12 +624,6 @@ bool AutomatedUITest::ForceCrash() { return true; } -bool AutomatedUITest::SimulateKeyPress(ui::KeyboardCode key) { - scoped_refptr<TabProxy> tab(GetActiveTab()); - tab->SimulateKeyPress(key); - return true; -} - bool AutomatedUITest::InitXMLReader() { base::FilePath input_path = GetInputFilePath(); diff --git a/chrome/test/reliability/automated_ui_tests.h b/chrome/test/reliability/automated_ui_tests.h index 083001b..06cd21f 100644 --- a/chrome/test/reliability/automated_ui_tests.h +++ b/chrome/test/reliability/automated_ui_tests.h @@ -187,38 +187,6 @@ class AutomatedUITest : public AutomatedUITestBase { // XML element: <Options/> bool Options(); - // Simulates a page up key press on the active window. - // XML element: <DownArrow/> - bool PressDownArrow(); - - // Simulates an enter key press on the active window. - // XML element: <PressEnterKey/> - bool PressEnterKey(); - - // Simulates an escape key press on the active window. - // XML element: <PressEscapeKey/> - bool PressEscapeKey(); - - // Simulates a page down key press on the active window. - // XML element: <PageDown/> - bool PressPageDown(); - - // Simulates a page up key press on the active window. - // XML element: <PageUp/> - bool PressPageUp(); - - // Simulates a space bar press on the active window. - // XML element: <PressSpaceBar/> - bool PressSpaceBar(); - - // Simulates a tab key press on the active window. - // XML element: <PressTabKey/> - bool PressTabKey(); - - // Simulates a page up key press on the active window. - // XML element: <UpArrow/> - bool PressUpArrow(); - // Stars the current page. This opens a dialog that may or may not be // dismissed. // XML element: <Star/> @@ -292,9 +260,6 @@ class AutomatedUITest : public AutomatedUITestBase { // Utility functions -------------------------------------------------------- - // Calls SimulateKeyPress on the active tab. |key| is the key pressed. - bool SimulateKeyPress(ui::KeyboardCode key); - // Opens init file, reads it into the reader, and closes the file. // Returns false if there are any errors. bool InitXMLReader(); diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index 9f32162..0e25017 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -28,7 +28,6 @@ // --memoryusage: prints out memory usage when visiting each page. // --endurl=url: visits the specified url in the end. // --logfile=filepath: saves the visit log to the specified path. -// --nopagedown: won't simulate page down key presses after page load. // --noclearprofile: do not clear profile dir before firing up each time. // --savedebuglog: save Chrome, V8, and test debug log for each page loaded. // --searchdumpsbypid: Look for crash dumps by browser process id. @@ -72,7 +71,6 @@ #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" #include "net/base/net_util.h" -#include "ui/base/keycodes/keyboard_codes.h" #include "v8/include/v8-testing.h" namespace { @@ -117,7 +115,6 @@ int32 g_iterations = 1; bool g_memory_usage = false; bool g_continuous_load = false; bool g_browser_existing = false; -bool g_page_down = true; bool g_clear_profile = true; std::string g_end_url; base::FilePath g_log_file_path; @@ -203,9 +200,6 @@ void SetPageRange(const CommandLine& parsed_command_line) { if (parsed_command_line.HasSwitch(kLogFileSwitch)) g_log_file_path = parsed_command_line.GetSwitchValuePath(kLogFileSwitch); - if (parsed_command_line.HasSwitch(kNoPageDownSwitch)) - g_page_down = false; - if (parsed_command_line.HasSwitch(kNoClearProfileSwitch)) g_clear_profile = false; @@ -335,19 +329,6 @@ class PageLoadTest : public UITest { scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); if (tab_proxy.get()) result = tab_proxy->NavigateToURL(url); - - if (result == AUTOMATION_MSG_NAVIGATION_SUCCESS) { - if (g_page_down) { - // Page down twice. - // Sleep for 2 seconds between commands. - // This used to be settable but the flag went away. - base::TimeDelta sleep_time = base::TimeDelta::FromSeconds(2); - tab_proxy->SimulateKeyPress(ui::VKEY_NEXT); - base::PlatformThread::Sleep(sleep_time); - tab_proxy->SimulateKeyPress(ui::VKEY_NEXT); - base::PlatformThread::Sleep(sleep_time); - } - } } // Log navigate complete time. @@ -470,12 +451,6 @@ class PageLoadTest : public UITest { return; // For usage 1 NavigationMetrics metrics; - // Though it would be nice to test the page down code path in usage 1, - // enabling page down adds several seconds to the test and does not seem - // worth the tradeoff. It is also potentially disruptive when running the - // test in the background as it will send the event to the window that - // has focus. - g_page_down = false; base::FilePath sample_data_dir = GetSampleDataDir(); base::FilePath test_page_1 = sample_data_dir.AppendASCII(kTestPage1); diff --git a/content/browser/renderer_host/input/web_input_event_builders_win.cc b/content/browser/renderer_host/input/web_input_event_builders_win.cc index 6e693a7..a5a9b20 100644 --- a/content/browser/renderer_host/input/web_input_event_builders_win.cc +++ b/content/browser/renderer_host/input/web_input_event_builders_win.cc @@ -5,6 +5,7 @@ #include "content/browser/renderer_host/input/web_input_event_builders_win.h" #include "base/logging.h" +#include "content/browser/renderer_host/input/web_input_event_util.h" using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -144,8 +145,11 @@ WebKeyboardEvent WebKeyboardEventBuilder::Build(HWND hwnd, UINT message, result.text[0] = result.windowsKeyCode; result.unmodifiedText[0] = result.windowsKeyCode; } - if (result.type != WebInputEvent::Char) - result.setKeyIdentifierFromWindowsKeyCode(); + if (result.type != WebInputEvent::Char) { + UpdateWindowsKeyCodeAndKeyIdentifier( + &result, + static_cast<ui::KeyboardCode>(result.windowsKeyCode)); + } if (::GetKeyState(VK_SHIFT) & 0x8000) result.modifiers |= WebInputEvent::ShiftKey; |