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

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: Added tests. Created 3 years, 10 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"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_EQ(1U, user_manager::UserManager::Get()->GetUnlockUsers().size()); 233 EXPECT_EQ(1U, user_manager::UserManager::Get()->GetUnlockUsers().size());
234 234
235 // The user is not allowed to lock the screen. 235 // The user is not allowed to lock the screen.
236 profile->GetPrefs()->SetBoolean(prefs::kAllowScreenLock, false); 236 profile->GetPrefs()->SetBoolean(prefs::kAllowScreenLock, false);
237 EXPECT_FALSE(user_manager::UserManager::Get()->CanCurrentUserLock()); 237 EXPECT_FALSE(user_manager::UserManager::Get()->CanCurrentUserLock());
238 EXPECT_EQ(0U, user_manager::UserManager::Get()->GetUnlockUsers().size()); 238 EXPECT_EQ(0U, user_manager::UserManager::Get()->GetUnlockUsers().size());
239 239
240 ResetUserManager(); 240 ResetUserManager();
241 } 241 }
242 242
243 TEST_F(UserManagerTest, SessionInitialized) {
244 user_manager::UserManager::Get()->UserLoggedIn(
245 owner_account_id_at_invalid_domain_,
246 owner_account_id_at_invalid_domain_.GetUserEmail(), false);
247 const user_manager::UserList* users =
248 &user_manager::UserManager::Get()->GetUsers();
249 ASSERT_EQ(1U, users->size());
250 EXPECT_FALSE((*users)[0]->session_initialized());
251 ResetUserManager();
252 users = &user_manager::UserManager::Get()->GetUsers();
253 ASSERT_EQ(1U, users->size());
254 EXPECT_FALSE((*users)[0]->session_initialized());
255 }
256
257 TEST_F(UserManagerTest, SessionInitializedMigration) {
258 user_manager::UserManager::Get()->UserLoggedIn(
259 owner_account_id_at_invalid_domain_,
260 owner_account_id_at_invalid_domain_.GetUserEmail(), false);
261 const user_manager::UserList* users =
262 &user_manager::UserManager::Get()->GetUsers();
263 ASSERT_EQ(1U, users->size());
264 EXPECT_FALSE((*users)[0]->session_initialized());
265
266 // Clear the stored user data - when UserManager loads again, it should
267 // migrate existing users by setting session_initialized to true for them.
268 local_state_->Get()->ClearPref("UserSessionInitialized");
269 ResetUserManager();
270 users = &user_manager::UserManager::Get()->GetUsers();
271 ASSERT_EQ(1U, users->size());
272 EXPECT_TRUE((*users)[0]->session_initialized());
273 }
274
243 } // namespace chromeos 275 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698