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 "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 9 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
10 #include "chrome/browser/chromeos/language_preferences.h" | 10 #include "chrome/browser/chromeos/language_preferences.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(1, mock_manager_.add_observer_count_); | 81 EXPECT_EQ(1, mock_manager_.add_observer_count_); |
82 } | 82 } |
83 EXPECT_EQ(1, mock_manager_.remove_observer_count_); | 83 EXPECT_EQ(1, mock_manager_.remove_observer_count_); |
84 } | 84 } |
85 | 85 |
86 TEST_F(InputMethodPersistenceTest, TestPrefPersistenceByState) { | 86 TEST_F(InputMethodPersistenceTest, TestPrefPersistenceByState) { |
87 InputMethodPersistence persistence(&mock_manager_); | 87 InputMethodPersistence persistence(&mock_manager_); |
88 | 88 |
89 persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN); | 89 persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN); |
90 mock_manager_.SetCurrentInputMethodId(kInputId1); | 90 mock_manager_.SetCurrentInputMethodId(kInputId1); |
91 persistence.InputMethodChanged(&mock_manager_, false); | 91 persistence.InputMethodChanged(&mock_manager_, |
| 92 ProfileManager::GetActiveUserProfile(), false); |
92 VerifyPrefs("", "", kInputId1); | 93 VerifyPrefs("", "", kInputId1); |
93 | 94 |
94 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); | 95 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); |
95 mock_manager_.SetCurrentInputMethodId(kInputId2); | 96 mock_manager_.SetCurrentInputMethodId(kInputId2); |
96 persistence.InputMethodChanged(&mock_manager_, false); | 97 persistence.InputMethodChanged(&mock_manager_, |
| 98 ProfileManager::GetActiveUserProfile(), false); |
97 VerifyPrefs(kInputId2, "", kInputId1); | 99 VerifyPrefs(kInputId2, "", kInputId1); |
98 | 100 |
99 persistence.OnSessionStateChange(InputMethodManager::STATE_LOCK_SCREEN); | 101 persistence.OnSessionStateChange(InputMethodManager::STATE_LOCK_SCREEN); |
100 mock_manager_.SetCurrentInputMethodId(kInputId1); | 102 mock_manager_.SetCurrentInputMethodId(kInputId1); |
101 persistence.InputMethodChanged(&mock_manager_, false); | 103 persistence.InputMethodChanged(&mock_manager_, |
| 104 ProfileManager::GetActiveUserProfile(), false); |
102 VerifyPrefs(kInputId2, "", kInputId1); | 105 VerifyPrefs(kInputId2, "", kInputId1); |
103 | 106 |
104 persistence.OnSessionStateChange(InputMethodManager::STATE_TERMINATING); | 107 persistence.OnSessionStateChange(InputMethodManager::STATE_TERMINATING); |
105 mock_manager_.SetCurrentInputMethodId(kInputId1); | 108 mock_manager_.SetCurrentInputMethodId(kInputId1); |
106 persistence.InputMethodChanged(&mock_manager_, false); | 109 persistence.InputMethodChanged(&mock_manager_, |
| 110 ProfileManager::GetActiveUserProfile(), false); |
107 VerifyPrefs(kInputId2, "", kInputId1); | 111 VerifyPrefs(kInputId2, "", kInputId1); |
108 | 112 |
109 persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN); | 113 persistence.OnSessionStateChange(InputMethodManager::STATE_LOGIN_SCREEN); |
110 mock_manager_.SetCurrentInputMethodId(kInputId2); | 114 mock_manager_.SetCurrentInputMethodId(kInputId2); |
111 persistence.InputMethodChanged(&mock_manager_, false); | 115 persistence.InputMethodChanged(&mock_manager_, |
| 116 ProfileManager::GetActiveUserProfile(), false); |
112 VerifyPrefs(kInputId2, "", kInputId2); | 117 VerifyPrefs(kInputId2, "", kInputId2); |
113 | 118 |
114 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); | 119 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); |
115 mock_manager_.SetCurrentInputMethodId(kInputId1); | 120 mock_manager_.SetCurrentInputMethodId(kInputId1); |
116 persistence.InputMethodChanged(&mock_manager_, false); | 121 persistence.InputMethodChanged(&mock_manager_, |
| 122 ProfileManager::GetActiveUserProfile(), false); |
117 VerifyPrefs(kInputId1, kInputId2, kInputId2); | 123 VerifyPrefs(kInputId1, kInputId2, kInputId2); |
118 } | 124 } |
119 | 125 |
120 } // namespace input_method | 126 } // namespace input_method |
121 } // namespace chromeos | 127 } // namespace chromeos |
OLD | NEW |