Commit 1861e3d4 authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Treat ARC IMEs as same as IMEs created by an extension.

Bug: 845079
Test: unit_tests
Change-Id: I5634751508c852e63f5f0de91ae1be0933ee4bd3
Reviewed-on: https://chromium-review.googlesource.com/1109604
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569951}
parent f25e82e4
......@@ -636,8 +636,10 @@ void InputMethodManagerImpl::StateImpl::GetInputMethodExtensions(
std::map<std::string, InputMethodDescriptor>::iterator iter;
for (iter = extra_input_methods.begin(); iter != extra_input_methods.end();
++iter) {
if (extension_ime_util::IsExtensionIME(iter->first))
if (extension_ime_util::IsExtensionIME(iter->first) ||
extension_ime_util::IsArcIME(iter->first)) {
result->push_back(iter->second);
}
}
}
......@@ -1022,7 +1024,8 @@ const InputMethodDescriptor* InputMethodManagerImpl::LookupInputMethod(
}
const InputMethodDescriptor* descriptor = NULL;
if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) {
if (extension_ime_util::IsExtensionIME(input_method_id_to_switch) ||
extension_ime_util::IsArcIME(input_method_id_to_switch)) {
DCHECK(state->extra_input_methods.find(input_method_id_to_switch) !=
state->extra_input_methods.end());
descriptor = &(state->extra_input_methods[input_method_id_to_switch]);
......
......@@ -1505,5 +1505,60 @@ TEST_F(InputMethodManagerImplTest, SetFeaturesDisabled) {
InputMethodManager::FEATURE_HANDWRITING));
}
TEST_F(InputMethodManagerImplTest, TestAddRemoveArcInputMethods) {
InitComponentExtension();
manager_->SetUISessionState(InputMethodManager::STATE_BROWSER_SCREEN);
// There is one default IME
EXPECT_EQ(1u, manager_->GetActiveIMEState()->GetNumActiveInputMethods());
// Add an ARC IMEs.
std::vector<std::string> layouts({"us"});
std::vector<std::string> languages({"en-US"});
MockInputMethodEngine engine;
const std::string ime_id =
extension_ime_util::GetArcInputMethodID(kExtensionId1, "engine_id");
const InputMethodDescriptor descriptor(
ime_id, "arc ime", "AI", layouts, languages,
false /* is_login_keyboard */, GURL(), GURL());
InputMethodDescriptors descriptors({descriptor});
manager_->GetActiveIMEState()->AddInputMethodExtension(kExtensionId1,
descriptors, &engine);
InputMethodDescriptors result;
manager_->GetActiveIMEState()->GetInputMethodExtensions(&result);
EXPECT_EQ(1u, result.size());
EXPECT_EQ(ime_id, result[0].id());
result.clear();
// The ARC IME is not enabled by default.
EXPECT_EQ(1u, manager_->GetActiveIMEState()->GetNumActiveInputMethods());
// Enable it.
std::vector<std::string> extension_ime_ids({ime_id});
manager_->GetActiveIMEState()->SetEnabledExtensionImes(&extension_ime_ids);
EXPECT_EQ(2u, manager_->GetActiveIMEState()->GetNumActiveInputMethods());
{
std::unique_ptr<InputMethodDescriptors> methods =
manager_->GetActiveIMEState()->GetActiveInputMethods();
EXPECT_EQ(2u, methods->size());
EXPECT_EQ(ime_id, methods->at(1).id());
}
// Change to it.
manager_->GetActiveIMEState()->ChangeInputMethod(ime_id,
false /* show_message */);
InputMethodDescriptor current =
manager_->GetActiveIMEState()->GetCurrentInputMethod();
EXPECT_EQ(ime_id, current.id());
// Remove it.
manager_->GetActiveIMEState()->RemoveInputMethodExtension(kExtensionId1);
manager_->GetActiveIMEState()->GetInputMethodExtensions(&result);
EXPECT_TRUE(result.empty());
}
} // namespace input_method
} // namespace chromeos
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