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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 ext_xkb_engine_dvp.layouts.push_back("us(dvp)"); | 239 ext_xkb_engine_dvp.layouts.push_back("us(dvp)"); |
240 ext_xkb.engines.push_back(ext_xkb_engine_dvp); | 240 ext_xkb.engines.push_back(ext_xkb_engine_dvp); |
241 | 241 |
242 ComponentExtensionEngine ext_xkb_engine_colemak; | 242 ComponentExtensionEngine ext_xkb_engine_colemak; |
243 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; | 243 ext_xkb_engine_colemak.engine_id = "xkb:us:colemak:eng"; |
244 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; | 244 ext_xkb_engine_colemak.display_name = "xkb:us:colemak:eng"; |
245 ext_xkb_engine_colemak.language_codes.push_back("en-US"); | 245 ext_xkb_engine_colemak.language_codes.push_back("en-US"); |
246 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); | 246 ext_xkb_engine_colemak.layouts.push_back("us(colemak)"); |
247 ext_xkb.engines.push_back(ext_xkb_engine_colemak); | 247 ext_xkb.engines.push_back(ext_xkb_engine_colemak); |
248 | 248 |
| 249 ComponentExtensionEngine ext_xkb_engine_workman; |
| 250 ext_xkb_engine_workman.engine_id = "xkb:us:workman:eng"; |
| 251 ext_xkb_engine_workman.display_name = "xkb:us:workman:eng"; |
| 252 ext_xkb_engine_workman.language_codes.push_back("en-US"); |
| 253 ext_xkb_engine_workman.layouts.push_back("us(workman)"); |
| 254 ext_xkb.engines.push_back(ext_xkb_engine_workman); |
| 255 |
| 256 ComponentExtensionEngine ext_xkb_engine_workman_intl; |
| 257 ext_xkb_engine_workman_intl.engine_id = "xkb:us:workman-intl:eng"; |
| 258 ext_xkb_engine_workman_intl.display_name = "xkb:us:workman-intl:eng"; |
| 259 ext_xkb_engine_workman_intl.language_codes.push_back("en-US"); |
| 260 ext_xkb_engine_workman_intl.layouts.push_back("us(workman-intl)"); |
| 261 ext_xkb.engines.push_back(ext_xkb_engine_workman_intl); |
| 262 |
249 ComponentExtensionEngine ext_xkb_engine_fr; | 263 ComponentExtensionEngine ext_xkb_engine_fr; |
250 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; | 264 ext_xkb_engine_fr.engine_id = "xkb:fr::fra"; |
251 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; | 265 ext_xkb_engine_fr.display_name = "xkb:fr::fra"; |
252 ext_xkb_engine_fr.language_codes.push_back("fr"); | 266 ext_xkb_engine_fr.language_codes.push_back("fr"); |
253 ext_xkb_engine_fr.layouts.push_back("fr"); | 267 ext_xkb_engine_fr.layouts.push_back("fr"); |
254 ext_xkb.engines.push_back(ext_xkb_engine_fr); | 268 ext_xkb.engines.push_back(ext_xkb_engine_fr); |
255 | 269 |
256 ComponentExtensionEngine ext_xkb_engine_se; | 270 ComponentExtensionEngine ext_xkb_engine_se; |
257 ext_xkb_engine_se.engine_id = "xkb:se::swe"; | 271 ext_xkb_engine_se.engine_id = "xkb:se::swe"; |
258 ext_xkb_engine_se.display_name = "xkb:se::swe"; | 272 ext_xkb_engine_se.display_name = "xkb:se::swe"; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // also for the scenario. | 384 // also for the scenario. |
371 std::vector<std::string> keyboard_layouts; | 385 std::vector<std::string> keyboard_layouts; |
372 keyboard_layouts.push_back("xkb:us::eng"); | 386 keyboard_layouts.push_back("xkb:us::eng"); |
373 | 387 |
374 TestObserver observer; | 388 TestObserver observer; |
375 InitComponentExtension(); | 389 InitComponentExtension(); |
376 manager_->AddObserver(&observer); | 390 manager_->AddObserver(&observer); |
377 menu_manager_->AddObserver(&observer); | 391 menu_manager_->AddObserver(&observer); |
378 EXPECT_EQ(0, observer.input_method_changed_count_); | 392 EXPECT_EQ(0, observer.input_method_changed_count_); |
379 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 393 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
380 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetActiveInputMethods()->size()); | 394 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetActiveInputMethods()->size()); |
381 EXPECT_EQ(1, observer.input_method_changed_count_); | 395 EXPECT_EQ(1, observer.input_method_changed_count_); |
382 // Menu change is triggered only if current input method was actually changed. | 396 // Menu change is triggered only if current input method was actually changed. |
383 EXPECT_EQ(0, observer.input_method_menu_item_changed_count_); | 397 EXPECT_EQ(0, observer.input_method_menu_item_changed_count_); |
384 manager_->GetActiveIMEState()->ChangeInputMethod( | 398 manager_->GetActiveIMEState()->ChangeInputMethod( |
385 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); | 399 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
386 EXPECT_FALSE(observer.last_show_message_); | 400 EXPECT_FALSE(observer.last_show_message_); |
387 EXPECT_EQ(2, observer.input_method_changed_count_); | 401 EXPECT_EQ(2, observer.input_method_changed_count_); |
388 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); | 402 EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
389 manager_->GetActiveIMEState()->ChangeInputMethod( | 403 manager_->GetActiveIMEState()->ChangeInputMethod( |
390 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); | 404 ImeIdFromEngineId("xkb:us:dvorak:eng"), false /* show_message */); |
(...skipping 27 matching lines...) Expand all Loading... |
418 EXPECT_TRUE(Contain(methods, *id_to_find)); | 432 EXPECT_TRUE(Contain(methods, *id_to_find)); |
419 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 433 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
420 ImeIdFromEngineId("xkb:us:dvorak:eng")); | 434 ImeIdFromEngineId("xkb:us:dvorak:eng")); |
421 EXPECT_TRUE(Contain(methods, *id_to_find)); | 435 EXPECT_TRUE(Contain(methods, *id_to_find)); |
422 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( | 436 id_to_find = manager_->GetInputMethodUtil()->GetInputMethodDescriptorFromId( |
423 ImeIdFromEngineId("xkb:fr::fra")); | 437 ImeIdFromEngineId("xkb:fr::fra")); |
424 EXPECT_TRUE(Contain(methods, *id_to_find)); | 438 EXPECT_TRUE(Contain(methods, *id_to_find)); |
425 } | 439 } |
426 | 440 |
427 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { | 441 TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
428 // Currently 6 keyboard layouts are supported for en-US, and 1 for ja. See | 442 // Currently 8 keyboard layouts are supported for en-US, and 1 for ja. See |
429 // ibus_input_method.txt. | 443 // ibus_input_method.txt. |
430 std::vector<std::string> keyboard_layouts; | 444 std::vector<std::string> keyboard_layouts; |
431 | 445 |
432 InitComponentExtension(); | 446 InitComponentExtension(); |
433 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 447 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
434 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 448 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
435 | 449 |
436 // For http://crbug.com/19655#c11 - (5) | 450 // For http://crbug.com/19655#c11 - (5) |
437 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. | 451 // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
438 manager_->GetActiveIMEState()->EnableLoginLayouts( | 452 manager_->GetActiveIMEState()->EnableLoginLayouts( |
439 "ja", keyboard_layouts); // Japanese | 453 "ja", keyboard_layouts); // Japanese |
440 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 454 EXPECT_EQ(2U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
441 } | 455 } |
442 | 456 |
443 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { | 457 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
444 // For http://crbug.com/329061 | 458 // For http://crbug.com/329061 |
445 std::vector<std::string> keyboard_layouts; | 459 std::vector<std::string> keyboard_layouts; |
446 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); | 460 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:se::swe")); |
447 | 461 |
448 InitComponentExtension(); | 462 InitComponentExtension(); |
449 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 463 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
450 const std::string im_id = | 464 const std::string im_id = |
451 manager_->GetActiveIMEState()->GetCurrentInputMethod().id(); | 465 manager_->GetActiveIMEState()->GetCurrentInputMethod().id(); |
452 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); | 466 EXPECT_EQ(ImeIdFromEngineId("xkb:se::swe"), im_id); |
453 } | 467 } |
454 | 468 |
455 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { | 469 TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
456 InitComponentExtension(); | 470 InitComponentExtension(); |
457 // The physical layout is French. | 471 // The physical layout is French. |
458 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 472 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
459 "xkb:fr::fra"); | 473 "xkb:fr::fra"); |
460 manager_->GetActiveIMEState()->EnableLoginLayouts( | 474 manager_->GetActiveIMEState()->EnableLoginLayouts( |
461 "en-US", | 475 "en-US", |
462 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 476 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
463 EXPECT_EQ( | 477 EXPECT_EQ( |
464 7U, | 478 9U, |
465 manager_->GetActiveIMEState()->GetNumActiveInputMethods()); // 6 + French | 479 manager_->GetActiveIMEState()->GetNumActiveInputMethods()); // 8 + French |
466 // The physical layout is Japanese. | 480 // The physical layout is Japanese. |
467 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 481 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
468 "xkb:jp::jpn"); | 482 "xkb:jp::jpn"); |
469 manager_->GetActiveIMEState()->EnableLoginLayouts( | 483 manager_->GetActiveIMEState()->EnableLoginLayouts( |
470 "ja", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 484 "ja", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
471 // "xkb:us::eng" is not needed, hence 1. | 485 // "xkb:us::eng" is not needed, hence 1. |
472 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 486 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
473 | 487 |
474 // The physical layout is Russian. | 488 // The physical layout is Russian. |
475 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 489 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
476 "xkb:ru::rus"); | 490 "xkb:ru::rus"); |
477 manager_->GetActiveIMEState()->EnableLoginLayouts( | 491 manager_->GetActiveIMEState()->EnableLoginLayouts( |
478 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 492 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
479 // "xkb:us::eng" only. | 493 // "xkb:us::eng" only. |
480 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 494 EXPECT_EQ(1U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
481 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 495 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
482 manager_->GetActiveIMEState()->GetActiveInputMethodIds().front()); | 496 manager_->GetActiveIMEState()->GetActiveInputMethodIds().front()); |
483 } | 497 } |
484 | 498 |
485 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { | 499 TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
486 InitComponentExtension(); | 500 InitComponentExtension(); |
487 // The physical layouts are French and Hungarian. | 501 // The physical layouts are French and Hungarian. |
488 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 502 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
489 "xkb:fr::fra,xkb:hu::hun"); | 503 "xkb:fr::fra,xkb:hu::hun"); |
490 manager_->GetActiveIMEState()->EnableLoginLayouts( | 504 manager_->GetActiveIMEState()->EnableLoginLayouts( |
491 "en-US", | 505 "en-US", |
492 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 506 manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
493 // 6 + French + Hungarian | 507 // 8 + French + Hungarian |
494 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 508 EXPECT_EQ(10U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
495 } | 509 } |
496 | 510 |
497 TEST_F(InputMethodManagerImplTest, | 511 TEST_F(InputMethodManagerImplTest, |
498 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { | 512 TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
499 InitComponentExtension(); | 513 InitComponentExtension(); |
500 // The physical layouts are English (US) and Russian. | 514 // The physical layouts are English (US) and Russian. |
501 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( | 515 manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting( |
502 "xkb:us::eng,xkb:ru::rus"); | 516 "xkb:us::eng,xkb:ru::rus"); |
503 manager_->GetActiveIMEState()->EnableLoginLayouts( | 517 manager_->GetActiveIMEState()->EnableLoginLayouts( |
504 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); | 518 "ru", manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds()); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 } | 909 } |
896 | 910 |
897 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { | 911 TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
898 TestObserver observer; | 912 TestObserver observer; |
899 InitComponentExtension(); | 913 InitComponentExtension(); |
900 manager_->AddObserver(&observer); | 914 manager_->AddObserver(&observer); |
901 std::vector<std::string> keyboard_layouts; | 915 std::vector<std::string> keyboard_layouts; |
902 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 916 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
903 // For http://crbug.com/19655#c11 - (1) | 917 // For http://crbug.com/19655#c11 - (1) |
904 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 918 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
905 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 919 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
906 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 920 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
907 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 921 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
908 EXPECT_EQ("us", keyboard_->last_layout_); | 922 EXPECT_EQ("us", keyboard_->last_layout_); |
909 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 923 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
910 EXPECT_TRUE(observer.last_show_message_); | 924 EXPECT_TRUE(observer.last_show_message_); |
911 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 925 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
912 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 926 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
913 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 927 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
914 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 928 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
915 EXPECT_TRUE(observer.last_show_message_); | 929 EXPECT_TRUE(observer.last_show_message_); |
(...skipping 10 matching lines...) Expand all Loading... |
926 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvp:eng"), | 940 EXPECT_EQ(ImeIdFromEngineId("xkb:us:dvp:eng"), |
927 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 941 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
928 EXPECT_EQ("us(dvp)", keyboard_->last_layout_); | 942 EXPECT_EQ("us(dvp)", keyboard_->last_layout_); |
929 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 943 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
930 EXPECT_TRUE(observer.last_show_message_); | 944 EXPECT_TRUE(observer.last_show_message_); |
931 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), | 945 EXPECT_EQ(ImeIdFromEngineId("xkb:us:colemak:eng"), |
932 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 946 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
933 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); | 947 EXPECT_EQ("us(colemak)", keyboard_->last_layout_); |
934 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 948 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
935 EXPECT_TRUE(observer.last_show_message_); | 949 EXPECT_TRUE(observer.last_show_message_); |
| 950 EXPECT_EQ(ImeIdFromEngineId("xkb:us:workman:eng"), |
| 951 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
| 952 EXPECT_EQ("us(workman)", keyboard_->last_layout_); |
| 953 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
| 954 EXPECT_TRUE(observer.last_show_message_); |
| 955 EXPECT_EQ(ImeIdFromEngineId("xkb:us:workman-intl:eng"), |
| 956 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
| 957 EXPECT_EQ("us(workman-intl)", keyboard_->last_layout_); |
| 958 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
| 959 EXPECT_TRUE(observer.last_show_message_); |
936 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 960 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
937 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 961 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
938 EXPECT_EQ("us", keyboard_->last_layout_); | 962 EXPECT_EQ("us", keyboard_->last_layout_); |
939 | 963 |
940 manager_->RemoveObserver(&observer); | 964 manager_->RemoveObserver(&observer); |
941 } | 965 } |
942 | 966 |
943 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { | 967 TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
944 TestObserver observer; | 968 TestObserver observer; |
945 InitComponentExtension(); | 969 InitComponentExtension(); |
946 manager_->AddObserver(&observer); | 970 manager_->AddObserver(&observer); |
947 | 971 |
948 std::vector<std::string> keyboard_layouts; | 972 std::vector<std::string> keyboard_layouts; |
949 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 973 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
950 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 974 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
951 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 975 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
952 EXPECT_TRUE(manager_->GetActiveIMEState()->CanCycleInputMethod()); | 976 EXPECT_TRUE(manager_->GetActiveIMEState()->CanCycleInputMethod()); |
953 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), | 977 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), |
954 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 978 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
955 EXPECT_EQ("us", keyboard_->last_layout_); | 979 EXPECT_EQ("us", keyboard_->last_layout_); |
956 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); | 980 manager_->GetActiveIMEState()->SwitchToNextInputMethod(); |
957 EXPECT_TRUE(observer.last_show_message_); | 981 EXPECT_TRUE(observer.last_show_message_); |
958 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), | 982 EXPECT_EQ(ImeIdFromEngineId("xkb:us:intl:eng"), |
959 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); | 983 manager_->GetActiveIMEState()->GetCurrentInputMethod().id()); |
960 EXPECT_EQ("us(intl)", keyboard_->last_layout_); | 984 EXPECT_EQ("us(intl)", keyboard_->last_layout_); |
961 manager_->GetActiveIMEState()->SwitchToPreviousInputMethod(); | 985 manager_->GetActiveIMEState()->SwitchToPreviousInputMethod(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 EXPECT_FALSE(manager_->GetActiveIMEState()->CanCycleInputMethod()); | 1037 EXPECT_FALSE(manager_->GetActiveIMEState()->CanCycleInputMethod()); |
1014 | 1038 |
1015 manager_->RemoveObserver(&observer); | 1039 manager_->RemoveObserver(&observer); |
1016 } | 1040 } |
1017 | 1041 |
1018 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { | 1042 TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
1019 InitComponentExtension(); | 1043 InitComponentExtension(); |
1020 std::vector<std::string> keyboard_layouts; | 1044 std::vector<std::string> keyboard_layouts; |
1021 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); | 1045 keyboard_layouts.push_back(ImeIdFromEngineId("xkb:us::eng")); |
1022 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); | 1046 manager_->GetActiveIMEState()->EnableLoginLayouts("en-US", keyboard_layouts); |
1023 EXPECT_EQ(6U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); | 1047 EXPECT_EQ(8U, manager_->GetActiveIMEState()->GetNumActiveInputMethods()); |
1024 | 1048 |
1025 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs | 1049 // Henkan, Muhenkan, ZenkakuHankaku should be ignored when no Japanese IMEs |
1026 // and keyboards are enabled. | 1050 // and keyboards are enabled. |
1027 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1051 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1028 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); | 1052 ui::Accelerator(ui::VKEY_CONVERT, ui::EF_NONE))); |
1029 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1053 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1030 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); | 1054 ui::Accelerator(ui::VKEY_NONCONVERT, ui::EF_NONE))); |
1031 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1055 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
1032 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); | 1056 ui::Accelerator(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE))); |
1033 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( | 1057 EXPECT_FALSE(manager_->GetActiveIMEState()->CanSwitchInputMethod( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 ASSERT_EQ(4U, input_method_ids.size()); | 1401 ASSERT_EQ(4U, input_method_ids.size()); |
1378 | 1402 |
1379 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1403 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
1380 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1404 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
1381 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1405 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
1382 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1406 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
1383 } | 1407 } |
1384 | 1408 |
1385 } // namespace input_method | 1409 } // namespace input_method |
1386 } // namespace chromeos | 1410 } // namespace chromeos |
OLD | NEW |