OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 scoped_ptr<InputMethodDescriptors> methods( | 1244 scoped_ptr<InputMethodDescriptors> methods( |
1245 manager_->GetActiveInputMethods()); | 1245 manager_->GetActiveInputMethods()); |
1246 ASSERT_EQ(2U, methods->size()); | 1246 ASSERT_EQ(2U, methods->size()); |
1247 // Ext. IMEs should be at the end of the list. | 1247 // Ext. IMEs should be at the end of the list. |
1248 EXPECT_EQ(ext_id, methods->at(1).id()); | 1248 EXPECT_EQ(ext_id, methods->at(1).id()); |
1249 } | 1249 } |
1250 manager_->RemoveObserver(&observer); | 1250 manager_->RemoveObserver(&observer); |
1251 } | 1251 } |
1252 | 1252 |
1253 TEST_F(InputMethodManagerImplTest, | 1253 TEST_F(InputMethodManagerImplTest, |
1254 ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { | |
1255 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | |
1256 std::vector<std::string> ids; | |
1257 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | |
1258 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | |
1259 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | |
1260 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | |
1261 | |
1262 InitComponentExtension(); | |
1263 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcUsId), | |
1264 manager_->GetCurrentInputMethod().id()); | |
1265 } | |
1266 | |
1267 TEST_F(InputMethodManagerImplTest, | |
1268 ChangeInputMethodBeforeComponentExtensionInitialization_TwoIME) { | |
1269 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | |
1270 std::vector<std::string> ids; | |
1271 ids.push_back(ImeIdFromEngineId(kNaclMozcUsId)); | |
1272 ids.push_back(ImeIdFromEngineId(kNaclMozcJpId)); | |
1273 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | |
1274 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | |
1275 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcUsId)); | |
1276 manager_->ChangeInputMethod(ImeIdFromEngineId(kNaclMozcJpId)); | |
1277 | |
1278 InitComponentExtension(); | |
1279 EXPECT_EQ(ImeIdFromEngineId(kNaclMozcJpId), | |
1280 manager_->GetCurrentInputMethod().id()); | |
1281 } | |
1282 | |
1283 TEST_F(InputMethodManagerImplTest, | |
1284 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | |
1285 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | |
1286 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | |
1287 ime_list_[1].id, | |
1288 ime_list_[1].engines[0].engine_id); | |
1289 std::vector<std::string> ids; | |
1290 ids.push_back(ext_id); | |
1291 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | |
1292 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | |
1293 manager_->ChangeInputMethod(ext_id); | |
1294 | |
1295 InitComponentExtension(); | |
1296 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | |
1297 } | |
1298 | |
1299 TEST_F(InputMethodManagerImplTest, | |
1300 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { | |
1301 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | |
1302 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | |
1303 ime_list_[1].id, | |
1304 ime_list_[1].engines[0].engine_id); | |
1305 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | |
1306 ime_list_[2].id, | |
1307 ime_list_[2].engines[0].engine_id); | |
1308 std::vector<std::string> ids; | |
1309 ids.push_back(ext_id1); | |
1310 ids.push_back(ext_id2); | |
1311 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | |
1312 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | |
1313 manager_->ChangeInputMethod(ext_id1); | |
1314 manager_->ChangeInputMethod(ext_id2); | |
1315 | |
1316 InitComponentExtension(); | |
1317 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | |
1318 } | |
1319 | |
1320 TEST_F(InputMethodManagerImplTest, | |
1321 ChangeInputMethod_ComponenteExtensionOneIME) { | 1254 ChangeInputMethod_ComponenteExtensionOneIME) { |
1322 InitComponentExtension(); | 1255 InitComponentExtension(); |
1323 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1256 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1324 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1257 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
1325 ime_list_[1].id, | 1258 ime_list_[1].id, |
1326 ime_list_[1].engines[0].engine_id); | 1259 ime_list_[1].engines[0].engine_id); |
1327 std::vector<std::string> ids; | 1260 std::vector<std::string> ids; |
1328 ids.push_back(ext_id); | 1261 ids.push_back(ext_id); |
1329 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1262 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1330 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1263 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 ASSERT_EQ(4U, input_method_ids.size()); | 1299 ASSERT_EQ(4U, input_method_ids.size()); |
1367 | 1300 |
1368 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1301 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
1369 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1302 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
1370 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1303 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1371 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1304 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
1372 } | 1305 } |
1373 | 1306 |
1374 } // namespace input_method | 1307 } // namespace input_method |
1375 } // namespace chromeos | 1308 } // namespace chromeos |
OLD | NEW |