OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <sys/types.h> | 5 #include <sys/types.h> |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 LoginUser(kTestUsers[0]); | 146 LoginUser(kTestUsers[0]); |
147 const User* user1 = user_manager->FindUser(kTestUsers[0]); | 147 const User* user1 = user_manager->FindUser(kTestUsers[0]); |
148 PrefService* prefs1 = user_manager->GetProfileByUser(user1)->GetPrefs(); | 148 PrefService* prefs1 = user_manager->GetProfileByUser(user1)->GetPrefs(); |
149 SetPrefs(prefs1, false); | 149 SetPrefs(prefs1, false); |
150 content::RunAllPendingInMessageLoop(); | 150 content::RunAllPendingInMessageLoop(); |
151 CheckSettingsCorrespondToPrefs(prefs1); | 151 CheckSettingsCorrespondToPrefs(prefs1); |
152 | 152 |
153 // Add second user and init its prefs with different values. | 153 // Add second user and init its prefs with different values. |
154 UserAddingScreen::Get()->Start(); | 154 UserAddingScreen::Get()->Start(); |
155 content::RunAllPendingInMessageLoop(); | 155 content::RunAllPendingInMessageLoop(); |
156 DisableAnimations(); | |
157 AddUser(kTestUsers[1]); | 156 AddUser(kTestUsers[1]); |
158 content::RunAllPendingInMessageLoop(); | 157 EXPECT_TRUE(user1->is_active()); |
159 const User* user2 = user_manager->FindUser(kTestUsers[1]); | 158 const User* user2 = user_manager->FindUser(kTestUsers[1]); |
160 EXPECT_TRUE(user2->is_active()); | |
161 PrefService* prefs2 = user_manager->GetProfileByUser(user2)->GetPrefs(); | 159 PrefService* prefs2 = user_manager->GetProfileByUser(user2)->GetPrefs(); |
162 SetPrefs(prefs2, true); | 160 SetPrefs(prefs2, true); |
163 | 161 |
164 // Check that settings were changed accordingly. | 162 // First user is still active, so settings was not changed. |
| 163 EXPECT_TRUE(user1->is_active()); |
| 164 CheckSettingsCorrespondToPrefs(prefs1); |
| 165 |
| 166 // Switch user and check that settings was changed accordingly. |
| 167 DisableAnimations(); |
| 168 user_manager->SwitchActiveUser(kTestUsers[1]); |
165 EXPECT_TRUE(user2->is_active()); | 169 EXPECT_TRUE(user2->is_active()); |
166 CheckSettingsCorrespondToPrefs(prefs2); | 170 CheckSettingsCorrespondToPrefs(prefs2); |
167 | 171 |
168 // Check that changing prefs of the active user doesn't affect prefs of the | 172 // Check that changing prefs of the active user doesn't affect prefs of the |
169 // inactive user. | 173 // inactive user. |
170 scoped_ptr<base::DictionaryValue> prefs_backup = | 174 scoped_ptr<base::DictionaryValue> prefs_backup = |
171 prefs1->GetPreferenceValues(); | 175 prefs1->GetPreferenceValues(); |
172 SetPrefs(prefs2, false); | 176 SetPrefs(prefs2, false); |
173 CheckSettingsCorrespondToPrefs(prefs2); | 177 CheckSettingsCorrespondToPrefs(prefs2); |
174 EXPECT_TRUE(prefs_backup->Equals(prefs1->GetPreferenceValues().get())); | 178 EXPECT_TRUE(prefs_backup->Equals(prefs1->GetPreferenceValues().get())); |
(...skipping 22 matching lines...) Expand all Loading... |
197 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); | 201 !prefs1->GetBoolean(prefs::kTapToClickEnabled)); |
198 CheckLocalStateCorrespondsToPrefs(prefs1); | 202 CheckLocalStateCorrespondsToPrefs(prefs1); |
199 | 203 |
200 // Switch user back. | 204 // Switch user back. |
201 user_manager->SwitchActiveUser(kTestUsers[0]); | 205 user_manager->SwitchActiveUser(kTestUsers[0]); |
202 CheckSettingsCorrespondToPrefs(prefs1); | 206 CheckSettingsCorrespondToPrefs(prefs1); |
203 CheckLocalStateCorrespondsToPrefs(prefs1); | 207 CheckLocalStateCorrespondsToPrefs(prefs1); |
204 } | 208 } |
205 | 209 |
206 } // namespace chromeos | 210 } // namespace chromeos |
OLD | NEW |