| 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 23 matching lines...) Expand all Loading... |
| 34 : mock_profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 34 : mock_profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
| 35 | 35 |
| 36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
| 37 // Set up a valid profile for our test. | 37 // Set up a valid profile for our test. |
| 38 ASSERT_TRUE(mock_profile_manager_.SetUp()); | 38 ASSERT_TRUE(mock_profile_manager_.SetUp()); |
| 39 TestingProfile* mock_profile = | 39 TestingProfile* mock_profile = |
| 40 mock_profile_manager_.CreateTestingProfile(chrome::kTestUserProfileDir); | 40 mock_profile_manager_.CreateTestingProfile(chrome::kTestUserProfileDir); |
| 41 CommandLine *cl = CommandLine::ForCurrentProcess(); | 41 CommandLine *cl = CommandLine::ForCurrentProcess(); |
| 42 cl->AppendSwitchASCII(switches::kLoginProfile, chrome::kTestUserProfileDir); | 42 cl->AppendSwitchASCII(switches::kLoginProfile, chrome::kTestUserProfileDir); |
| 43 mock_profile_manager_.SetLoggedIn(true); | 43 mock_profile_manager_.SetLoggedIn(true); |
| 44 ProfileManager::AllowGetDefaultProfile(); | |
| 45 EXPECT_TRUE(ProfileManager::GetActiveUserProfile() != NULL); | 44 EXPECT_TRUE(ProfileManager::GetActiveUserProfile() != NULL); |
| 46 mock_user_prefs_ = mock_profile->GetTestingPrefService(); | 45 mock_user_prefs_ = mock_profile->GetTestingPrefService(); |
| 47 } | 46 } |
| 48 | 47 |
| 49 // Verifies that the user and system prefs contain the expected values. | 48 // Verifies that the user and system prefs contain the expected values. |
| 50 void VerifyPrefs(const std::string& current_input_method, | 49 void VerifyPrefs(const std::string& current_input_method, |
| 51 const std::string& previous_input_method, | 50 const std::string& previous_input_method, |
| 52 const std::string& preferred_keyboard_layout) { | 51 const std::string& preferred_keyboard_layout) { |
| 53 EXPECT_EQ(current_input_method, | 52 EXPECT_EQ(current_input_method, |
| 54 mock_user_prefs_->GetString(prefs::kLanguageCurrentInputMethod)); | 53 mock_user_prefs_->GetString(prefs::kLanguageCurrentInputMethod)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 VerifyPrefs(kInputId2, "", kInputId2); | 100 VerifyPrefs(kInputId2, "", kInputId2); |
| 102 | 101 |
| 103 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); | 102 persistence.OnSessionStateChange(InputMethodManager::STATE_BROWSER_SCREEN); |
| 104 mock_manager_.SetCurrentInputMethodId(kInputId1); | 103 mock_manager_.SetCurrentInputMethodId(kInputId1); |
| 105 persistence.InputMethodChanged(&mock_manager_, false); | 104 persistence.InputMethodChanged(&mock_manager_, false); |
| 106 VerifyPrefs(kInputId1, kInputId2, kInputId2); | 105 VerifyPrefs(kInputId1, kInputId2, kInputId2); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace input_method | 108 } // namespace input_method |
| 110 } // namespace chromeos | 109 } // namespace chromeos |
| OLD | NEW |