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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Returns true if |descriptors| contain |target|. | 44 // Returns true if |descriptors| contain |target|. |
45 bool Contain(const InputMethodDescriptors& descriptors, | 45 bool Contain(const InputMethodDescriptors& descriptors, |
46 const InputMethodDescriptor& target) { | 46 const InputMethodDescriptor& target) { |
47 for (size_t i = 0; i < descriptors.size(); ++i) { | 47 for (size_t i = 0; i < descriptors.size(); ++i) { |
48 if (descriptors[i].id() == target.id()) | 48 if (descriptors[i].id() == target.id()) |
49 return true; | 49 return true; |
50 } | 50 } |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
| 54 std::string XkbId(const std::string& id) { |
| 55 return extension_ime_util::GetInputMethodIDByKeyboardLayout(id); |
| 56 } |
| 57 |
54 class InputMethodManagerImplTest : public testing::Test { | 58 class InputMethodManagerImplTest : public testing::Test { |
55 public: | 59 public: |
56 InputMethodManagerImplTest() | 60 InputMethodManagerImplTest() |
57 : delegate_(NULL), | 61 : delegate_(NULL), |
58 candidate_window_controller_(NULL), | 62 candidate_window_controller_(NULL), |
59 xkeyboard_(NULL) { | 63 xkeyboard_(NULL) { |
60 } | 64 } |
61 virtual ~InputMethodManagerImplTest() {} | 65 virtual ~InputMethodManagerImplTest() {} |
62 | 66 |
63 virtual void SetUp() OVERRIDE { | 67 virtual void SetUp() OVERRIDE { |
64 delegate_ = new FakeInputMethodDelegate(); | 68 delegate_ = new FakeInputMethodDelegate(); |
65 manager_.reset(new InputMethodManagerImpl( | 69 manager_.reset(new InputMethodManagerImpl( |
66 scoped_ptr<InputMethodDelegate>(delegate_))); | 70 scoped_ptr<InputMethodDelegate>(delegate_))); |
67 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); | 71 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); |
68 candidate_window_controller_ = new MockCandidateWindowController; | 72 candidate_window_controller_ = new MockCandidateWindowController; |
69 manager_->SetCandidateWindowControllerForTesting( | 73 manager_->SetCandidateWindowControllerForTesting( |
70 candidate_window_controller_); | 74 candidate_window_controller_); |
71 xkeyboard_ = new FakeXKeyboard; | 75 xkeyboard_ = new FakeXKeyboard; |
72 manager_->SetXKeyboardForTesting(xkeyboard_); | 76 manager_->SetXKeyboardForTesting(xkeyboard_); |
73 mock_engine_handler_.reset(new MockIMEEngineHandler()); | 77 mock_engine_handler_.reset(new MockIMEEngineHandler()); |
74 IMEBridge::Initialize(); | 78 IMEBridge::Initialize(); |
75 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); | 79 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
76 | 80 |
77 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); | 81 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); |
78 | 82 |
79 ime_list_.clear(); | 83 ime_list_.clear(); |
80 | 84 |
| 85 ComponentExtensionIME ext_xkb; |
| 86 ext_xkb.id = "fgoepimhcoialccpbmpnnblemnepkkao"; |
| 87 ext_xkb.description = "ext_xkb_description"; |
| 88 ext_xkb.path = base::FilePath("ext_xkb_file_path"); |
| 89 |
| 90 ComponentExtensionEngine ext_xkb_engine_us; |
| 91 ext_xkb_engine_us.engine_id = "xkb:us::eng"; |
| 92 ext_xkb_engine_us.display_name = "xkb:us::eng"; |
| 93 ext_xkb_engine_us.language_codes.push_back("en-US"); |
| 94 ext_xkb_engine_us.layouts.push_back("us"); |
| 95 ext_xkb.engines.push_back(ext_xkb_engine_us); |
| 96 |
| 97 ComponentExtensionEngine ext_xkb_engine_dvorak; |
| 98 ext_xkb_engine_dvorak.engine_id = "xkb:us:dvorak:eng"; |
| 99 ext_xkb_engine_dvorak.display_name = "xkb:us:dvorak:eng"; |
| 100 ext_xkb_engine_dvorak.language_codes.push_back("en-US"); |
| 101 ext_xkb_engine_dvorak.layouts.push_back("us(dvorak)"); |
| 102 ext_xkb.engines.push_back(ext_xkb_engine_dvorak); |
| 103 |
| 104 ComponentExtensionEngine ext_xkb_engine_intl; |
| 105 ext_xkb_engine_intl.engine_id = "xkb:us:intl:eng"; |
| 106 ext_xkb_engine_intl.display_name = "xkb:us:intl:eng"; |
| 107 ext_xkb_engine_intl.language_codes.push_back("en-US"); |
| 108 ext_xkb_engine_intl.layouts.push_back("us(intl)"); |
| 109 ext_xkb.engines.push_back(ext_xkb_engine_intl); |
| 110 |
| 111 ComponentExtensionEngine ext_xkb_engine_altgr_intl; |
| 112 ext_xkb_engine_altgr_intl.engine_id = "xkb:us:altgr-intl:eng"; |
| 113 ext_xkb_engine_altgr_intl.display_name = "xkb:us:altgr-intl:eng"; |
| 114 ext_xkb_engine_altgr_intl.language_codes.push_back("en-US"); |
| 115 ext_xkb_engine_altgr_intl.layouts.push_back("us(altgr-intl)"); |
| 116 ext_xkb.engines.push_back(ext_xkb_engine_altgr_intl); |
| 117 |
| 118 ComponentExtensionEngine ext_xkb_engine_fr; |
| 119 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; |
| 120 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; |
| 121 ext_xkb_engine_fr.language_codes.push_back("fr"); |
| 122 ext_xkb_engine_fr.layouts.push_back("fr"); |
| 123 ext_xkb.engines.push_back(ext_xkb_engine_fr); |
| 124 |
| 125 ComponentExtensionEngine ext_xkb_engine_colemak; |
| 126 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; |
| 127 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; |
| 128 ext_xkb_engine_colemak.language_codes.push_back("en-US"); |
| 129 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); |
| 130 ext_xkb.engines.push_back(ext_xkb_engine_colemak); |
| 131 |
| 132 ComponentExtensionEngine ext_xkb_engine_se; |
| 133 ext_xkb_engine_se.engine_id = "xkb:se::swe"; |
| 134 ext_xkb_engine_se.display_name = "xkb:se::swe"; |
| 135 ext_xkb_engine_se.language_codes.push_back("sv"); |
| 136 ext_xkb_engine_se.layouts.push_back("se"); |
| 137 ext_xkb.engines.push_back(ext_xkb_engine_se); |
| 138 |
| 139 ComponentExtensionEngine ext_xkb_engine_jp; |
| 140 ext_xkb_engine_jp.engine_id = "xkb:jp::jpn"; |
| 141 ext_xkb_engine_jp.display_name = "xkb:jp::jpn"; |
| 142 ext_xkb_engine_jp.language_codes.push_back("ja"); |
| 143 ext_xkb_engine_jp.layouts.push_back("jp"); |
| 144 ext_xkb.engines.push_back(ext_xkb_engine_jp); |
| 145 |
| 146 ComponentExtensionEngine ext_xkb_engine_ru; |
| 147 ext_xkb_engine_ru.engine_id = "xkb:ru::rus"; |
| 148 ext_xkb_engine_ru.display_name = "xkb:ru::rus"; |
| 149 ext_xkb_engine_ru.language_codes.push_back("ru"); |
| 150 ext_xkb_engine_ru.layouts.push_back("ru"); |
| 151 ext_xkb.engines.push_back(ext_xkb_engine_ru); |
| 152 |
| 153 ComponentExtensionEngine ext_xkb_engine_hu; |
| 154 ext_xkb_engine_hu.engine_id = "xkb:hu::hun"; |
| 155 ext_xkb_engine_hu.display_name = "xkb:hu::hun"; |
| 156 ext_xkb_engine_hu.language_codes.push_back("hu"); |
| 157 ext_xkb_engine_hu.layouts.push_back("hu"); |
| 158 ext_xkb.engines.push_back(ext_xkb_engine_hu); |
| 159 |
| 160 ime_list_.push_back(ext_xkb); |
| 161 |
81 ComponentExtensionIME ext1; | 162 ComponentExtensionIME ext1; |
82 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; | 163 ext1.id = "fpfbhcjppmaeaijcidgiibchfbnhbelj"; |
83 ext1.description = "ext1_description"; | 164 ext1.description = "ext1_description"; |
84 ext1.path = base::FilePath("ext1_file_path"); | 165 ext1.path = base::FilePath("ext1_file_path"); |
85 | 166 |
86 ComponentExtensionEngine ext1_engine1; | 167 ComponentExtensionEngine ext1_engine1; |
87 ext1_engine1.engine_id = "nacl_mozc_us"; | 168 ext1_engine1.engine_id = "nacl_mozc_us"; |
88 ext1_engine1.display_name = "ext1_engine_1_display_name"; | 169 ext1_engine1.display_name = "ext1_engine_1_display_name"; |
89 ext1_engine1.language_codes.push_back("ja"); | 170 ext1_engine1.language_codes.push_back("ja"); |
90 ext1_engine1.layouts.push_back("us"); | 171 ext1_engine1.layouts.push_back("us"); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // also for the scenario. | 324 // also for the scenario. |
244 std::vector<std::string> keyboard_layouts; | 325 std::vector<std::string> keyboard_layouts; |
245 keyboard_layouts.push_back("xkb:us::eng"); | 326 keyboard_layouts.push_back("xkb:us::eng"); |
246 | 327 |
247 TestObserver observer; | 328 TestObserver observer; |
248 InitComponentExtension(); | 329 InitComponentExtension(); |
249 manager_->AddObserver(&observer); | 330 manager_->AddObserver(&observer); |
250 menu_manager_->AddObserver(&observer); | 331 menu_manager_->AddObserver(&observer); |
251 EXPECT_EQ(0, observer.input_method_changed_count_); | 332 EXPECT_EQ(0, observer.input_method_changed_count_); |
252 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 333 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
| 334 EXPECT_EQ(5U, manager_->GetActiveInputMethods()->size()); |
253 EXPECT_EQ(1, observer.input_method_changed_count_); | 335 EXPECT_EQ(1, observer.input_method_changed_count_); |
254 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); | 336 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
255 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 337 manager_->ChangeInputMethod(XkbId("xkb:us:dvorak:eng")); |
256 EXPECT_FALSE(observer.last_show_message_); | 338 EXPECT_FALSE(observer.last_show_message_); |
257 EXPECT_EQ(2, observer.input_method_changed_count_); | 339 EXPECT_EQ(2, observer.input_method_changed_count_); |
258 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 340 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
259 manager_->ChangeInputMethod("xkb:us:dvorak:eng"); | 341 manager_->ChangeInputMethod(XkbId("xkb:us:dvorak:eng")); |
260 EXPECT_FALSE(observer.last_show_message_); | 342 EXPECT_FALSE(observer.last_show_message_); |
261 | 343 |
262 // The observer is always notified even when the same input method ID is | 344 // The observer is always notified even when the same input method ID is |
263 // passed to ChangeInputMethod() more than twice. | 345 // passed to ChangeInputMethod() more than twice. |
264 // TODO(komatsu): Revisit if this is neccessary. | 346 // TODO(komatsu): Revisit if this is neccessary. |
265 EXPECT_EQ(3, observer.input_method_changed_count_); | 347 EXPECT_EQ(3, observer.input_method_changed_count_); |
266 | 348 |
267 // If the same input method ID is passed, PropertyChanged() is not | 349 // If the same input method ID is passed, PropertyChanged() is not |
268 // notified. | 350 // notified. |
269 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); | 351 EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
(...skipping 24 matching lines...) Expand all Loading... |
294 } | 376 } |
295 | 377 |
296 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 378 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
297 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 379 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
298 // ibus_input_method.txt. | 380 // ibus_input_method.txt. |
299 std::vector<std::string> keyboard_layouts; | 381 std::vector<std::string> keyboard_layouts; |
300 | 382 |
301 InitComponentExtension(); | 383 InitComponentExtension(); |
302 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 384 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
303 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 385 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
304 for (size_t i = 0; i < manager_->GetActiveInputMethodIds().size(); ++i) | |
305 LOG(ERROR) << manager_->GetActiveInputMethodIds().at(i); | |
306 | 386 |
307 // For http://crbug.com/19655#c11 - (5) | 387 // For http://crbug.com/19655#c11 - (5) |
308 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 388 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
309 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 389 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
310 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 390 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
311 } | 391 } |
312 | 392 |
313 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 393 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
314 // For http://crbug.com/329061 | 394 // For http://crbug.com/329061 |
315 std::vector<std::string> keyboard_layouts; | 395 std::vector<std::string> keyboard_layouts; |
316 keyboard_layouts.push_back("xkb:se::swe"); | 396 keyboard_layouts.push_back("xkb:se::swe"); |
317 | 397 |
| 398 InitComponentExtension(); |
318 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 399 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
319 const std::string im_id = manager_->GetCurrentInputMethod().id(); | 400 const std::string im_id = manager_->GetCurrentInputMethod().id(); |
320 EXPECT_EQ("xkb:se::swe", im_id); | 401 EXPECT_EQ(XkbId("xkb:se::swe"), im_id); |
321 } | 402 } |
322 | 403 |
323 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 404 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
| 405 InitComponentExtension(); |
324 // The physical layout is French. | 406 // The physical layout is French. |
325 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 407 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
326 "xkb:fr::fra"); | 408 "xkb:fr::fra"); |
327 manager_->EnableLoginLayouts( | 409 manager_->EnableLoginLayouts( |
328 "en-US", | 410 "en-US", |
329 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 411 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
330 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French | 412 EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French |
331 // The physical layout is Japanese. | 413 // The physical layout is Japanese. |
332 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 414 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
333 "xkb:jp::jpn"); | 415 "xkb:jp::jpn"); |
334 manager_->EnableLoginLayouts( | 416 manager_->EnableLoginLayouts( |
335 "ja", | 417 "ja", |
336 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 418 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
337 // "xkb:us::eng" is not needed, hence 1. | 419 // "xkb:us::eng" is not needed. Hence 1. |
338 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 420 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
339 | 421 |
340 // The physical layout is Russian. | 422 // The physical layout is Russian. |
341 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 423 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
342 "xkb:ru::rus"); | 424 "xkb:ru::rus"); |
343 manager_->EnableLoginLayouts( | 425 manager_->EnableLoginLayouts( |
344 "ru", | 426 "ru", |
345 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 427 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
346 // "xkb:us::eng" only. | 428 // "xkb:us::eng" only. |
347 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 429 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
348 EXPECT_EQ("xkb:us::eng", manager_->GetActiveInputMethodIds().front()); | 430 EXPECT_EQ(XkbId("xkb:us::eng"), |
| 431 manager_->GetActiveInputMethodIds().front()); |
349 } | 432 } |
350 | 433 |
351 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { | 434 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
| 435 InitComponentExtension(); |
352 // The physical layouts are French and Hungarian. | 436 // The physical layouts are French and Hungarian. |
353 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 437 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
354 "xkb:fr::fra,xkb:hu::hun"); | 438 "xkb:fr::fra,xkb:hu::hun"); |
355 manager_->EnableLoginLayouts( | 439 manager_->EnableLoginLayouts( |
356 "en-US", | 440 "en-US", |
357 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 441 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
358 // 5 + French + Hungarian | 442 // 5 + French + Hungarian |
359 EXPECT_EQ(7U, manager_->GetNumActiveInputMethods()); | 443 EXPECT_EQ(7U, manager_->GetNumActiveInputMethods()); |
360 } | 444 } |
361 | 445 |
362 TEST_F(InputMethodManagerImplTest, | 446 TEST_F(InputMethodManagerImplTest, |
363 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { | 447 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
| 448 InitComponentExtension(); |
364 // The physical layouts are English (US) and Russian. | 449 // The physical layouts are English (US) and Russian. |
365 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 450 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
366 "xkb:us::eng,xkb:ru::rus"); | 451 "xkb:us::eng,xkb:ru::rus"); |
367 manager_->EnableLoginLayouts( | 452 manager_->EnableLoginLayouts( |
368 "ru", | 453 "ru", |
369 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 454 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
370 // xkb:us:eng | 455 // xkb:us:eng |
371 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 456 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
372 } | 457 } |
373 | 458 |
374 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { | 459 TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { |
| 460 InitComponentExtension(); |
375 std::vector<std::string> keyboard_layouts; | 461 std::vector<std::string> keyboard_layouts; |
376 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese | 462 manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
377 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 463 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
378 scoped_ptr<InputMethodDescriptors> methods( | 464 scoped_ptr<InputMethodDescriptors> methods( |
379 manager_->GetActiveInputMethods()); | 465 manager_->GetActiveInputMethods()); |
380 ASSERT_TRUE(methods.get()); | 466 ASSERT_TRUE(methods.get()); |
381 EXPECT_EQ(2U, methods->size()); | 467 EXPECT_EQ(2U, methods->size()); |
382 const InputMethodDescriptor* id_to_find = | 468 const InputMethodDescriptor* id_to_find = |
383 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 469 manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
384 "xkb:us::eng"); | 470 XkbId("xkb:us::eng")); |
385 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 471 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
386 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 472 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
387 "xkb:jp::jpn"); | 473 XkbId("xkb:jp::jpn")); |
388 EXPECT_TRUE(Contain(*methods.get(), *id_to_find)); | 474 EXPECT_TRUE(id_to_find && Contain(*methods.get(), *id_to_find)); |
389 } | 475 } |
390 | 476 |
391 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { | 477 TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { |
392 // For http://crbug.com/19655#c11 - (8), step 6. | 478 // For http://crbug.com/19655#c11 - (8), step 6. |
393 TestObserver observer; | 479 TestObserver observer; |
394 manager_->AddObserver(&observer); | 480 manager_->AddObserver(&observer); |
395 InitComponentExtension(); | 481 InitComponentExtension(); |
396 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 482 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
397 std::vector<std::string> ids; | 483 std::vector<std::string> ids; |
398 ids.push_back("xkb:us:dvorak:eng"); | 484 ids.push_back("xkb:us:dvorak:eng"); |
399 ids.push_back("xkb:us:colemak:eng"); | 485 ids.push_back("xkb:us:colemak:eng"); |
400 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 486 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
401 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 487 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
402 // Since all the IDs added avobe are keyboard layouts, Start() should not be | 488 // Since all the IDs added avobe are keyboard layouts, Start() should not be |
403 // called. | 489 // called. |
404 EXPECT_EQ(1, observer.input_method_changed_count_); | 490 EXPECT_EQ(1, observer.input_method_changed_count_); |
405 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 491 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
406 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 492 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
407 // Disable Dvorak. | 493 // Disable Dvorak. |
408 ids.erase(ids.begin()); | 494 ids.erase(ids.begin()); |
409 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 495 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
410 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 496 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
411 EXPECT_EQ(2, observer.input_method_changed_count_); | 497 EXPECT_EQ(2, observer.input_method_changed_count_); |
412 EXPECT_EQ(ids[0], // colemak | 498 EXPECT_EQ(XkbId(ids[0]), // colemak |
413 manager_->GetCurrentInputMethod().id()); | 499 manager_->GetCurrentInputMethod().id()); |
414 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 500 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
415 manager_->RemoveObserver(&observer); | 501 manager_->RemoveObserver(&observer); |
416 } | 502 } |
417 | 503 |
418 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { | 504 TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { |
419 // For http://crbug.com/19655#c11 - (9). | 505 // For http://crbug.com/19655#c11 - (9). |
420 TestObserver observer; | 506 TestObserver observer; |
421 manager_->AddObserver(&observer); | 507 manager_->AddObserver(&observer); |
422 InitComponentExtension(); | 508 InitComponentExtension(); |
423 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 509 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
424 std::vector<std::string> ids; | 510 std::vector<std::string> ids; |
425 ids.push_back("xkb:us::eng"); | 511 ids.push_back("xkb:us::eng"); |
426 ids.push_back("xkb:us:dvorak:eng"); | 512 ids.push_back("xkb:us:dvorak:eng"); |
427 ids.push_back("xkb:us:colemak:eng"); | 513 ids.push_back("xkb:us:colemak:eng"); |
428 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 514 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
429 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 515 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
430 EXPECT_EQ(1, observer.input_method_changed_count_); | 516 EXPECT_EQ(1, observer.input_method_changed_count_); |
431 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 517 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
432 EXPECT_EQ("us", xkeyboard_->last_layout_); | 518 EXPECT_EQ("us", xkeyboard_->last_layout_); |
433 // Switch to Dvorak. | 519 // Switch to Dvorak. |
434 manager_->SwitchToNextInputMethod(); | 520 manager_->SwitchToNextInputMethod(); |
435 EXPECT_EQ(2, observer.input_method_changed_count_); | 521 EXPECT_EQ(2, observer.input_method_changed_count_); |
436 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 522 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
437 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 523 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
438 // Disable Dvorak. | 524 // Disable Dvorak. |
439 ids.erase(ids.begin() + 1); | 525 ids.erase(ids.begin() + 1); |
440 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 526 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
441 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 527 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
442 EXPECT_EQ(3, observer.input_method_changed_count_); | 528 EXPECT_EQ(3, observer.input_method_changed_count_); |
443 EXPECT_EQ(ids[0], // US Qwerty | 529 EXPECT_EQ(XkbId(ids[0]), // US Qwerty |
444 manager_->GetCurrentInputMethod().id()); | 530 manager_->GetCurrentInputMethod().id()); |
445 EXPECT_EQ("us", xkeyboard_->last_layout_); | 531 EXPECT_EQ("us", xkeyboard_->last_layout_); |
446 manager_->RemoveObserver(&observer); | 532 manager_->RemoveObserver(&observer); |
447 } | 533 } |
448 | 534 |
449 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { | 535 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { |
450 // For http://crbug.com/19655#c11 - (10). | 536 // For http://crbug.com/19655#c11 - (10). |
451 TestObserver observer; | 537 TestObserver observer; |
452 manager_->AddObserver(&observer); | 538 manager_->AddObserver(&observer); |
453 InitComponentExtension(); | 539 InitComponentExtension(); |
454 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 540 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
455 std::vector<std::string> ids; | 541 std::vector<std::string> ids; |
456 ids.push_back("xkb:us:dvorak:eng"); | 542 ids.push_back("xkb:us:dvorak:eng"); |
457 ids.push_back(kNaclMozcUsId); | 543 ids.push_back(kNaclMozcUsId); |
458 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 544 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
459 EXPECT_EQ(1, observer.input_method_changed_count_); | 545 EXPECT_EQ(1, observer.input_method_changed_count_); |
460 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 546 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
461 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 547 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
462 // Switch to Mozc | 548 // Switch to Mozc |
463 manager_->SwitchToNextInputMethod(); | 549 manager_->SwitchToNextInputMethod(); |
464 EXPECT_EQ(2, observer.input_method_changed_count_); | 550 EXPECT_EQ(2, observer.input_method_changed_count_); |
465 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 551 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
466 EXPECT_EQ("us", xkeyboard_->last_layout_); | 552 EXPECT_EQ("us", xkeyboard_->last_layout_); |
467 // Disable Mozc. | 553 // Disable Mozc. |
468 ids.erase(ids.begin() + 1); | 554 ids.erase(ids.begin() + 1); |
469 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 555 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
470 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 556 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
471 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 557 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
472 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 558 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
473 } | 559 } |
474 | 560 |
475 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { | 561 TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { |
476 // For http://crbug.com/19655#c11 - (11). | 562 // For http://crbug.com/19655#c11 - (11). |
477 TestObserver observer; | 563 TestObserver observer; |
478 manager_->AddObserver(&observer); | 564 manager_->AddObserver(&observer); |
479 InitComponentExtension(); | 565 InitComponentExtension(); |
480 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 566 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
481 std::vector<std::string> ids; | 567 std::vector<std::string> ids; |
482 ids.push_back("xkb:us:dvorak:eng"); | 568 ids.push_back("xkb:us:dvorak:eng"); |
483 ids.push_back(kNaclMozcUsId); | 569 ids.push_back(kNaclMozcUsId); |
484 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 570 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
485 EXPECT_EQ(1, observer.input_method_changed_count_); | 571 EXPECT_EQ(1, observer.input_method_changed_count_); |
486 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 572 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
487 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 573 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
488 | 574 |
489 // Disable Dvorak. | 575 // Disable Dvorak. |
490 ids.erase(ids.begin()); | 576 ids.erase(ids.begin()); |
491 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 577 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
492 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 578 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
493 EXPECT_EQ(ids[0], // Mozc | 579 EXPECT_EQ(XkbId(ids[0]), // Mozc |
494 manager_->GetCurrentInputMethod().id()); | 580 manager_->GetCurrentInputMethod().id()); |
495 EXPECT_EQ("us", xkeyboard_->last_layout_); | 581 EXPECT_EQ("us", xkeyboard_->last_layout_); |
496 manager_->RemoveObserver(&observer); | 582 manager_->RemoveObserver(&observer); |
497 } | 583 } |
498 | 584 |
499 TEST_F(InputMethodManagerImplTest, TestEnableImes) { | 585 TEST_F(InputMethodManagerImplTest, TestEnableImes) { |
500 TestObserver observer; | 586 TestObserver observer; |
501 manager_->AddObserver(&observer); | 587 manager_->AddObserver(&observer); |
502 InitComponentExtension(); | 588 InitComponentExtension(); |
503 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 589 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
504 std::vector<std::string> ids; | 590 std::vector<std::string> ids; |
505 ids.push_back(kExt2Engine1Id); | 591 ids.push_back(kExt2Engine1Id); |
506 ids.push_back("mozc-dv"); | 592 ids.push_back("mozc-dv"); |
507 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 593 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
508 EXPECT_EQ(1, observer.input_method_changed_count_); | 594 EXPECT_EQ(1, observer.input_method_changed_count_); |
509 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 595 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
510 EXPECT_EQ("us", xkeyboard_->last_layout_); | 596 EXPECT_EQ("us", xkeyboard_->last_layout_); |
511 manager_->RemoveObserver(&observer); | 597 manager_->RemoveObserver(&observer); |
512 } | 598 } |
513 | 599 |
514 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { | 600 TEST_F(InputMethodManagerImplTest, TestEnableUnknownIds) { |
515 TestObserver observer; | 601 TestObserver observer; |
516 manager_->AddObserver(&observer); | 602 manager_->AddObserver(&observer); |
517 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 603 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
518 std::vector<std::string> ids; | 604 std::vector<std::string> ids; |
519 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. | 605 ids.push_back("xkb:tl::tlh"); // Klingon, which is not supported. |
(...skipping 12 matching lines...) Expand all Loading... |
532 TestObserver observer; | 618 TestObserver observer; |
533 manager_->AddObserver(&observer); | 619 manager_->AddObserver(&observer); |
534 InitComponentExtension(); | 620 InitComponentExtension(); |
535 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 621 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
536 std::vector<std::string> ids; | 622 std::vector<std::string> ids; |
537 ids.push_back("xkb:us::eng"); | 623 ids.push_back("xkb:us::eng"); |
538 ids.push_back("xkb:us:dvorak:eng"); | 624 ids.push_back("xkb:us:dvorak:eng"); |
539 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 625 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
540 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 626 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
541 EXPECT_EQ(1, observer.input_method_changed_count_); | 627 EXPECT_EQ(1, observer.input_method_changed_count_); |
542 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 628 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
543 EXPECT_EQ("us", xkeyboard_->last_layout_); | 629 EXPECT_EQ("us", xkeyboard_->last_layout_); |
544 | 630 |
545 // Switch to Dvorak. | 631 // Switch to Dvorak. |
546 manager_->SwitchToNextInputMethod(); | 632 manager_->SwitchToNextInputMethod(); |
547 EXPECT_EQ(2, observer.input_method_changed_count_); | 633 EXPECT_EQ(2, observer.input_method_changed_count_); |
548 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 634 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
549 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 635 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
550 | 636 |
551 // Lock screen | 637 // Lock screen |
552 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 638 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
553 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 639 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
554 EXPECT_EQ(ids[1], // still Dvorak | 640 EXPECT_EQ(XkbId(ids[1]), // still Dvorak |
555 manager_->GetCurrentInputMethod().id()); | 641 manager_->GetCurrentInputMethod().id()); |
556 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 642 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
557 // Switch back to Qwerty. | 643 // Switch back to Qwerty. |
558 manager_->SwitchToNextInputMethod(); | 644 manager_->SwitchToNextInputMethod(); |
559 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 645 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
560 EXPECT_EQ("us", xkeyboard_->last_layout_); | 646 EXPECT_EQ("us", xkeyboard_->last_layout_); |
561 | 647 |
562 // Unlock screen. The original state, Dvorak, is restored. | 648 // Unlock screen. The original state, Dvorak, is restored. |
563 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 649 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
564 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 650 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
565 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 651 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
566 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 652 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
567 | 653 |
568 manager_->RemoveObserver(&observer); | 654 manager_->RemoveObserver(&observer); |
569 } | 655 } |
570 | 656 |
571 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { | 657 TEST_F(InputMethodManagerImplTest, SwitchInputMethodTest) { |
572 // For http://crbug.com/19655#c11 - (15). | 658 // For http://crbug.com/19655#c11 - (15). |
573 TestObserver observer; | 659 TestObserver observer; |
574 manager_->AddObserver(&observer); | 660 manager_->AddObserver(&observer); |
575 InitComponentExtension(); | 661 InitComponentExtension(); |
576 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 662 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
577 std::vector<std::string> ids; | 663 std::vector<std::string> ids; |
578 ids.push_back("xkb:us:dvorak:eng"); | 664 ids.push_back("xkb:us:dvorak:eng"); |
579 ids.push_back(kExt2Engine2Id); | 665 ids.push_back(kExt2Engine2Id); |
580 ids.push_back(kExt2Engine1Id); | 666 ids.push_back(kExt2Engine1Id); |
581 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 667 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
582 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); | 668 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); |
583 EXPECT_EQ(1, observer.input_method_changed_count_); | 669 EXPECT_EQ(1, observer.input_method_changed_count_); |
584 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 670 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
585 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 671 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
586 | 672 |
587 // Switch to Mozc. | 673 // Switch to Mozc. |
588 manager_->SwitchToNextInputMethod(); | 674 manager_->SwitchToNextInputMethod(); |
589 EXPECT_EQ(2, observer.input_method_changed_count_); | 675 EXPECT_EQ(2, observer.input_method_changed_count_); |
590 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 676 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
591 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 677 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
592 | 678 |
593 // Lock screen | 679 // Lock screen |
594 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 680 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
595 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. | 681 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Qwerty+Dvorak. |
596 EXPECT_EQ("xkb:us:dvorak:eng", | 682 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), |
597 manager_->GetCurrentInputMethod().id()); | 683 manager_->GetCurrentInputMethod().id()); |
598 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 684 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
599 manager_->SwitchToNextInputMethod(); | 685 manager_->SwitchToNextInputMethod(); |
600 EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout. | 686 EXPECT_EQ(XkbId("xkb:us::eng"), // The hardware keyboard layout. |
601 manager_->GetCurrentInputMethod().id()); | 687 manager_->GetCurrentInputMethod().id()); |
602 EXPECT_EQ("us", xkeyboard_->last_layout_); | 688 EXPECT_EQ("us", xkeyboard_->last_layout_); |
603 | 689 |
604 // Unlock screen. The original state, pinyin-dv, is restored. | 690 // Unlock screen. The original state, pinyin-dv, is restored. |
605 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 691 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
606 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. | 692 EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); // Dvorak and 2 IMEs. |
607 EXPECT_EQ(ids[1], manager_->GetCurrentInputMethod().id()); | 693 EXPECT_EQ(XkbId(ids[1]), manager_->GetCurrentInputMethod().id()); |
608 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 694 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
609 | 695 |
610 manager_->RemoveObserver(&observer); | 696 manager_->RemoveObserver(&observer); |
611 } | 697 } |
612 | 698 |
613 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { | 699 TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
614 // For http://crbug.com/19655#c11 - (8), step 7-11. | 700 // For http://crbug.com/19655#c11 - (8), step 7-11. |
615 InitComponentExtension(); | 701 InitComponentExtension(); |
616 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 702 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
617 std::vector<std::string> ids; | 703 std::vector<std::string> ids; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 810 |
725 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 811 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
726 TestObserver observer; | 812 TestObserver observer; |
727 manager_->AddObserver(&observer); | 813 manager_->AddObserver(&observer); |
728 InitComponentExtension(); | 814 InitComponentExtension(); |
729 std::vector<std::string> keyboard_layouts; | 815 std::vector<std::string> keyboard_layouts; |
730 keyboard_layouts.push_back("xkb:us::eng"); | 816 keyboard_layouts.push_back("xkb:us::eng"); |
731 // For http://crbug.com/19655#c11 - (1) | 817 // For http://crbug.com/19655#c11 - (1) |
732 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 818 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
733 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 819 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
734 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 820 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
735 EXPECT_EQ("us", xkeyboard_->last_layout_); | 821 EXPECT_EQ("us", xkeyboard_->last_layout_); |
736 manager_->SwitchToNextInputMethod(); | 822 manager_->SwitchToNextInputMethod(); |
737 EXPECT_TRUE(observer.last_show_message_); | 823 EXPECT_TRUE(observer.last_show_message_); |
738 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 824 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
739 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 825 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
740 manager_->SwitchToNextInputMethod(); | 826 manager_->SwitchToNextInputMethod(); |
741 EXPECT_TRUE(observer.last_show_message_); | 827 EXPECT_TRUE(observer.last_show_message_); |
742 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 828 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), |
| 829 manager_->GetCurrentInputMethod().id()); |
743 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 830 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
744 manager_->SwitchToNextInputMethod(); | 831 manager_->SwitchToNextInputMethod(); |
745 EXPECT_TRUE(observer.last_show_message_); | 832 EXPECT_TRUE(observer.last_show_message_); |
746 EXPECT_EQ("xkb:us:dvorak:eng", manager_->GetCurrentInputMethod().id()); | 833 EXPECT_EQ(XkbId("xkb:us:dvorak:eng"), |
| 834 manager_->GetCurrentInputMethod().id()); |
747 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 835 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
748 manager_->SwitchToNextInputMethod(); | 836 manager_->SwitchToNextInputMethod(); |
749 EXPECT_TRUE(observer.last_show_message_); | 837 EXPECT_TRUE(observer.last_show_message_); |
750 EXPECT_EQ("xkb:us:colemak:eng", manager_->GetCurrentInputMethod().id()); | 838 EXPECT_EQ(XkbId("xkb:us:colemak:eng"), |
| 839 manager_->GetCurrentInputMethod().id()); |
751 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); | 840 EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
752 manager_->SwitchToNextInputMethod(); | 841 manager_->SwitchToNextInputMethod(); |
753 EXPECT_TRUE(observer.last_show_message_); | 842 EXPECT_TRUE(observer.last_show_message_); |
754 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 843 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
755 EXPECT_EQ("us", xkeyboard_->last_layout_); | 844 EXPECT_EQ("us", xkeyboard_->last_layout_); |
756 | 845 |
757 manager_->RemoveObserver(&observer); | 846 manager_->RemoveObserver(&observer); |
758 } | 847 } |
759 | 848 |
760 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 849 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
761 TestObserver observer; | 850 TestObserver observer; |
762 manager_->AddObserver(&observer); | 851 manager_->AddObserver(&observer); |
763 InitComponentExtension(); | 852 InitComponentExtension(); |
764 | 853 |
765 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 854 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
766 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 855 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
767 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 856 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
768 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 857 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
769 | 858 |
770 std::vector<std::string> keyboard_layouts; | 859 std::vector<std::string> keyboard_layouts; |
771 keyboard_layouts.push_back("xkb:us::eng"); | 860 keyboard_layouts.push_back("xkb:us::eng"); |
772 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 861 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
773 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 862 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
774 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 863 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
775 EXPECT_EQ("us", xkeyboard_->last_layout_); | 864 EXPECT_EQ("us", xkeyboard_->last_layout_); |
776 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 865 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
777 EXPECT_TRUE(observer.last_show_message_); | 866 EXPECT_TRUE(observer.last_show_message_); |
778 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 867 EXPECT_EQ(XkbId("xkb:us:intl:eng"), |
| 868 manager_->GetCurrentInputMethod().id()); |
779 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 869 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
780 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 870 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
781 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 871 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
782 EXPECT_TRUE(observer.last_show_message_); | 872 EXPECT_TRUE(observer.last_show_message_); |
783 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 873 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
784 EXPECT_EQ("us", xkeyboard_->last_layout_); | 874 EXPECT_EQ("us", xkeyboard_->last_layout_); |
785 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 875 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
786 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 876 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
787 EXPECT_TRUE(observer.last_show_message_); | 877 EXPECT_TRUE(observer.last_show_message_); |
788 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 878 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
789 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 879 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
790 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 880 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
791 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 881 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
792 EXPECT_TRUE(observer.last_show_message_); | 882 EXPECT_TRUE(observer.last_show_message_); |
793 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 883 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
794 EXPECT_EQ("us", xkeyboard_->last_layout_); | 884 EXPECT_EQ("us", xkeyboard_->last_layout_); |
795 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 885 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
796 EXPECT_TRUE(observer.last_show_message_); | 886 EXPECT_TRUE(observer.last_show_message_); |
797 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 887 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
798 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 888 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
799 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); | 889 EXPECT_TRUE(manager_->SwitchToNextInputMethod()); |
800 EXPECT_TRUE(observer.last_show_message_); | 890 EXPECT_TRUE(observer.last_show_message_); |
801 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 891 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), |
| 892 manager_->GetCurrentInputMethod().id()); |
802 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 893 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
803 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 894 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
804 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 895 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
805 EXPECT_TRUE(observer.last_show_message_); | 896 EXPECT_TRUE(observer.last_show_message_); |
806 EXPECT_EQ("xkb:us:intl:eng", manager_->GetCurrentInputMethod().id()); | 897 EXPECT_EQ(XkbId("xkb:us:intl:eng"), manager_->GetCurrentInputMethod().id()); |
807 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); | 898 EXPECT_EQ("us(intl)", xkeyboard_->last_layout_); |
808 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 899 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
809 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 900 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
810 EXPECT_TRUE(observer.last_show_message_); | 901 EXPECT_TRUE(observer.last_show_message_); |
811 EXPECT_EQ("xkb:us:altgr-intl:eng", manager_->GetCurrentInputMethod().id()); | 902 EXPECT_EQ(XkbId("xkb:us:altgr-intl:eng"), |
| 903 manager_->GetCurrentInputMethod().id()); |
812 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); | 904 EXPECT_EQ("us(altgr-intl)", xkeyboard_->last_layout_); |
813 | 905 |
814 manager_->RemoveObserver(&observer); | 906 manager_->RemoveObserver(&observer); |
815 } | 907 } |
816 | 908 |
817 TEST_F(InputMethodManagerImplTest, | 909 TEST_F(InputMethodManagerImplTest, |
818 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { | 910 TestSwitchToPreviousInputMethodForOneActiveInputMethod) { |
819 TestObserver observer; | 911 TestObserver observer; |
820 manager_->AddObserver(&observer); | 912 manager_->AddObserver(&observer); |
821 InitComponentExtension(); | 913 InitComponentExtension(); |
(...skipping 10 matching lines...) Expand all Loading... |
832 | 924 |
833 // Ctrl+Space accelerator should not be consumed if there is only one active | 925 // Ctrl+Space accelerator should not be consumed if there is only one active |
834 // input method. | 926 // input method. |
835 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 927 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
836 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 928 EXPECT_FALSE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
837 | 929 |
838 manager_->RemoveObserver(&observer); | 930 manager_->RemoveObserver(&observer); |
839 } | 931 } |
840 | 932 |
841 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 933 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
| 934 std::string expect_id = XkbId("xkb:us::eng"); |
842 TestObserver observer; | 935 TestObserver observer; |
843 manager_->AddObserver(&observer); | 936 manager_->AddObserver(&observer); |
844 InitComponentExtension(); | 937 InitComponentExtension(); |
845 std::vector<std::string> keyboard_layouts; | 938 std::vector<std::string> keyboard_layouts; |
846 keyboard_layouts.push_back("xkb:us::eng"); | 939 keyboard_layouts.push_back("xkb:us::eng"); |
847 manager_->EnableLoginLayouts("en-US", keyboard_layouts); | 940 manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
848 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); | 941 EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
849 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 942 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
850 EXPECT_EQ("us", xkeyboard_->last_layout_); | 943 EXPECT_EQ("us", xkeyboard_->last_layout_); |
851 | 944 |
852 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 945 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
853 // and keyboards are enabled. | 946 // and keyboards are enabled. |
854 EXPECT_FALSE(manager_->SwitchInputMethod( | 947 EXPECT_FALSE(manager_->SwitchInputMethod( |
855 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 948 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
856 EXPECT_FALSE(observer.last_show_message_); | 949 EXPECT_FALSE(observer.last_show_message_); |
857 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 950 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
858 EXPECT_EQ("us", xkeyboard_->last_layout_); | 951 EXPECT_EQ("us", xkeyboard_->last_layout_); |
859 EXPECT_FALSE(manager_->SwitchInputMethod( | 952 EXPECT_FALSE(manager_->SwitchInputMethod( |
860 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 953 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
861 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 954 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
862 EXPECT_EQ("us", xkeyboard_->last_layout_); | 955 EXPECT_EQ("us", xkeyboard_->last_layout_); |
863 EXPECT_FALSE(manager_->SwitchInputMethod( | 956 EXPECT_FALSE(manager_->SwitchInputMethod( |
864 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 957 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
865 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 958 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
866 EXPECT_EQ("us", xkeyboard_->last_layout_); | 959 EXPECT_EQ("us", xkeyboard_->last_layout_); |
867 EXPECT_FALSE(manager_->SwitchInputMethod( | 960 EXPECT_FALSE(manager_->SwitchInputMethod( |
868 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 961 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
869 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 962 EXPECT_EQ(expect_id, manager_->GetCurrentInputMethod().id()); |
870 EXPECT_EQ("us", xkeyboard_->last_layout_); | 963 EXPECT_EQ("us", xkeyboard_->last_layout_); |
871 | 964 |
872 manager_->RemoveObserver(&observer); | 965 manager_->RemoveObserver(&observer); |
873 } | 966 } |
874 | 967 |
875 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { | 968 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
876 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. | 969 // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. |
877 InitComponentExtension(); | 970 InitComponentExtension(); |
878 | 971 |
879 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 972 ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
880 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); | 973 keydown_accelerator.set_type(ui::ET_KEY_PRESSED); |
881 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 974 ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
882 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); | 975 keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
883 | 976 |
884 std::vector<std::string> keyboard_layouts; | 977 std::vector<std::string> keyboard_layouts; |
885 keyboard_layouts.push_back("xkb:us::eng"); | 978 keyboard_layouts.push_back("xkb:us::eng"); |
886 manager_->EnableLoginLayouts("ja", keyboard_layouts); | 979 manager_->EnableLoginLayouts("ja", keyboard_layouts); |
887 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 980 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
888 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 981 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
889 EXPECT_EQ("us", xkeyboard_->last_layout_); | 982 EXPECT_EQ("us", xkeyboard_->last_layout_); |
890 EXPECT_TRUE(manager_->SwitchInputMethod( | 983 EXPECT_TRUE(manager_->SwitchInputMethod( |
891 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 984 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
892 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 985 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
893 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 986 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
894 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 987 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
895 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 988 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
896 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 989 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
897 EXPECT_EQ("us", xkeyboard_->last_layout_); | 990 EXPECT_EQ("us", xkeyboard_->last_layout_); |
898 EXPECT_TRUE(manager_->SwitchInputMethod( | 991 EXPECT_TRUE(manager_->SwitchInputMethod( |
899 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 992 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
900 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 993 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
901 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 994 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
902 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); | 995 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keydown_accelerator)); |
903 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); | 996 EXPECT_TRUE(manager_->SwitchToPreviousInputMethod(keyup_accelerator)); |
904 EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); | 997 EXPECT_EQ(XkbId("xkb:us::eng"), manager_->GetCurrentInputMethod().id()); |
905 EXPECT_EQ("us", xkeyboard_->last_layout_); | 998 EXPECT_EQ("us", xkeyboard_->last_layout_); |
906 EXPECT_TRUE(manager_->SwitchInputMethod( | 999 EXPECT_TRUE(manager_->SwitchInputMethod( |
907 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1000 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
908 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1001 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
909 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1002 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
910 } | 1003 } |
911 | 1004 |
912 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { | 1005 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { |
913 InitComponentExtension(); | 1006 InitComponentExtension(); |
914 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1007 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
915 std::vector<std::string> ids; | 1008 std::vector<std::string> ids; |
916 ids.push_back("xkb:jp::jpn"); | 1009 ids.push_back("xkb:jp::jpn"); |
917 ids.push_back(kNaclMozcJpId); | 1010 ids.push_back(kNaclMozcJpId); |
918 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1011 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
919 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1012 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
920 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1013 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
921 EXPECT_TRUE(manager_->SwitchInputMethod( | 1014 EXPECT_TRUE(manager_->SwitchInputMethod( |
922 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1015 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
923 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1016 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
924 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1017 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
925 EXPECT_TRUE(manager_->SwitchInputMethod( | 1018 EXPECT_TRUE(manager_->SwitchInputMethod( |
926 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); | 1019 ui::Accelerator(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE))); |
927 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1020 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
928 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1021 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
929 EXPECT_TRUE(manager_->SwitchInputMethod( | 1022 EXPECT_TRUE(manager_->SwitchInputMethod( |
930 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1023 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
931 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1024 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
932 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1025 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
933 EXPECT_TRUE(manager_->SwitchInputMethod( | 1026 EXPECT_TRUE(manager_->SwitchInputMethod( |
934 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1027 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
935 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1028 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
936 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1029 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
937 EXPECT_TRUE(manager_->SwitchInputMethod( | 1030 EXPECT_TRUE(manager_->SwitchInputMethod( |
938 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1031 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
939 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1032 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
940 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1033 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
941 EXPECT_TRUE(manager_->SwitchInputMethod( | 1034 EXPECT_TRUE(manager_->SwitchInputMethod( |
942 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1035 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
943 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1036 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
944 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1037 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
945 | 1038 |
946 // Add Dvorak. | 1039 // Add Dvorak. |
947 ids.push_back("xkb:us:dvorak:eng"); | 1040 ids.push_back("xkb:us:dvorak:eng"); |
948 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1041 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
949 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1042 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
950 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1043 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
951 EXPECT_TRUE(manager_->SwitchInputMethod( | 1044 EXPECT_TRUE(manager_->SwitchInputMethod( |
952 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1045 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
953 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1046 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
954 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1047 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
955 EXPECT_TRUE(manager_->SwitchInputMethod( | 1048 EXPECT_TRUE(manager_->SwitchInputMethod( |
956 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1049 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
957 EXPECT_EQ("xkb:jp::jpn", manager_->GetCurrentInputMethod().id()); | 1050 EXPECT_EQ(XkbId("xkb:jp::jpn"), manager_->GetCurrentInputMethod().id()); |
958 EXPECT_EQ("jp", xkeyboard_->last_layout_); | 1051 EXPECT_EQ("jp", xkeyboard_->last_layout_); |
959 } | 1052 } |
960 | 1053 |
961 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { | 1054 TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { |
962 TestObserver observer; | 1055 TestObserver observer; |
963 manager_->AddObserver(&observer); | 1056 manager_->AddObserver(&observer); |
964 InitComponentExtension(); | 1057 InitComponentExtension(); |
965 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1058 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
966 std::vector<std::string> ids; | 1059 std::vector<std::string> ids; |
967 ids.push_back("xkb:us:dvorak:eng"); | 1060 ids.push_back("xkb:us:dvorak:eng"); |
968 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1061 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
969 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1062 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
970 EXPECT_EQ(1, observer.input_method_changed_count_); | 1063 EXPECT_EQ(1, observer.input_method_changed_count_); |
971 EXPECT_EQ(ids[0], | 1064 EXPECT_EQ(XkbId(ids[0]), |
972 manager_->GetCurrentInputMethod().id()); | 1065 manager_->GetCurrentInputMethod().id()); |
973 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 1066 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
974 | 1067 |
975 // Add two Extension IMEs. | 1068 // Add two Extension IMEs. |
976 std::vector<std::string> layouts; | 1069 std::vector<std::string> layouts; |
977 layouts.push_back("us"); | 1070 layouts.push_back("us"); |
978 std::vector<std::string> languages; | 1071 std::vector<std::string> languages; |
979 languages.push_back("en-US"); | 1072 languages.push_back("en-US"); |
980 | 1073 |
981 const std::string ext1_id = | 1074 const std::string ext1_id = |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { | 1136 TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { |
1044 TestObserver observer; | 1137 TestObserver observer; |
1045 InitComponentExtension(); | 1138 InitComponentExtension(); |
1046 manager_->AddObserver(&observer); | 1139 manager_->AddObserver(&observer); |
1047 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1140 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1048 std::vector<std::string> ids; | 1141 std::vector<std::string> ids; |
1049 ids.push_back("xkb:us::eng"); | 1142 ids.push_back("xkb:us::eng"); |
1050 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1143 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1051 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1144 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1052 EXPECT_EQ(1, observer.input_method_changed_count_); | 1145 EXPECT_EQ(1, observer.input_method_changed_count_); |
1053 EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); | 1146 EXPECT_EQ(XkbId(ids[0]), manager_->GetCurrentInputMethod().id()); |
1054 EXPECT_EQ("us", xkeyboard_->last_layout_); | 1147 EXPECT_EQ("us", xkeyboard_->last_layout_); |
1055 | 1148 |
1056 // Add an Extension IME. | 1149 // Add an Extension IME. |
1057 std::vector<std::string> layouts; | 1150 std::vector<std::string> layouts; |
1058 layouts.push_back("us(dvorak)"); | 1151 layouts.push_back("us(dvorak)"); |
1059 std::vector<std::string> languages; | 1152 std::vector<std::string> languages; |
1060 languages.push_back("en-US"); | 1153 languages.push_back("en-US"); |
1061 | 1154 |
1062 const std::string ext_id = | 1155 const std::string ext_id = |
1063 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 1156 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
(...skipping 19 matching lines...) Expand all Loading... |
1083 | 1176 |
1084 // Switch to the IME. | 1177 // Switch to the IME. |
1085 manager_->SwitchToNextInputMethod(); | 1178 manager_->SwitchToNextInputMethod(); |
1086 EXPECT_EQ(3, observer.input_method_changed_count_); | 1179 EXPECT_EQ(3, observer.input_method_changed_count_); |
1087 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1180 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1088 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 1181 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
1089 | 1182 |
1090 // Lock the screen. This is for crosbug.com/27049. | 1183 // Lock the screen. This is for crosbug.com/27049. |
1091 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); | 1184 manager_->SetState(InputMethodManager::STATE_LOCK_SCREEN); |
1092 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME | 1185 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); // Qwerty. No Ext. IME |
1093 EXPECT_EQ("xkb:us::eng", | 1186 EXPECT_EQ(XkbId("xkb:us::eng"), |
1094 manager_->GetCurrentInputMethod().id()); | 1187 manager_->GetCurrentInputMethod().id()); |
1095 EXPECT_EQ("us", xkeyboard_->last_layout_); | 1188 EXPECT_EQ("us", xkeyboard_->last_layout_); |
1096 | 1189 |
1097 // Unlock the screen. | 1190 // Unlock the screen. |
1098 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1191 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1099 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1192 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1100 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1193 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1101 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); | 1194 EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); |
1102 { | 1195 { |
1103 // This is for crosbug.com/27052. | 1196 // This is for crosbug.com/27052. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 manager_->ChangeInputMethod(kNaclMozcJpId); | 1228 manager_->ChangeInputMethod(kNaclMozcJpId); |
1136 | 1229 |
1137 InitComponentExtension(); | 1230 InitComponentExtension(); |
1138 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); | 1231 EXPECT_EQ(kNaclMozcJpId, manager_->GetCurrentInputMethod().id()); |
1139 } | 1232 } |
1140 | 1233 |
1141 TEST_F(InputMethodManagerImplTest, | 1234 TEST_F(InputMethodManagerImplTest, |
1142 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { | 1235 ChangeInputMethodBeforeComponentExtensionInitialization_CompOneIME) { |
1143 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1236 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1144 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1237 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
1145 ime_list_[0].id, | 1238 ime_list_[1].id, |
1146 ime_list_[0].engines[0].engine_id); | 1239 ime_list_[1].engines[0].engine_id); |
1147 std::vector<std::string> ids; | 1240 std::vector<std::string> ids; |
1148 ids.push_back(ext_id); | 1241 ids.push_back(ext_id); |
1149 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1242 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1150 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1243 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1151 manager_->ChangeInputMethod(ext_id); | 1244 manager_->ChangeInputMethod(ext_id); |
1152 | 1245 |
1153 InitComponentExtension(); | 1246 InitComponentExtension(); |
1154 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1247 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1155 } | 1248 } |
1156 | 1249 |
1157 TEST_F(InputMethodManagerImplTest, | 1250 TEST_F(InputMethodManagerImplTest, |
1158 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { | 1251 ChangeInputMethodBeforeComponentExtensionInitialization_CompTwoIME) { |
1159 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1252 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1160 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1253 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
1161 ime_list_[0].id, | |
1162 ime_list_[0].engines[0].engine_id); | |
1163 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | |
1164 ime_list_[1].id, | 1254 ime_list_[1].id, |
1165 ime_list_[1].engines[0].engine_id); | 1255 ime_list_[1].engines[0].engine_id); |
| 1256 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1257 ime_list_[2].id, |
| 1258 ime_list_[2].engines[0].engine_id); |
1166 std::vector<std::string> ids; | 1259 std::vector<std::string> ids; |
1167 ids.push_back(ext_id1); | 1260 ids.push_back(ext_id1); |
1168 ids.push_back(ext_id2); | 1261 ids.push_back(ext_id2); |
1169 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1262 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1170 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1263 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1171 manager_->ChangeInputMethod(ext_id1); | 1264 manager_->ChangeInputMethod(ext_id1); |
1172 manager_->ChangeInputMethod(ext_id2); | 1265 manager_->ChangeInputMethod(ext_id2); |
1173 | 1266 |
1174 InitComponentExtension(); | 1267 InitComponentExtension(); |
1175 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1268 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
1176 } | 1269 } |
1177 | 1270 |
1178 TEST_F(InputMethodManagerImplTest, | 1271 TEST_F(InputMethodManagerImplTest, |
1179 ChangeInputMethod_ComponenteExtensionOneIME) { | 1272 ChangeInputMethod_ComponenteExtensionOneIME) { |
1180 InitComponentExtension(); | 1273 InitComponentExtension(); |
1181 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1274 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1182 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( | 1275 const std::string ext_id = extension_ime_util::GetComponentInputMethodID( |
1183 ime_list_[0].id, | 1276 ime_list_[1].id, |
1184 ime_list_[0].engines[0].engine_id); | 1277 ime_list_[1].engines[0].engine_id); |
1185 std::vector<std::string> ids; | 1278 std::vector<std::string> ids; |
1186 ids.push_back(ext_id); | 1279 ids.push_back(ext_id); |
1187 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1280 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1188 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1281 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
1189 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); | 1282 EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); |
1190 } | 1283 } |
1191 | 1284 |
1192 TEST_F(InputMethodManagerImplTest, | 1285 TEST_F(InputMethodManagerImplTest, |
1193 ChangeInputMethod_ComponenteExtensionTwoIME) { | 1286 ChangeInputMethod_ComponenteExtensionTwoIME) { |
1194 InitComponentExtension(); | 1287 InitComponentExtension(); |
1195 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 1288 manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
1196 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( | 1289 const std::string ext_id1 = extension_ime_util::GetComponentInputMethodID( |
1197 ime_list_[0].id, | |
1198 ime_list_[0].engines[0].engine_id); | |
1199 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( | |
1200 ime_list_[1].id, | 1290 ime_list_[1].id, |
1201 ime_list_[1].engines[0].engine_id); | 1291 ime_list_[1].engines[0].engine_id); |
| 1292 const std::string ext_id2 = extension_ime_util::GetComponentInputMethodID( |
| 1293 ime_list_[2].id, |
| 1294 ime_list_[2].engines[0].engine_id); |
1202 std::vector<std::string> ids; | 1295 std::vector<std::string> ids; |
1203 ids.push_back(ext_id1); | 1296 ids.push_back(ext_id1); |
1204 ids.push_back(ext_id2); | 1297 ids.push_back(ext_id2); |
1205 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); | 1298 EXPECT_TRUE(manager_->ReplaceEnabledInputMethods(ids)); |
1206 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1299 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
1207 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1300 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); |
1208 manager_->ChangeInputMethod(ext_id2); | 1301 manager_->ChangeInputMethod(ext_id2); |
1209 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1302 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
1210 } | 1303 } |
1211 | 1304 |
| 1305 TEST_F(InputMethodManagerImplTest, MigrateXkbInputMethodTest) { |
| 1306 std::vector<std::string> input_method_ids; |
| 1307 input_method_ids.push_back("xkb:us::eng"); |
| 1308 input_method_ids.push_back("xkb:fr::fra"); |
| 1309 input_method_ids.push_back( |
| 1310 "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng"); |
| 1311 input_method_ids.push_back("xkb:fr::fra"); |
| 1312 input_method_ids.push_back("_comp_ime_asdf_pinyin"); |
| 1313 |
| 1314 manager_->MigrateXkbInputMethods(&input_method_ids); |
| 1315 |
| 1316 ASSERT_EQ(3U, input_method_ids.size()); |
| 1317 |
| 1318 EXPECT_EQ(XkbId("xkb:us::eng"), input_method_ids[0]); |
| 1319 EXPECT_EQ(XkbId("xkb:fr::fra"), input_method_ids[1]); |
| 1320 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
| 1321 } |
| 1322 |
1212 } // namespace input_method | 1323 } // namespace input_method |
1213 } // namespace chromeos | 1324 } // namespace chromeos |
OLD | NEW |