| 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 25 matching lines...) Expand all Loading... |
| 36 protected: | 36 protected: |
| 37 InputMethodPersistenceTest() | 37 InputMethodPersistenceTest() |
| 38 : mock_profile_manager_(TestingBrowserProcess::GetGlobal()), | 38 : mock_profile_manager_(TestingBrowserProcess::GetGlobal()), |
| 39 fake_user_manager_(new chromeos::FakeChromeUserManager()), | 39 fake_user_manager_(new chromeos::FakeChromeUserManager()), |
| 40 user_manager_enabler_(fake_user_manager_) {} | 40 user_manager_enabler_(fake_user_manager_) {} |
| 41 | 41 |
| 42 void SetUp() override { | 42 void SetUp() override { |
| 43 ASSERT_TRUE(mock_profile_manager_.SetUp()); | 43 ASSERT_TRUE(mock_profile_manager_.SetUp()); |
| 44 | 44 |
| 45 // Add a user. | 45 // Add a user. |
| 46 const char kTestUserName[] = "test-user@example.com"; | 46 const AccountId test_account_id( |
| 47 fake_user_manager_->AddUser(kTestUserName); | 47 AccountId::FromUserEmail("test-user@example.com")); |
| 48 fake_user_manager_->LoginUser(kTestUserName); | 48 fake_user_manager_->AddUser(test_account_id); |
| 49 fake_user_manager_->LoginUser(test_account_id); |
| 49 | 50 |
| 50 // Create a valid profile for the user. | 51 // Create a valid profile for the user. |
| 51 TestingProfile* mock_profile = | 52 TestingProfile* mock_profile = mock_profile_manager_.CreateTestingProfile( |
| 52 mock_profile_manager_.CreateTestingProfile(kTestUserName); | 53 test_account_id.GetUserEmail()); |
| 53 mock_profile_manager_.SetLoggedIn(true); | 54 mock_profile_manager_.SetLoggedIn(true); |
| 54 EXPECT_TRUE(ProfileManager::GetActiveUserProfile() == mock_profile); | 55 EXPECT_TRUE(ProfileManager::GetActiveUserProfile() == mock_profile); |
| 55 | 56 |
| 56 mock_user_prefs_ = mock_profile->GetTestingPrefService(); | 57 mock_user_prefs_ = mock_profile->GetTestingPrefService(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 // Verifies that the user and system prefs contain the expected values. | 60 // Verifies that the user and system prefs contain the expected values. |
| 60 void VerifyPrefs(const std::string& current_input_method, | 61 void VerifyPrefs(const std::string& current_input_method, |
| 61 const std::string& previous_input_method, | 62 const std::string& previous_input_method, |
| 62 const std::string& preferred_keyboard_layout) { | 63 const std::string& preferred_keyboard_layout) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 121 |
| 121 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); | 122 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); |
| 122 mock_manager_.SetCurrentInputMethodId(kInputId1); | 123 mock_manager_.SetCurrentInputMethodId(kInputId1); |
| 123 persistence.InputMethodChanged(&mock_manager_, | 124 persistence.InputMethodChanged(&mock_manager_, |
| 124 ProfileManager::GetActiveUserProfile(), false); | 125 ProfileManager::GetActiveUserProfile(), false); |
| 125 VerifyPrefs(kInputId1, kInputId2, kInputId2); | 126 VerifyPrefs(kInputId1, kInputId2, kInputId2); |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace input_method | 129 } // namespace input_method |
| 129 } // namespace chromeos | 130 } // namespace chromeos |
| OLD | NEW |