Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc

Issue 433163005: Refactoring for InputMethodEngine and InputMethodEventRouter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: error tolerance for missing background page for key events. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
index 0f21840ba75b224a948649e641a57b3020b48ad4..a42bfde542ce77836f001eade63fce4e332e2f66 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc
@@ -43,6 +43,8 @@ const char kNaclMozcJpId[] = "nacl_mozc_jp";
const char kExt2Engine1Id[] = "ext2_engine1-t-i0-engine_id";
const char kExt2Engine2Id[] = "ext2_engine2-t-i0-engine_id";
const char kPinyinImeId[] = "zh-t-i0-pinyin";
+const char kExtensionId1[] = "00000000000000000000000000000000";
+const char kExtensionId2[] = "11111111111111111111111111111111";
// Returns true if |descriptors| contain |target|.
bool Contain(const InputMethodDescriptors& descriptors,
@@ -135,8 +137,7 @@ class InputMethodManagerImplTest : public BrowserWithTestWindowTest {
candidate_window_controller_);
keyboard_ = new FakeImeKeyboard;
manager_->SetImeKeyboardForTesting(keyboard_);
- mock_engine_handler_.reset(
- new MockInputMethodEngine(InputMethodDescriptor()));
+ mock_engine_handler_.reset(new MockInputMethodEngine());
IMEBridge::Initialize();
IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get());
@@ -161,27 +162,26 @@ class InputMethodManagerImplTest : public BrowserWithTestWindowTest {
}
protected:
- Profile* GetProfile() { return manager_->GetProfile(); }
// Helper function to initialize component extension stuff for testing.
void InitComponentExtension() {
mock_delegate_ = new MockComponentExtIMEManagerDelegate();
mock_delegate_->set_ime_list(ime_list_);
scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_);
+ std::vector<std::string> layouts;
+ layouts.push_back("us");
+ std::vector<std::string> languages;
+ languages.push_back("en-US");
+
// Note, for production, these SetEngineHandler are called when
// IMEEngineHandlerInterface is initialized via
// InitializeComponentextension.
- manager_->AddInputMethodExtension(GetProfile(),
- ImeIdFromEngineId(kNaclMozcUsId),
- mock_engine_handler_.get());
- manager_->AddInputMethodExtension(GetProfile(),
- ImeIdFromEngineId(kNaclMozcJpId),
- mock_engine_handler_.get());
- manager_->AddInputMethodExtension(GetProfile(),
- ImeIdFromEngineId(kExt2Engine1Id),
+ InputMethodDescriptors descriptors;
+ manager_->AddInputMethodExtension(ImeIdFromEngineId(kNaclMozcUsId),
+ descriptors,
mock_engine_handler_.get());
- manager_->AddInputMethodExtension(GetProfile(),
- ImeIdFromEngineId(kExt2Engine2Id),
+ manager_->AddInputMethodExtension(ImeIdFromEngineId(kExt2Engine1Id),
+ descriptors,
mock_engine_handler_.get());
manager_->InitializeComponentExtensionForTesting(delegate.Pass());
}
@@ -1125,7 +1125,7 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
languages.push_back("en-US");
const std::string ext1_id =
- extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
+ extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id");
const InputMethodDescriptor descriptor1(ext1_id,
"deadbeef input method",
"DB",
@@ -1134,8 +1134,10 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
false, // is_login_keyboard
GURL(),
GURL());
- MockInputMethodEngine engine(descriptor1);
- manager_->AddInputMethodExtension(GetProfile(), ext1_id, &engine);
+ MockInputMethodEngine engine;
+ InputMethodDescriptors descriptors;
+ descriptors.push_back(descriptor1);
+ manager_->AddInputMethodExtension(kExtensionId1, descriptors, &engine);
// Extension IMEs are not enabled by default.
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
@@ -1154,7 +1156,7 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
}
const std::string ext2_id =
- extension_ime_util::GetInputMethodID("cafebabe", "engine_id");
+ extension_ime_util::GetInputMethodID(kExtensionId2, "engine_id");
const InputMethodDescriptor descriptor2(ext2_id,
"cafebabe input method",
"CB",
@@ -1163,8 +1165,10 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
false, // is_login_keyboard
GURL(),
GURL());
- MockInputMethodEngine engine2(descriptor2);
- manager_->AddInputMethodExtension(GetProfile(), ext2_id, &engine2);
+ descriptors.clear();
+ descriptors.push_back(descriptor2);
+ MockInputMethodEngine engine2;
+ manager_->AddInputMethodExtension(kExtensionId2, descriptors, &engine2);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
extension_ime_ids.push_back(ext2_id);
@@ -1180,9 +1184,9 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
}
// Remove them.
- manager_->RemoveInputMethodExtension(GetProfile(), ext1_id);
+ manager_->RemoveInputMethodExtension(kExtensionId1);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
- manager_->RemoveInputMethodExtension(GetProfile(), ext2_id);
+ manager_->RemoveInputMethodExtension(kExtensionId2);
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
}
@@ -1206,7 +1210,7 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
languages.push_back("en-US");
const std::string ext_id =
- extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
+ extension_ime_util::GetInputMethodID(kExtensionId1, "engine_id");
const InputMethodDescriptor descriptor(ext_id,
"deadbeef input method",
"DB",
@@ -1215,8 +1219,10 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
false, // is_login_keyboard
GURL(),
GURL());
- MockInputMethodEngine engine(descriptor);
- manager_->AddInputMethodExtension(GetProfile(), ext_id, &engine);
+ MockInputMethodEngine engine;
+ InputMethodDescriptors descriptors;
+ descriptors.push_back(descriptor);
+ manager_->AddInputMethodExtension(kExtensionId1, descriptors, &engine);
// Extension IME is not enabled by default.
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());

Powered by Google App Engine
This is Rietveld 408576698