Commit 1a47f6ae authored by yoichio@chromium.org's avatar yoichio@chromium.org

Set focused TextInputType to the Ime extension.

Input elements typed "text", "search", "tel", "url", "email"  and "number" are text input field: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-type

context.type should represent those types. 

BUG=311514

Review URL: https://codereview.chromium.org/47553010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233521 0039d316-1c4b-4281-b951-d872f2087c98
parent cb4a7319
...@@ -416,8 +416,26 @@ void InputMethodEngineIBus::FocusIn(ibus::TextInputType text_input_type) { ...@@ -416,8 +416,26 @@ void InputMethodEngineIBus::FocusIn(ibus::TextInputType text_input_type) {
InputContext context; InputContext context;
context.id = context_id_; context.id = context_id_;
// TODO: Other types switch (text_input_type) {
case ibus::TEXT_INPUT_TYPE_SEARCH:
context.type = "search";
break;
case ibus::TEXT_INPUT_TYPE_TELEPHONE:
context.type = "tel";
break;
case ibus::TEXT_INPUT_TYPE_URL:
context.type = "url";
break;
case ibus::TEXT_INPUT_TYPE_EMAIL:
context.type = "email";
break;
case ibus::TEXT_INPUT_TYPE_NUMBER:
context.type = "number";
break;
default:
context.type = "text"; context.type = "text";
break;
}
observer_->OnFocus(context); observer_->OnFocus(context);
} }
......
...@@ -181,7 +181,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest, ...@@ -181,7 +181,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
ASSERT_TRUE(activated_listener.was_satisfied()); ASSERT_TRUE(activated_listener.was_satisfied());
// onFocus event should be fired if FocusIn function is called. // onFocus event should be fired if FocusIn function is called.
ExtensionTestMessageListener focus_listener("onFocus", false);; ExtensionTestMessageListener focus_listener("onFocus:text", false);;
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_TEXT); engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_TEXT);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied()); ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied()); ASSERT_TRUE(focus_listener.was_satisfied());
...@@ -794,6 +794,50 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest, ...@@ -794,6 +794,50 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
EXPECT_EQ(3U, EXPECT_EQ(3U,
mock_input_context->last_delete_surrounding_text_arg().length); mock_input_context->last_delete_surrounding_text_arg().length);
} }
{
SCOPED_TRACE("onFocus test");
mock_input_context->Reset();
mock_candidate_window->Reset();
mock_property->Reset();
{
ExtensionTestMessageListener focus_listener("onFocus:text", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_TEXT);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
{
ExtensionTestMessageListener focus_listener("onFocus:search", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_SEARCH);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
{
ExtensionTestMessageListener focus_listener("onFocus:tel", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_TELEPHONE);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
{
ExtensionTestMessageListener focus_listener("onFocus:url", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_URL);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
{
ExtensionTestMessageListener focus_listener("onFocus:email", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_EMAIL);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
{
ExtensionTestMessageListener focus_listener("onFocus:number", false);
engine_handler->FocusIn(ibus::TEXT_INPUT_TYPE_NUMBER);
ASSERT_TRUE(focus_listener.WaitUntilSatisfied());
ASSERT_TRUE(focus_listener.was_satisfied());
}
}
IBusBridge::Get()->SetInputContextHandler(NULL); IBusBridge::Get()->SetInputContextHandler(NULL);
IBusBridge::Get()->SetCandidateWindowHandler(NULL); IBusBridge::Get()->SetCandidateWindowHandler(NULL);
IBusBridge::Get()->SetPropertyHandler(NULL); IBusBridge::Get()->SetPropertyHandler(NULL);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"description": "Describes an input Context", "description": "Describes an input Context",
"properties": { "properties": {
"contextID": {"type": "integer", "description": "This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called."}, "contextID": {"type": "integer", "description": "This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called."},
"type": {"type": "string", "description": "Type of value this text field edits, (Text, Number, Password, etc)", "enum": ["text", "number", "password"]} "type": {"type": "string", "description": "Type of value this text field edits, (Text, Number, URL, etc)", "enum": ["text", "search", "tel", "url", "email", "number"]}
} }
}, },
{ {
......
...@@ -138,7 +138,7 @@ EngineBridge.prototype = { ...@@ -138,7 +138,7 @@ EngineBridge.prototype = {
this.focusedContext_ = context; this.focusedContext_ = context;
if (this.activeEngine_) if (this.activeEngine_)
this.engineInstance_[this.activeEngine_].onFocus(context); this.engineInstance_[this.activeEngine_].onFocus(context);
chrome.test.sendMessage('onFocus'); chrome.test.sendMessage('onFocus:' + context.type);
}, },
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment