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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 ext_xkb_engine_altgr_intl.layouts.push_back("us(altgr-intl)"); | 221 ext_xkb_engine_altgr_intl.layouts.push_back("us(altgr-intl)"); |
222 ext_xkb.engines.push_back(ext_xkb_engine_altgr_intl); | 222 ext_xkb.engines.push_back(ext_xkb_engine_altgr_intl); |
223 | 223 |
224 ComponentExtensionEngine ext_xkb_engine_dvorak; | 224 ComponentExtensionEngine ext_xkb_engine_dvorak; |
225 ext_xkb_engine_dvorak.engine_id = "xkb:us:dvorak:eng"; | 225 ext_xkb_engine_dvorak.engine_id = "xkb:us:dvorak:eng"; |
226 ext_xkb_engine_dvorak.display_name = "xkb:us:dvorak:eng"; | 226 ext_xkb_engine_dvorak.display_name = "xkb:us:dvorak:eng"; |
227 ext_xkb_engine_dvorak.language_codes.push_back("en-US"); | 227 ext_xkb_engine_dvorak.language_codes.push_back("en-US"); |
228 ext_xkb_engine_dvorak.layouts.push_back("us(dvorak)"); | 228 ext_xkb_engine_dvorak.layouts.push_back("us(dvorak)"); |
229 ext_xkb.engines.push_back(ext_xkb_engine_dvorak); | 229 ext_xkb.engines.push_back(ext_xkb_engine_dvorak); |
230 | 230 |
| 231 ComponentExtensionEngine ext_xkb_engine_dvp; |
| 232 ext_xkb_engine_dvp.engine_id = "xkb:us:dvp:eng"; |
| 233 ext_xkb_engine_dvp.display_name = "xkb:us:dvp:eng"; |
| 234 ext_xkb_engine_dvp.language_codes.push_back("en-US"); |
| 235 ext_xkb_engine_dvp.layouts.push_back("us(dvp)"); |
| 236 ext_xkb.engines.push_back(ext_xkb_engine_dvp); |
| 237 |
231 ComponentExtensionEngine ext_xkb_engine_colemak; | 238 ComponentExtensionEngine ext_xkb_engine_colemak; |
232 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; | 239 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; |
233 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; | 240 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; |
234 ext_xkb_engine_colemak.language_codes.push_back("en-US"); | 241 ext_xkb_engine_colemak.language_codes.push_back("en-US"); |
235 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); | 242 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); |
236 ext_xkb.engines.push_back(ext_xkb_engine_colemak); | 243 ext_xkb.engines.push_back(ext_xkb_engine_colemak); |
237 | 244 |
238 ComponentExtensionEngine ext_xkb_engine_fr; | 245 ComponentExtensionEngine ext_xkb_engine_fr; |
239 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; | 246 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; |
240 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; | 247 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // also for the scenario. | 366 // also for the scenario. |
360 std::vector<std::string> keyboard_layouts; | 367 std::vector<std::string> keyboard_layouts; |
361 keyboard_layouts.push_back("xkb:us::eng"); | 368 keyboard_layouts.push_back("xkb:us::eng"); |
362 | 369 |
363 TestObserver observer; | 370 TestObserver observer; |
364 InitComponentExtension(); | 371 InitComponentExtension(); |
365 manager_->AddObserver(&observer); | 372 manager_->AddObserver(&observer); |
366 menu_manager_->AddObserver(&observer); | 373 menu_manager_->AddObserver(&observer); |
367 EXPECT_EQ(0, observer.input_method_changed_count_); | 374 EXPECT_EQ(0, observer.input_method_changed_count_); |
368 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 375 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
369 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetActiveInputMethods()->size()); | 376 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetActiveInputMethods()->size()); |
370 EXPECT_EQ(1, observer.input_method_changed_count_); | 377 EXPECT_EQ(1, observer.input_method_changed_count_); |
371 // Menu change is triggered only if current input method was actually changed. | 378 // Menu change is triggered only if current input method was actually changed. |
372 EXPECT_EQ(0, observer.input_method_menu_item_changed_count_); | 379 EXPECT_EQ(0, observer.input_method_menu_item_changed_count_); |
373 manager_->GetActiveIMEState()->ChangeInputMethod( | 380 manager_->GetActiveIMEState()->ChangeInputMethod( |
374 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); | 381 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
375 EXPECT_FALSE(observer.last_show_message_); | 382 EXPECT_FALSE(observer.last_show_message_); |
376 EXPECT_EQ(2, observer.input_method_changed_count_); | 383 EXPECT_EQ(2, observer.input_method_changed_count_); |
377 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); | 384 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
378 manager_->GetActiveIMEState()->ChangeInputMethod( | 385 manager_->GetActiveIMEState()->ChangeInputMethod( |
379 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); | 386 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
(...skipping 27 matching lines...) Expand all Loading... |
407 EXPECT_TRUE(Contain(methods, *id_to_find)); | 414 EXPECT_TRUE(Contain(methods, *id_to_find)); |
408 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 415 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
409 ImeIdFromEngineId("xkb:us:dvorak:eng")); | 416 ImeIdFromEngineId("xkb:us:dvorak:eng")); |
410 EXPECT_TRUE(Contain(methods, *id_to_find)); | 417 EXPECT_TRUE(Contain(methods, *id_to_find)); |
411 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 418 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
412 ImeIdFromEngineId("xkb:fr::fra")); | 419 ImeIdFromEngineId("xkb:fr::fra")); |
413 EXPECT_TRUE(Contain(methods, *id_to_find)); | 420 EXPECT_TRUE(Contain(methods, *id_to_find)); |
414 } | 421 } |
415 | 422 |
416 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 423 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
417 // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See | 424 // Currently 6 keyboard layouts are supported for en-US, and 1 for ja. See |
418 // ibus_input_method.txt. | 425 // ibus_input_method.txt. |
419 std::vector<std::string> keyboard_layouts; | 426 std::vector<std::string> keyboard_layouts; |
420 | 427 |
421 InitComponentExtension(); | 428 InitComponentExtension(); |
422 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 429 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
423 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 430 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
424 | 431 |
425 // For http://crbug.com/19655#c11 - (5) | 432 // For http://crbug.com/19655#c11 - (5) |
426 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 433 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
427 manager_->GetActiveIMEState()->EnableLoginLayouts( | 434 manager_->GetActiveIMEState()->EnableLoginLayouts( |
428 "ja", keyboard_layouts); // Japanese | 435 "ja", keyboard_layouts); // Japanese |
429 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 436 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
430 } | 437 } |
431 | 438 |
432 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 439 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
433 // For http://crbug.com/329061 | 440 // For http://crbug.com/329061 |
434 std::vector<std::string> keyboard_layouts; | 441 std::vector<std::string> keyboard_layouts; |
435 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); | 442 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); |
436 | 443 |
437 InitComponentExtension(); | 444 InitComponentExtension(); |
438 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 445 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
439 const std::string im_id = | 446 const std::string im_id = |
440 manager_->GetActiveIMEState()->GetCurrentInputMethod().id(); | 447 manager_->GetActiveIMEState()->GetCurrentInputMethod().id(); |
441 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); | 448 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); |
442 } | 449 } |
443 | 450 |
444 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 451 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
445 InitComponentExtension(); | 452 InitComponentExtension(); |
446 // The physical layout is French. | 453 // The physical layout is French. |
447 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 454 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
448 "xkb:fr::fra"); | 455 "xkb:fr::fra"); |
449 manager_->GetActiveIMEState()->EnableLoginLayouts( | 456 manager_->GetActiveIMEState()->EnableLoginLayouts( |
450 "en-US", | 457 "en-US", |
451 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 458 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
452 EXPECT_EQ( | 459 EXPECT_EQ( |
453 6U, | 460 7U, |
454 manager_->GetActiveIMEState()->GetNumActiveInputMethods()); // 5 + French | 461 manager_->GetActiveIMEState()->GetNumActiveInputMethods()); // 6 + French |
455 // The physical layout is Japanese. | 462 // The physical layout is Japanese. |
456 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 463 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
457 "xkb:jp::jpn"); | 464 "xkb:jp::jpn"); |
458 manager_->GetActiveIMEState()->EnableLoginLayouts( | 465 manager_->GetActiveIMEState()->EnableLoginLayouts( |
459 "ja", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 466 "ja", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
460 // "xkb:us::eng" is not needed, hence 1. | 467 // "xkb:us::eng" is not needed, hence 1. |
461 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 468 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
462 | 469 |
463 // The physical layout is Russian. | 470 // The physical layout is Russian. |
464 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 471 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
465 "xkb:ru::rus"); | 472 "xkb:ru::rus"); |
466 manager_->GetActiveIMEState()->EnableLoginLayouts( | 473 manager_->GetActiveIMEState()->EnableLoginLayouts( |
467 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 474 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
468 // "xkb:us::eng" only. | 475 // "xkb:us::eng" only. |
469 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 476 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
470 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 477 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
471 manager_->GetActiveIMEState()->GetActiveInputMethodIds().front()); | 478 manager_->GetActiveIMEState()->GetActiveInputMethodIds().front()); |
472 } | 479 } |
473 | 480 |
474 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { | 481 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
475 InitComponentExtension(); | 482 InitComponentExtension(); |
476 // The physical layouts are French and Hungarian. | 483 // The physical layouts are French and Hungarian. |
477 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 484 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
478 "xkb:fr::fra,xkb:hu::hun"); | 485 "xkb:fr::fra,xkb:hu::hun"); |
479 manager_->GetActiveIMEState()->EnableLoginLayouts( | 486 manager_->GetActiveIMEState()->EnableLoginLayouts( |
480 "en-US", | 487 "en-US", |
481 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 488 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
482 // 5 + French + Hungarian | 489 // 6 + French + Hungarian |
483 EXPECT_EQ(7U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 490 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
484 } | 491 } |
485 | 492 |
486 TEST_F(InputMethodManagerImplTest, | 493 TEST_F(InputMethodManagerImplTest, |
487 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { | 494 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
488 InitComponentExtension(); | 495 InitComponentExtension(); |
489 // The physical layouts are English (US) and Russian. | 496 // The physical layouts are English (US) and Russian. |
490 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 497 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
491 "xkb:us::eng,xkb:ru::rus"); | 498 "xkb:us::eng,xkb:ru::rus"); |
492 manager_->GetActiveIMEState()->EnableLoginLayouts( | 499 manager_->GetActiveIMEState()->EnableLoginLayouts( |
493 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 500 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 } | 891 } |
885 | 892 |
886 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 893 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
887 TestObserver observer; | 894 TestObserver observer; |
888 InitComponentExtension(); | 895 InitComponentExtension(); |
889 manager_->AddObserver(&observer); | 896 manager_->AddObserver(&observer); |
890 std::vector<std::string> keyboard_layouts; | 897 std::vector<std::string> keyboard_layouts; |
891 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 898 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
892 // For http://crbug.com/19655#c11 - (1) | 899 // For http://crbug.com/19655#c11 - (1) |
893 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 900 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
894 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 901 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
895 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 902 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
896 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 903 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
897 EXPECT_EQ("us", keyboard_->last_layout_); | 904 EXPECT_EQ("us", keyboard_->last_layout_); |
898 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 905 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
899 EXPECT_TRUE(observer.last_show_message_); | 906 EXPECT_TRUE(observer.last_show_message_); |
900 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 907 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
901 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 908 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
902 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 909 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
903 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 910 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
904 EXPECT_TRUE(observer.last_show_message_); | 911 EXPECT_TRUE(observer.last_show_message_); |
905 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), | 912 EXPECT_EQ(ImeIdFromEngineId("xkb:us:altgr-intl:eng"), |
906 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 913 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
907 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); | 914 EXPECT_EQ("us(altgr-intl)", keyboard_->last_layout_); |
908 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 915 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
909 EXPECT_TRUE(observer.last_show_message_); | 916 EXPECT_TRUE(observer.last_show_message_); |
910 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), | 917 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvorak:eng"), |
911 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 918 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
912 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); | 919 EXPECT_EQ("us(dvorak)", keyboard_->last_layout_); |
913 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 920 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
914 EXPECT_TRUE(observer.last_show_message_); | 921 EXPECT_TRUE(observer.last_show_message_); |
| 922 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvp:eng"), |
| 923 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
| 924 EXPECT_EQ("us(dvp)", keyboard_->last_layout_); |
| 925 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
| 926 EXPECT_TRUE(observer.last_show_message_); |
915 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), | 927 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), |
916 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 928 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
917 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 929 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
918 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 930 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
919 EXPECT_TRUE(observer.last_show_message_); | 931 EXPECT_TRUE(observer.last_show_message_); |
920 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 932 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
921 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 933 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
922 EXPECT_EQ("us", keyboard_->last_layout_); | 934 EXPECT_EQ("us", keyboard_->last_layout_); |
923 | 935 |
924 manager_->RemoveObserver(&observer); | 936 manager_->RemoveObserver(&observer); |
925 } | 937 } |
926 | 938 |
927 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 939 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
928 TestObserver observer; | 940 TestObserver observer; |
929 InitComponentExtension(); | 941 InitComponentExtension(); |
930 manager_->AddObserver(&observer); | 942 manager_->AddObserver(&observer); |
931 | 943 |
932 std::vector<std::string> keyboard_layouts; | 944 std::vector<std::string> keyboard_layouts; |
933 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 945 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
934 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 946 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
935 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 947 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
936 EXPECT_TRUE(manager_->GetActiveIMEState()->CanCycleInputMethod()); | 948 EXPECT_TRUE(manager_->GetActiveIMEState()->CanCycleInputMethod()); |
937 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 949 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
938 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 950 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
939 EXPECT_EQ("us", keyboard_->last_layout_); | 951 EXPECT_EQ("us", keyboard_->last_layout_); |
940 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 952 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
941 EXPECT_TRUE(observer.last_show_message_); | 953 EXPECT_TRUE(observer.last_show_message_); |
942 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 954 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
943 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 955 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
944 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 956 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
945 manager_->GetActiveIMEState()->SwitchToPreviousInputMethod(); | 957 manager_->GetActiveIMEState()->SwitchToPreviousInputMethod(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 EXPECT_FALSE(manager_->GetActiveIMEState()->CanCycleInputMethod()); | 1009 EXPECT_FALSE(manager_->GetActiveIMEState()->CanCycleInputMethod()); |
998 | 1010 |
999 manager_->RemoveObserver(&observer); | 1011 manager_->RemoveObserver(&observer); |
1000 } | 1012 } |
1001 | 1013 |
1002 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 1014 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
1003 InitComponentExtension(); | 1015 InitComponentExtension(); |
1004 std::vector<std::string> keyboard_layouts; | 1016 std::vector<std::string> keyboard_layouts; |
1005 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1017 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1006 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 1018 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
1007 EXPECT_EQ(5U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 1019 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1008 | 1020 |
1009 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 1021 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
1010 // and keyboards are enabled. | 1022 // and keyboards are enabled. |
1011 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1023 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1012 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1024 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1013 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1025 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1014 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1026 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1015 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1027 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1016 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1028 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1017 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1029 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 ASSERT_EQ(4U, input_method_ids.size()); | 1373 ASSERT_EQ(4U, input_method_ids.size()); |
1362 | 1374 |
1363 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1375 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
1364 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1376 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
1365 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1377 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1366 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1378 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
1367 } | 1379 } |
1368 | 1380 |
1369 } // namespace input_method | 1381 } // namespace input_method |
1370 } // namespace chromeos | 1382 } // namespace chromeos |
OLD | NEW |