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