| 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 // Add two Extension IMEs. | 917 // Add two Extension IMEs. |
| 918 std::vector<std::string> layouts; | 918 std::vector<std::string> layouts; |
| 919 layouts.push_back("us"); | 919 layouts.push_back("us"); |
| 920 std::vector<std::string> languages; | 920 std::vector<std::string> languages; |
| 921 languages.push_back("en-US"); | 921 languages.push_back("en-US"); |
| 922 | 922 |
| 923 const std::string ext1_id = | 923 const std::string ext1_id = |
| 924 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 924 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
| 925 const InputMethodDescriptor descriptor1(ext1_id, | 925 const InputMethodDescriptor descriptor1(ext1_id, |
| 926 "deadbeef input method", | 926 "deadbeef input method", |
| 927 "DB", |
| 927 layouts, | 928 layouts, |
| 928 languages, | 929 languages, |
| 929 false, // is_login_keyboard | 930 false, // is_login_keyboard |
| 930 GURL(), | 931 GURL(), |
| 931 GURL()); | 932 GURL()); |
| 932 MockInputMethodEngine engine(descriptor1); | 933 MockInputMethodEngine engine(descriptor1); |
| 933 manager_->AddInputMethodExtension(ext1_id, &engine); | 934 manager_->AddInputMethodExtension(ext1_id, &engine); |
| 934 | 935 |
| 935 // Extension IMEs are not enabled by default. | 936 // Extension IMEs are not enabled by default. |
| 936 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 937 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| 937 | 938 |
| 938 std::vector<std::string> extension_ime_ids; | 939 std::vector<std::string> extension_ime_ids; |
| 939 extension_ime_ids.push_back(ext1_id); | 940 extension_ime_ids.push_back(ext1_id); |
| 940 manager_->SetEnabledExtensionImes(&extension_ime_ids); | 941 manager_->SetEnabledExtensionImes(&extension_ime_ids); |
| 941 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 942 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 942 | 943 |
| 943 { | 944 { |
| 944 scoped_ptr<InputMethodDescriptors> methods( | 945 scoped_ptr<InputMethodDescriptors> methods( |
| 945 manager_->GetActiveInputMethods()); | 946 manager_->GetActiveInputMethods()); |
| 946 ASSERT_EQ(2U, methods->size()); | 947 ASSERT_EQ(2U, methods->size()); |
| 947 // Ext IMEs should be at the end of the list. | 948 // Ext IMEs should be at the end of the list. |
| 948 EXPECT_EQ(ext1_id, methods->at(1).id()); | 949 EXPECT_EQ(ext1_id, methods->at(1).id()); |
| 949 } | 950 } |
| 950 | 951 |
| 951 const std::string ext2_id = | 952 const std::string ext2_id = |
| 952 extension_ime_util::GetInputMethodID("cafebabe", "engine_id"); | 953 extension_ime_util::GetInputMethodID("cafebabe", "engine_id"); |
| 953 const InputMethodDescriptor descriptor2(ext2_id, | 954 const InputMethodDescriptor descriptor2(ext2_id, |
| 954 "cafebabe input method", | 955 "cafebabe input method", |
| 956 "CB", |
| 955 layouts, | 957 layouts, |
| 956 languages, | 958 languages, |
| 957 false, // is_login_keyboard | 959 false, // is_login_keyboard |
| 958 GURL(), | 960 GURL(), |
| 959 GURL()); | 961 GURL()); |
| 960 MockInputMethodEngine engine2(descriptor2); | 962 MockInputMethodEngine engine2(descriptor2); |
| 961 manager_->AddInputMethodExtension(ext2_id, &engine2); | 963 manager_->AddInputMethodExtension(ext2_id, &engine2); |
| 962 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 964 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 963 | 965 |
| 964 extension_ime_ids.push_back(ext2_id); | 966 extension_ime_ids.push_back(ext2_id); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 // Add an Extension IME. | 998 // Add an Extension IME. |
| 997 std::vector<std::string> layouts; | 999 std::vector<std::string> layouts; |
| 998 layouts.push_back("us(dvorak)"); | 1000 layouts.push_back("us(dvorak)"); |
| 999 std::vector<std::string> languages; | 1001 std::vector<std::string> languages; |
| 1000 languages.push_back("en-US"); | 1002 languages.push_back("en-US"); |
| 1001 | 1003 |
| 1002 const std::string ext_id = | 1004 const std::string ext_id = |
| 1003 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); | 1005 extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); |
| 1004 const InputMethodDescriptor descriptor(ext_id, | 1006 const InputMethodDescriptor descriptor(ext_id, |
| 1005 "deadbeef input method", | 1007 "deadbeef input method", |
| 1008 "DB", |
| 1006 layouts, | 1009 layouts, |
| 1007 languages, | 1010 languages, |
| 1008 false, // is_login_keyboard | 1011 false, // is_login_keyboard |
| 1009 GURL(), | 1012 GURL(), |
| 1010 GURL()); | 1013 GURL()); |
| 1011 MockInputMethodEngine engine(descriptor); | 1014 MockInputMethodEngine engine(descriptor); |
| 1012 manager_->AddInputMethodExtension(ext_id, &engine); | 1015 manager_->AddInputMethodExtension(ext_id, &engine); |
| 1013 | 1016 |
| 1014 // Extension IME is not enabled by default. | 1017 // Extension IME is not enabled by default. |
| 1015 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); | 1018 EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 ids.push_back(ext_id2); | 1146 ids.push_back(ext_id2); |
| 1144 EXPECT_TRUE(manager_->EnableInputMethods(ids)); | 1147 EXPECT_TRUE(manager_->EnableInputMethods(ids)); |
| 1145 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); | 1148 EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
| 1146 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); | 1149 EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); |
| 1147 manager_->ChangeInputMethod(ext_id2); | 1150 manager_->ChangeInputMethod(ext_id2); |
| 1148 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); | 1151 EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); |
| 1149 } | 1152 } |
| 1150 | 1153 |
| 1151 } // namespace input_method | 1154 } // namespace input_method |
| 1152 } // namespace chromeos | 1155 } // namespace chromeos |
| OLD | NEW |