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