diff options
author | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 10:57:40 +0000 |
---|---|---|
committer | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-11 10:57:40 +0000 |
commit | b256eca653bf17bcbf08e7a11c37e736fe47a9b4 (patch) | |
tree | ea40bf0711f762488a69066ad9c8d8ce9ceb0ccc /content/renderer/render_view_browsertest.cc | |
parent | f1ef8f759aaa4216a94fdfc9860f183680c7f7f7 (diff) | |
download | chromium_src-b256eca653bf17bcbf08e7a11c37e736fe47a9b4.zip chromium_src-b256eca653bf17bcbf08e7a11c37e736fe47a9b4.tar.gz chromium_src-b256eca653bf17bcbf08e7a11c37e736fe47a9b4.tar.bz2 |
Add new parameter ui::TextInputMode to ViewHostMsg_TextInputTypeChanged IPC message.
Focused input element has new attribute inputmode, which tells browser to switch character type like "latin", "katakana".
at RenderWidget::UpdateTextInputType(),
1. get WebKit::WebTextInputInfo, which has inputmode as WebString.
2. convert it to corresponding enum ui::TextInputMode this cl adds.
3. set it to IPC parameter extended.
BUG=244758
Review URL: https://chromiumcodereview.appspot.com/18682002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/render_view_browsertest.cc')
-rw-r--r-- | content/renderer/render_view_browsertest.cc | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index 44bd173..9093a081 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -776,10 +776,46 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) { "<body>" "<input id=\"test1\" type=\"text\" value=\"some text\"></input>" "<input id=\"test2\" type=\"password\"></input>" + "<input id=\"test3\" type=\"text\" inputmode=\"verbatim\"></input>" + "<input id=\"test4\" type=\"text\" inputmode=\"latin\"></input>" + "<input id=\"test5\" type=\"text\" inputmode=\"latin-name\"></input>" + "<input id=\"test6\" type=\"text\" inputmode=\"latin-prose\">" + "</input>" + "<input id=\"test7\" type=\"text\" inputmode=\"full-width-latin\">" + "</input>" + "<input id=\"test8\" type=\"text\" inputmode=\"kana\"></input>" + "<input id=\"test9\" type=\"text\" inputmode=\"katakana\"></input>" + "<input id=\"test10\" type=\"text\" inputmode=\"numeric\"></input>" + "<input id=\"test11\" type=\"text\" inputmode=\"tel\"></input>" + "<input id=\"test12\" type=\"text\" inputmode=\"email\"></input>" + "<input id=\"test13\" type=\"text\" inputmode=\"url\"></input>" + "<input id=\"test14\" type=\"text\" inputmode=\"unknown\"></input>" + "<input id=\"test15\" type=\"text\" inputmode=\"verbatim\"></input>" "</body>" "</html>"); render_thread_->sink().ClearMessages(); + struct InputModeTestCase { + const char* input_id; + ui::TextInputMode expected_mode; + }; + static const InputModeTestCase kInputModeTestCases[] = { + {"test1", ui::TEXT_INPUT_MODE_DEFAULT}, + {"test3", ui::TEXT_INPUT_MODE_VERBATIM}, + {"test4", ui::TEXT_INPUT_MODE_LATIN}, + {"test5", ui::TEXT_INPUT_MODE_LATIN_NAME}, + {"test6", ui::TEXT_INPUT_MODE_LATIN_PROSE}, + {"test7", ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN}, + {"test8", ui::TEXT_INPUT_MODE_KANA}, + {"test9", ui::TEXT_INPUT_MODE_KATAKANA}, + {"test10", ui::TEXT_INPUT_MODE_NUMERIC}, + {"test11", ui::TEXT_INPUT_MODE_TEL}, + {"test12", ui::TEXT_INPUT_MODE_EMAIL}, + {"test13", ui::TEXT_INPUT_MODE_URL}, + {"test14", ui::TEXT_INPUT_MODE_DEFAULT}, + {"test15", ui::TEXT_INPUT_MODE_VERBATIM}, + }; + const int kRepeatCount = 10; for (int i = 0; i < kRepeatCount; i++) { // Move the input focus to the first <input> element, where we should @@ -796,7 +832,11 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) { EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); ui::TextInputType type; bool can_compose_inline = false; - ViewHostMsg_TextInputTypeChanged::Read(msg, &type, &can_compose_inline); + ui::TextInputMode input_mode = ui::TEXT_INPUT_MODE_DEFAULT; + ViewHostMsg_TextInputTypeChanged::Read(msg, + &type, + &can_compose_inline, + &input_mode); EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); EXPECT_EQ(true, can_compose_inline); @@ -812,8 +852,35 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) { msg = render_thread_->sink().GetMessageAt(0); EXPECT_TRUE(msg != NULL); EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); - ViewHostMsg_TextInputTypeChanged::Read(msg, &type, &can_compose_inline); + ViewHostMsg_TextInputTypeChanged::Read(msg, + &type, + &can_compose_inline, + &input_mode); EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInputModeTestCases); i++) { + const InputModeTestCase* test_case = &kInputModeTestCases[i]; + std::string javascript = + base::StringPrintf("document.getElementById('%s').focus();", + test_case->input_id); + // Move the input focus to the target <input> element, where we should + // activate IMEs. + ExecuteJavaScriptAndReturnIntValue(ASCIIToUTF16(javascript), NULL); + ProcessPendingMessages(); + render_thread_->sink().ClearMessages(); + + // Update the IME status and verify if our IME backend sends an IPC + // message to activate IMEs. + view()->UpdateTextInputType(); + const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); + EXPECT_TRUE(msg != NULL); + EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); + ViewHostMsg_TextInputTypeChanged::Read(msg, + &type, + &can_compose_inline, + &input_mode); + EXPECT_EQ(test_case->expected_mode, input_mode); + } } } |