| 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/preferences.h" | 5 #include "chrome/browser/chromeos/preferences.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| 14 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 14 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
| 15 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 15 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 18 #include "chrome/browser/chromeos/system/fake_input_device_settings.h" | |
| 19 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/test/base/testing_profile_manager.h" | 22 #include "chrome/test/base/testing_profile_manager.h" |
| 24 #include "components/prefs/pref_member.h" | 23 #include "components/prefs/pref_member.h" |
| 25 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 24 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
| 28 #include "sync/api/attachments/attachment_id.h" | 27 #include "sync/api/attachments/attachment_id.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 previous_input_method_.Init( | 170 previous_input_method_.Init( |
| 172 prefs::kLanguagePreviousInputMethod, pref_service_); | 171 prefs::kLanguagePreviousInputMethod, pref_service_); |
| 173 previous_input_method_.SetValue("KeyboardA"); | 172 previous_input_method_.SetValue("KeyboardA"); |
| 174 current_input_method_.Init( | 173 current_input_method_.Init( |
| 175 prefs::kLanguageCurrentInputMethod, pref_service_); | 174 prefs::kLanguageCurrentInputMethod, pref_service_); |
| 176 current_input_method_.SetValue("KeyboardB"); | 175 current_input_method_.SetValue("KeyboardB"); |
| 177 | 176 |
| 178 mock_manager_ = new input_method::MyMockInputMethodManager( | 177 mock_manager_ = new input_method::MyMockInputMethodManager( |
| 179 &previous_input_method_, ¤t_input_method_); | 178 &previous_input_method_, ¤t_input_method_); |
| 180 input_method::InitializeForTesting(mock_manager_); | 179 input_method::InitializeForTesting(mock_manager_); |
| 181 system::InputDeviceSettings::SetSettingsForTesting( | |
| 182 new system::FakeInputDeviceSettings()); | |
| 183 | 180 |
| 184 prefs_.reset(new Preferences(mock_manager_)); | 181 prefs_.reset(new Preferences(mock_manager_)); |
| 185 } | 182 } |
| 186 | 183 |
| 187 void TearDown() override { | 184 void TearDown() override { |
| 188 input_method::Shutdown(); | 185 input_method::Shutdown(); |
| 189 // UserSessionManager doesn't listen to profile destruction, so make sure | 186 // UserSessionManager doesn't listen to profile destruction, so make sure |
| 190 // the default IME state isn't still cached in case test_profile_ is | 187 // the default IME state isn't still cached in case test_profile_ is |
| 191 // given the same address in the next test. | 188 // given the same address in the next test. |
| 192 UserSessionManager::GetInstance()->RemoveProfileForTesting(test_profile_); | 189 UserSessionManager::GetInstance()->RemoveProfileForTesting(test_profile_); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 pref_service_); | 240 pref_service_); |
| 244 enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes, | 241 enabled_extension_imes_.Init(prefs::kLanguageEnabledExtensionImes, |
| 245 pref_service_); | 242 pref_service_); |
| 246 enabled_extension_imes_syncable_.Init( | 243 enabled_extension_imes_syncable_.Init( |
| 247 prefs::kLanguageEnabledExtensionImesSyncable, pref_service_); | 244 prefs::kLanguageEnabledExtensionImesSyncable, pref_service_); |
| 248 | 245 |
| 249 // Initialize component and 3rd-party input method extensions. | 246 // Initialize component and 3rd-party input method extensions. |
| 250 InitComponentExtensionIMEManager(); | 247 InitComponentExtensionIMEManager(); |
| 251 input_method::InputMethodDescriptors descriptors; | 248 input_method::InputMethodDescriptors descriptors; |
| 252 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( | 249 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( |
| 253 kIdentityIMEID, | 250 kIdentityIMEID, descriptors, nullptr); |
| 254 descriptors, | |
| 255 NULL); | |
| 256 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( | 251 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( |
| 257 kToUpperIMEID, | 252 kToUpperIMEID, descriptors, nullptr); |
| 258 descriptors, | |
| 259 NULL); | |
| 260 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( | 253 mock_manager_->GetActiveIMEState()->AddInputMethodExtension( |
| 261 kAPIArgumentIMEID, | 254 kAPIArgumentIMEID, descriptors, nullptr); |
| 262 descriptors, | |
| 263 NULL); | |
| 264 } | 255 } |
| 265 | 256 |
| 266 void InitComponentExtensionIMEManager() { | 257 void InitComponentExtensionIMEManager() { |
| 267 // Set our custom IME list on the mock delegate. | 258 // Set our custom IME list on the mock delegate. |
| 268 input_method::MockComponentExtIMEManagerDelegate* mock_delegate = | 259 input_method::MockComponentExtIMEManagerDelegate* mock_delegate = |
| 269 new input_method::MockComponentExtIMEManagerDelegate(); | 260 new input_method::MockComponentExtIMEManagerDelegate(); |
| 270 mock_delegate->set_ime_list(CreateImeList()); | 261 mock_delegate->set_ime_list(CreateImeList()); |
| 271 | 262 |
| 272 // Pass the mock delegate to a new ComponentExtensionIMEManager. | 263 // Pass the mock delegate to a new ComponentExtensionIMEManager. |
| 273 std::unique_ptr<ComponentExtensionIMEManagerDelegate> delegate( | 264 std::unique_ptr<ComponentExtensionIMEManagerDelegate> delegate( |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 "Syncable values should have added local values on initialization."); | 689 "Syncable values should have added local values on initialization."); |
| 699 ExpectGlobalValues( | 690 ExpectGlobalValues( |
| 700 "es,en-US", | 691 "es,en-US", |
| 701 "xkb:es::spa,xkb:us::eng,xkb:ru::rus,xkb:xy::xyz," + | 692 "xkb:es::spa,xkb:us::eng,xkb:ru::rus,xkb:xy::xyz," + |
| 702 ToInputMethodIds("xkb:jp::jpn"), | 693 ToInputMethodIds("xkb:jp::jpn"), |
| 703 std::string(kIdentityIMEID) + "," + kUnknownIMEID); | 694 std::string(kIdentityIMEID) + "," + kUnknownIMEID); |
| 704 } | 695 } |
| 705 } | 696 } |
| 706 | 697 |
| 707 } // namespace chromeos | 698 } // namespace chromeos |
| OLD | NEW |