| 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_persistence.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 8 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
| 9 #include "chrome/browser/chromeos/language_preferences.h" | 9 #include "chrome/browser/chromeos/language_preferences.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 19 #include "chrome/test/base/testing_profile_manager.h" | 19 #include "chrome/test/base/testing_profile_manager.h" |
| 20 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 22 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 | 24 |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 namespace chromeos { | 27 namespace chromeos { |
| 28 namespace input_method { | 28 namespace input_method { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 const char kInputId1[] = "xkb:us:dvorak:eng"; | 31 const char kInputId1[] = "xkb:us:dvorak:eng"; |
| 32 const char kInputId2[] = "xkb:us:colemak:eng"; | 32 const char kInputId2[] = "xkb:us:colemak:eng"; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 EXPECT_EQ(current_input_method, | 64 EXPECT_EQ(current_input_method, |
| 65 mock_user_prefs_->GetString(prefs::kLanguageCurrentInputMethod)); | 65 mock_user_prefs_->GetString(prefs::kLanguageCurrentInputMethod)); |
| 66 EXPECT_EQ(previous_input_method, | 66 EXPECT_EQ(previous_input_method, |
| 67 mock_user_prefs_->GetString(prefs::kLanguagePreviousInputMethod)); | 67 mock_user_prefs_->GetString(prefs::kLanguagePreviousInputMethod)); |
| 68 EXPECT_EQ(preferred_keyboard_layout, | 68 EXPECT_EQ(preferred_keyboard_layout, |
| 69 g_browser_process->local_state()->GetString( | 69 g_browser_process->local_state()->GetString( |
| 70 language_prefs::kPreferredKeyboardLayout)); | 70 language_prefs::kPreferredKeyboardLayout)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 content::TestBrowserThreadBundle thread_bundle_; | 73 content::TestBrowserThreadBundle thread_bundle_; |
| 74 syncable_prefs::TestingPrefServiceSyncable* mock_user_prefs_; | 74 sync_preferences::TestingPrefServiceSyncable* mock_user_prefs_; |
| 75 MockInputMethodManager mock_manager_; | 75 MockInputMethodManager mock_manager_; |
| 76 TestingProfileManager mock_profile_manager_; | 76 TestingProfileManager mock_profile_manager_; |
| 77 chromeos::FakeChromeUserManager* fake_user_manager_; | 77 chromeos::FakeChromeUserManager* fake_user_manager_; |
| 78 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 78 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 TEST_F(InputMethodPersistenceTest, TestLifetime) { | 81 TEST_F(InputMethodPersistenceTest, TestLifetime) { |
| 82 { | 82 { |
| 83 InputMethodPersistence persistence(&mock_manager_); | 83 InputMethodPersistence persistence(&mock_manager_); |
| 84 EXPECT_EQ(1, mock_manager_.add_observer_count_); | 84 EXPECT_EQ(1, mock_manager_.add_observer_count_); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); | 122 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); |
| 123 mock_manager_.SetCurrentInputMethodId(kInputId1); | 123 mock_manager_.SetCurrentInputMethodId(kInputId1); |
| 124 persistence.InputMethodChanged(&mock_manager_, | 124 persistence.InputMethodChanged(&mock_manager_, |
| 125 ProfileManager::GetActiveUserProfile(), false); | 125 ProfileManager::GetActiveUserProfile(), false); |
| 126 VerifyPrefs(kInputId1, kInputId2, kInputId2); | 126 VerifyPrefs(kInputId1, kInputId2, kInputId2); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace input_method | 129 } // namespace input_method |
| 130 } // namespace chromeos | 130 } // namespace chromeos |
| OLD | NEW |