Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: chrome/browser/chromeos/login/users/user_manager_unittest.cc

Issue 2711113003: Track whether a given user session has completed initialization, and use (Closed)
Patch Set: Only expose known_user::RemovePrefsForTesting() for tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <cstdlib> 5 #include <cstdlib>
6 #include <cstring> 6 #include <cstring>
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" 14 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 18 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/scoped_testing_local_state.h" 22 #include "chrome/test/base/scoped_testing_local_state.h"
23 #include "chrome/test/base/testing_browser_process.h" 23 #include "chrome/test/base/testing_browser_process.h"
24 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
25 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
26 #include "chromeos/dbus/dbus_thread_manager.h" 26 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "chromeos/settings/cros_settings_names.h" 27 #include "chromeos/settings/cros_settings_names.h"
28 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
29 #include "components/user_manager/known_user.h"
29 #include "components/user_manager/user.h" 30 #include "components/user_manager/user.h"
30 #include "components/user_manager/user_manager.h" 31 #include "components/user_manager/user_manager.h"
31 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
32 #include "content/public/test/test_browser_thread_bundle.h" 33 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
34 35
35 namespace chromeos { 36 namespace chromeos {
36 37
37 class UnittestProfileManager : public ::ProfileManagerWithoutInit { 38 class UnittestProfileManager : public ::ProfileManagerWithoutInit {
38 public: 39 public:
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_EQ(1U, user_manager::UserManager::Get()->GetUnlockUsers().size()); 234 EXPECT_EQ(1U, user_manager::UserManager::Get()->GetUnlockUsers().size());
234 235
235 // The user is not allowed to lock the screen. 236 // The user is not allowed to lock the screen.
236 profile->GetPrefs()->SetBoolean(prefs::kAllowScreenLock, false); 237 profile->GetPrefs()->SetBoolean(prefs::kAllowScreenLock, false);
237 EXPECT_FALSE(user_manager::UserManager::Get()->CanCurrentUserLock()); 238 EXPECT_FALSE(user_manager::UserManager::Get()->CanCurrentUserLock());
238 EXPECT_EQ(0U, user_manager::UserManager::Get()->GetUnlockUsers().size()); 239 EXPECT_EQ(0U, user_manager::UserManager::Get()->GetUnlockUsers().size());
239 240
240 ResetUserManager(); 241 ResetUserManager();
241 } 242 }
242 243
244 TEST_F(UserManagerTest, ProfileInitialized) {
245 user_manager::UserManager::Get()->UserLoggedIn(
246 owner_account_id_at_invalid_domain_,
247 owner_account_id_at_invalid_domain_.GetUserEmail(), false);
248 const user_manager::UserList* users =
249 &user_manager::UserManager::Get()->GetUsers();
250 ASSERT_EQ(1U, users->size());
251 EXPECT_FALSE((*users)[0]->profile_ever_initialized());
252 ResetUserManager();
253 users = &user_manager::UserManager::Get()->GetUsers();
254 ASSERT_EQ(1U, users->size());
255 EXPECT_FALSE((*users)[0]->profile_ever_initialized());
256 }
257
258 TEST_F(UserManagerTest, ProfileInitializedMigration) {
259 user_manager::UserManager::Get()->UserLoggedIn(
260 owner_account_id_at_invalid_domain_,
261 owner_account_id_at_invalid_domain_.GetUserEmail(), false);
262 const user_manager::UserList* users =
263 &user_manager::UserManager::Get()->GetUsers();
264 ASSERT_EQ(1U, users->size());
265 EXPECT_FALSE((*users)[0]->profile_ever_initialized());
266
267 // Clear the stored user data - when UserManager loads again, it should
268 // migrate existing users by setting session_initialized to true for them.
269 user_manager::known_user::RemovePrefsForTesting((*users)[0]->GetAccountId());
270 ResetUserManager();
271 users = &user_manager::UserManager::Get()->GetUsers();
272 ASSERT_EQ(1U, users->size());
273 EXPECT_TRUE((*users)[0]->profile_ever_initialized());
274 }
275
243 } // namespace chromeos 276 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698