| 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/browser_state_monitor.h" | 5 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
| 6 | 6 |
| 7 #include "chrome/browser/api/prefs/pref_member.h" | 7 #include "chrome/browser/api/prefs/pref_member.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/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, | 230 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, |
| 231 mock_manager.last_state_); | 231 mock_manager.last_state_); |
| 232 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor.state()); | 232 EXPECT_EQ(InputMethodManager::STATE_TERMINATING, monitor.state()); |
| 233 | 233 |
| 234 // In the terminating state, the monitor should ignore input method changes. | 234 // In the terminating state, the monitor should ignore input method changes. |
| 235 monitor.InputMethodChanged(&mock_manager, false); | 235 monitor.InputMethodChanged(&mock_manager, false); |
| 236 EXPECT_EQ(0, monitor.update_local_state_count()); | 236 EXPECT_EQ(0, monitor.update_local_state_count()); |
| 237 EXPECT_EQ(0, monitor.update_user_pref_count()); | 237 EXPECT_EQ(0, monitor.update_user_pref_count()); |
| 238 } | 238 } |
| 239 | 239 |
| 240 TEST(BrowserStateMonitorTest, TestObservePrefChanged) { | |
| 241 TestingPrefService prefs; | |
| 242 RegisterTestPrefs(&prefs); | |
| 243 MockInputMethodManager mock_manager; | |
| 244 TestableBrowserStateMonitor monitor(&mock_manager); | |
| 245 monitor.SetPrefServiceForTesting(&prefs); | |
| 246 | |
| 247 EXPECT_EQ(1, mock_manager.set_state_count_); | |
| 248 monitor.Observe(chrome::NOTIFICATION_PREF_CHANGED, | |
| 249 content::NotificationService::AllSources(), | |
| 250 content::NotificationService::NoDetails()); | |
| 251 | |
| 252 // NOTIFICATION_PREF_CHANGED should be ignored. | |
| 253 EXPECT_EQ(1, mock_manager.set_state_count_); | |
| 254 } | |
| 255 | |
| 256 TEST(BrowserStateMonitorTest, TestUpdatePrefOnLoginScreen) { | 240 TEST(BrowserStateMonitorTest, TestUpdatePrefOnLoginScreen) { |
| 257 TestingPrefService prefs; | 241 TestingPrefService prefs; |
| 258 RegisterTestPrefs(&prefs); | 242 RegisterTestPrefs(&prefs); |
| 259 MockInputMethodManager mock_manager; | 243 MockInputMethodManager mock_manager; |
| 260 TestableBrowserStateMonitor monitor(&mock_manager); | 244 TestableBrowserStateMonitor monitor(&mock_manager); |
| 261 monitor.SetPrefServiceForTesting(&prefs); | 245 monitor.SetPrefServiceForTesting(&prefs); |
| 262 | 246 |
| 263 EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, monitor.state()); | 247 EXPECT_EQ(InputMethodManager::STATE_LOGIN_SCREEN, monitor.state()); |
| 264 monitor.InputMethodChanged(&mock_manager, false); | 248 monitor.InputMethodChanged(&mock_manager, false); |
| 265 EXPECT_EQ(1, monitor.update_local_state_count()); | 249 EXPECT_EQ(1, monitor.update_local_state_count()); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 monitor.InputMethodChanged(&mock_manager, false); | 367 monitor.InputMethodChanged(&mock_manager, false); |
| 384 EXPECT_EQ(0, monitor.update_local_state_count()); | 368 EXPECT_EQ(0, monitor.update_local_state_count()); |
| 385 EXPECT_EQ(5, monitor.update_user_pref_count()); | 369 EXPECT_EQ(5, monitor.update_user_pref_count()); |
| 386 EXPECT_EQ(input_method_id_3, monitor.last_user_pref()); | 370 EXPECT_EQ(input_method_id_3, monitor.last_user_pref()); |
| 387 EXPECT_EQ(input_method_id_2, previous.GetValue()); | 371 EXPECT_EQ(input_method_id_2, previous.GetValue()); |
| 388 EXPECT_EQ(input_method_id_3, current.GetValue()); | 372 EXPECT_EQ(input_method_id_3, current.GetValue()); |
| 389 } | 373 } |
| 390 | 374 |
| 391 } // namespace input_method | 375 } // namespace input_method |
| 392 } // namespace chromeos | 376 } // namespace chromeos |
| OLD | NEW |