| Index: content/renderer/render_view_browsertest.cc
|
| diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
|
| index 3a49f7021753c40ee50f159a0c4d186e1e270930..ab3c8f99e25d4f0a6fdc4861bc79f1c1996010be 100644
|
| --- a/content/renderer/render_view_browsertest.cc
|
| +++ b/content/renderer/render_view_browsertest.cc
|
| @@ -1475,153 +1475,6 @@ TEST_F(RenderViewImplTest, OnSetTextDirection) {
|
| }
|
| }
|
|
|
| -// Test that we can receive correct DOM events when we send input events
|
| -// through the RenderWidget::OnHandleInputEvent() function.
|
| -TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) {
|
| -#if !defined(OS_MACOSX)
|
| - // Load an HTML page consisting of one <input> element and three
|
| - // contentediable <div> elements.
|
| - // The <input> element is used for sending keyboard events, and the <div>
|
| - // elements are used for writing DOM events in the following format:
|
| - // "<keyCode>,<shiftKey>,<controlKey>,<altKey>".
|
| - // TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to
|
| - // true when pressing an alt key, i.e. the |ev.metaKey| value is not
|
| - // trustworthy. We will check the |ev.metaKey| value when this issue is fixed.
|
| - view()->set_send_content_state_immediately(true);
|
| - LoadHTML("<html>"
|
| - "<head>"
|
| - "<title></title>"
|
| - "<script type='text/javascript' language='javascript'>"
|
| - "function OnKeyEvent(ev) {"
|
| - " var result = document.getElementById(ev.type);"
|
| - " result.innerText ="
|
| - " (ev.which || ev.keyCode) + ',' +"
|
| - " ev.shiftKey + ',' +"
|
| - " ev.ctrlKey + ',' +"
|
| - " ev.altKey;"
|
| - " return true;"
|
| - "}"
|
| - "</script>"
|
| - "</head>"
|
| - "<body>"
|
| - "<input id='test' type='text'"
|
| - " onkeydown='return OnKeyEvent(event);'"
|
| - " onkeypress='return OnKeyEvent(event);'"
|
| - " onkeyup='return OnKeyEvent(event);'>"
|
| - "</input>"
|
| - "<div id='keydown' contenteditable='true'>"
|
| - "</div>"
|
| - "<div id='keypress' contenteditable='true'>"
|
| - "</div>"
|
| - "<div id='keyup' contenteditable='true'>"
|
| - "</div>"
|
| - "</body>"
|
| - "</html>");
|
| - ExecuteJavaScriptForTests("document.getElementById('test').focus();");
|
| - render_thread_->sink().ClearMessages();
|
| -
|
| - static const MockKeyboard::Layout kLayouts[] = {
|
| -#if defined(OS_WIN)
|
| - // Since we ignore the mock keyboard layout on Linux and instead just use
|
| - // the screen's keyboard layout, these trivially pass. They are commented
|
| - // out to avoid the illusion that they work.
|
| - MockKeyboard::LAYOUT_ARABIC,
|
| - MockKeyboard::LAYOUT_CANADIAN_FRENCH,
|
| - MockKeyboard::LAYOUT_FRENCH,
|
| - MockKeyboard::LAYOUT_HEBREW,
|
| - MockKeyboard::LAYOUT_RUSSIAN,
|
| -#endif
|
| - MockKeyboard::LAYOUT_UNITED_STATES,
|
| - };
|
| -
|
| - for (size_t i = 0; i < arraysize(kLayouts); ++i) {
|
| - // For each key code, we send three keyboard events.
|
| - // * we press only the key;
|
| - // * we press the key and a left-shift key, and;
|
| - // * we press the key and a right-alt (AltGr) key.
|
| - // For each modifiers, we need a string used for formatting its expected
|
| - // result. (See the above comment for its format.)
|
| - static const struct {
|
| - MockKeyboard::Modifiers modifiers;
|
| - const char* expected_result;
|
| - } kModifierData[] = {
|
| - {MockKeyboard::NONE, "false,false,false"},
|
| - {MockKeyboard::LEFT_SHIFT, "true,false,false"},
|
| -#if defined(OS_WIN)
|
| - {MockKeyboard::RIGHT_ALT, "false,false,true"},
|
| -#endif
|
| - };
|
| -
|
| - MockKeyboard::Layout layout = kLayouts[i];
|
| - for (size_t j = 0; j < arraysize(kModifierData); ++j) {
|
| - // Virtual key codes used for this test.
|
| - static const int kKeyCodes[] = {
|
| - '0', '1', '2', '3', '4', '5', '6', '7',
|
| - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
|
| - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
| - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
|
| - 'W', 'X', 'Y', 'Z',
|
| - ui::VKEY_OEM_1,
|
| - ui::VKEY_OEM_PLUS,
|
| - ui::VKEY_OEM_COMMA,
|
| - ui::VKEY_OEM_MINUS,
|
| - ui::VKEY_OEM_PERIOD,
|
| - ui::VKEY_OEM_2,
|
| - ui::VKEY_OEM_3,
|
| - ui::VKEY_OEM_4,
|
| - ui::VKEY_OEM_5,
|
| - ui::VKEY_OEM_6,
|
| - ui::VKEY_OEM_7,
|
| -#if defined(OS_WIN)
|
| - // Not sure how to handle this key on Linux.
|
| - ui::VKEY_OEM_8,
|
| -#endif
|
| - };
|
| -
|
| - MockKeyboard::Modifiers modifiers = kModifierData[j].modifiers;
|
| - for (size_t k = 0; k < arraysize(kKeyCodes); ++k) {
|
| - // Send a keyboard event to the RenderView object.
|
| - // We should test a keyboard event only when the given keyboard-layout
|
| - // driver is installed in a PC and the driver can assign a Unicode
|
| - // charcter for the given tuple (key-code and modifiers).
|
| - int key_code = kKeyCodes[k];
|
| - base::string16 char_code;
|
| - if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0)
|
| - continue;
|
| -
|
| - // Create an expected result from the virtual-key code, the character
|
| - // code, and the modifier-key status.
|
| - // We format a string that emulates a DOM-event string produced hy
|
| - // our JavaScript function. (See the above comment for the format.)
|
| - static char expected_result[1024];
|
| - expected_result[0] = 0;
|
| - base::snprintf(&expected_result[0],
|
| - sizeof(expected_result),
|
| - "\n" // texts in the <input> element
|
| - "%d,%s\n" // texts in the first <div> element
|
| - "%d,%s\n" // texts in the second <div> element
|
| - "%d,%s", // texts in the third <div> element
|
| - key_code, kModifierData[j].expected_result,
|
| - static_cast<int>(char_code[0]),
|
| - kModifierData[j].expected_result,
|
| - key_code, kModifierData[j].expected_result);
|
| -
|
| - // Retrieve the text in the test page and compare it with the expected
|
| - // text created from a virtual-key code, a character code, and the
|
| - // modifier-key status.
|
| - const int kMaxOutputCharacters = 1024;
|
| - std::string output = base::UTF16ToUTF8(
|
| - base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText(
|
| - GetMainFrame(), kMaxOutputCharacters)));
|
| - EXPECT_EQ(expected_result, output);
|
| - }
|
| - }
|
| - }
|
| -#else
|
| - NOTIMPLEMENTED();
|
| -#endif
|
| -}
|
| -
|
| // Test that our EditorClientImpl class can insert characters when we send
|
| // keyboard events through the RenderWidget::OnHandleInputEvent() function.
|
| // This test is for preventing regressions caused only when we use non-US
|
|
|