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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller_browsertest.cc

Issue 656283002: [session_manager] Move user session initialization code out of ExistingUserController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 2 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 (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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 .Times(AnyNumber()) 156 .Times(AnyNumber())
157 .WillRepeatedly(Return(false)); 157 .WillRepeatedly(Return(false));
158 EXPECT_CALL(*mock_user_manager_, IsSessionStarted()) 158 EXPECT_CALL(*mock_user_manager_, IsSessionStarted())
159 .Times(AnyNumber()) 159 .Times(AnyNumber())
160 .WillRepeatedly(Return(false)); 160 .WillRepeatedly(Return(false));
161 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 161 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
162 .Times(AnyNumber()) 162 .Times(AnyNumber())
163 .WillRepeatedly(Return(false)); 163 .WillRepeatedly(Return(false));
164 EXPECT_CALL(*mock_user_manager_, Shutdown()) 164 EXPECT_CALL(*mock_user_manager_, Shutdown())
165 .Times(1); 165 .Times(1);
166 EXPECT_CALL(*mock_user_manager_, FindUser(_))
167 .Times(AnyNumber())
168 .WillRepeatedly(ReturnNull());
166 } 169 }
167 170
168 virtual void SetUpOnMainThread() override { 171 virtual void SetUpOnMainThread() override {
169 testing_profile_.reset(new TestingProfile()); 172 testing_profile_.reset(new TestingProfile());
170 SetUpUserManager(); 173 SetUpUserManager();
171 existing_user_controller_.reset( 174 existing_user_controller_.reset(
172 new ExistingUserController(mock_login_display_host_.get())); 175 new ExistingUserController(mock_login_display_host_.get()));
173 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get()); 176 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get());
174 existing_user_controller_->Init(user_manager::UserList()); 177 existing_user_controller_->Init(user_manager::UserList());
175 profile_prepared_cb_ = 178 profile_prepared_cb_ =
176 base::Bind(&ExistingUserController::OnProfilePrepared, 179 base::Bind(&ExistingUserController::OnProfilePrepared,
177 base::Unretained(existing_user_controller()), 180 base::Unretained(existing_user_controller()),
178 testing_profile_.get()); 181 testing_profile_.get(),
182 false);
179 } 183 }
180 184
181 virtual void TearDownOnMainThread() override { 185 virtual void TearDownOnMainThread() override {
182 // ExistingUserController must be deleted before the thread is cleaned up: 186 // ExistingUserController must be deleted before the thread is cleaned up:
183 // If there is an outstanding login attempt when ExistingUserController is 187 // If there is an outstanding login attempt when ExistingUserController is
184 // deleted, its LoginPerformer instance will be deleted, which in turn 188 // deleted, its LoginPerformer instance will be deleted, which in turn
185 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must 189 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must
186 // be deleted on the UI thread. 190 // be deleted on the UI thread.
187 existing_user_controller_.reset(); 191 existing_user_controller_.reset();
188 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread(); 192 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Mock URLFetcher. 229 // Mock URLFetcher.
226 MockURLFetcherFactory<SuccessFetcher> factory_; 230 MockURLFetcherFactory<SuccessFetcher> factory_;
227 231
228 base::Callback<void(void)> profile_prepared_cb_; 232 base::Callback<void(void)> profile_prepared_cb_;
229 233
230 private: 234 private:
231 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); 235 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest);
232 }; 236 };
233 237
234 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { 238 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) {
235 // This is disabled twice: once right after signin but before checking for
236 // auto-enrollment, and again after doing an ownership status check.
237 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 239 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
238 .Times(2); 240 .Times(1);
239 UserContext user_context(kUsername); 241 UserContext user_context(kUsername);
240 user_context.SetKey(Key(kPassword)); 242 user_context.SetKey(Key(kPassword));
241 user_context.SetUserIDHash(kUsername); 243 user_context.SetUserIDHash(kUsername);
242 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 244 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
243 .Times(1) 245 .Times(1)
244 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); 246 .WillOnce(WithArg<0>(CreateAuthenticator(user_context)));
245 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) 247 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _))
246 .Times(1) 248 .Times(1)
247 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, 249 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
248 &base::Callback<void(void)>::Run)); 250 &base::Callback<void(void)>::Run));
249 EXPECT_CALL(*mock_login_utils_,
250 DoBrowserLaunch(testing_profile_.get(),
251 mock_login_display_host_.get()))
252 .Times(1);
253 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 251 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
254 .Times(1); 252 .Times(1);
255 EXPECT_CALL(*mock_login_display_host_, 253 EXPECT_CALL(*mock_login_display_host_,
256 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL)) 254 StartWizardPtr(WizardController::kTermsOfServiceScreenName, NULL))
257 .Times(0); 255 .Times(0);
258 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 256 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
259 .Times(AnyNumber()) 257 .Times(AnyNumber())
260 .WillRepeatedly(Return(false)); 258 .WillRepeatedly(Return(false));
261 existing_user_controller()->Login(user_context, SigninSpecifics()); 259 existing_user_controller()->Login(user_context, SigninSpecifics());
262 content::RunAllPendingInMessageLoop(); 260 content::RunAllPendingInMessageLoop();
(...skipping 24 matching lines...) Expand all
287 existing_user_controller()->CompleteLogin(user_context); 285 existing_user_controller()->CompleteLogin(user_context);
288 content::RunAllPendingInMessageLoop(); 286 content::RunAllPendingInMessageLoop();
289 } 287 }
290 288
291 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, 289 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest,
292 NewUserDontAutoEnrollAfterSignIn) { 290 NewUserDontAutoEnrollAfterSignIn) {
293 EXPECT_CALL(*mock_login_display_host_, 291 EXPECT_CALL(*mock_login_display_host_,
294 StartWizardPtr(WizardController::kEnrollmentScreenName, 292 StartWizardPtr(WizardController::kEnrollmentScreenName,
295 _)) 293 _))
296 .Times(0); 294 .Times(0);
297 EXPECT_CALL(*mock_login_display_host_,
298 StartWizardPtr(WizardController::kTermsOfServiceScreenName,
299 NULL))
300 .Times(1);
301 UserContext user_context(kNewUsername); 295 UserContext user_context(kNewUsername);
302 user_context.SetKey(Key(kPassword)); 296 user_context.SetKey(Key(kPassword));
303 user_context.SetUserIDHash(kNewUsername); 297 user_context.SetUserIDHash(kNewUsername);
304 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 298 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
305 .Times(1) 299 .Times(1)
306 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); 300 .WillOnce(WithArg<0>(CreateAuthenticator(user_context)));
307 base::Callback<void(void)> add_user_cb = 301 base::Callback<void(void)> add_user_cb =
308 base::Bind(&MockUserManager::AddUser, 302 base::Bind(&MockUserManager::AddUser,
309 base::Unretained(mock_user_manager_), 303 base::Unretained(mock_user_manager_),
310 kNewUsername); 304 kNewUsername);
311 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) 305 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _))
312 .Times(1) 306 .Times(1)
313 .WillOnce(DoAll( 307 .WillOnce(DoAll(
314 InvokeWithoutArgs(&add_user_cb, 308 InvokeWithoutArgs(&add_user_cb,
315 &base::Callback<void(void)>::Run), 309 &base::Callback<void(void)>::Run),
316 InvokeWithoutArgs(&profile_prepared_cb_, 310 InvokeWithoutArgs(&profile_prepared_cb_,
317 &base::Callback<void(void)>::Run))); 311 &base::Callback<void(void)>::Run)));
318 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) 312 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin())
319 .Times(1); 313 .Times(1);
320 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 314 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
321 .Times(AnyNumber()) 315 .Times(AnyNumber())
322 .WillRepeatedly(Return(true)); 316 .WillRepeatedly(Return(true));
323 317
324 // The order of these expected calls matters: the UI if first disabled 318 // The order of these expected calls matters: the UI if first disabled
325 // during the login sequence, and is enabled again after login completion. 319 // during the login sequence, and is enabled again after login completion.
326 Sequence uiEnabledSequence; 320 Sequence uiEnabledSequence;
327 // This is disabled twice: once right after signin but before checking for 321 // This is disabled twice: once right after signin but before checking for
328 // auto-enrollment, and again after doing an ownership status check. 322 // auto-enrollment, and again after doing an ownership status check.
329 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 323 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
330 .Times(2) 324 .Times(1)
331 .InSequence(uiEnabledSequence); 325 .InSequence(uiEnabledSequence);
332 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 326 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
333 .Times(1) 327 .Times(1)
334 .InSequence(uiEnabledSequence); 328 .InSequence(uiEnabledSequence);
335 329
336 existing_user_controller()->CompleteLogin(user_context); 330 existing_user_controller()->CompleteLogin(user_context);
337 content::RunAllPendingInMessageLoop(); 331 content::RunAllPendingInMessageLoop();
338 } 332 }
339 333
340 MATCHER_P(HasDetails, expected, "") { 334 MATCHER_P(HasDetails, expected, "") {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void ExpectSuccessfulLogin(const UserContext& user_context) { 424 void ExpectSuccessfulLogin(const UserContext& user_context) {
431 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 425 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
432 .Times(AnyNumber()); 426 .Times(AnyNumber());
433 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 427 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
434 .Times(1) 428 .Times(1)
435 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); 429 .WillOnce(WithArg<0>(CreateAuthenticator(user_context)));
436 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) 430 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _))
437 .Times(1) 431 .Times(1)
438 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, 432 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
439 &base::Callback<void(void)>::Run)); 433 &base::Callback<void(void)>::Run));
440 EXPECT_CALL(*mock_login_utils_,
441 DoBrowserLaunch(testing_profile_.get(),
442 mock_login_display_host_.get()))
443 .Times(1);
444 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 434 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
445 .Times(1); 435 .Times(1);
446 EXPECT_CALL(*mock_login_display_host_, 436 EXPECT_CALL(*mock_login_display_host_,
447 StartWizardPtr(WizardController::kTermsOfServiceScreenName, 437 StartWizardPtr(WizardController::kTermsOfServiceScreenName,
448 NULL)) 438 NULL))
449 .Times(0); 439 .Times(0);
450 } 440 }
451 441
452 void SetAutoLoginPolicy(const std::string& username, int delay) { 442 void SetAutoLoginPolicy(const std::string& username, int delay) {
453 // Wait until ExistingUserController has finished auto-login 443 // Wait until ExistingUserController has finished auto-login
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 // First run propagates public accounts and stores them in Local State. 671 // First run propagates public accounts and stores them in Local State.
682 } 672 }
683 673
684 // See http://crbug.com/393704; flaky. 674 // See http://crbug.com/393704; flaky.
685 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, 675 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
686 DISABLED_TestLoadingPublicUsersFromLocalState) { 676 DISABLED_TestLoadingPublicUsersFromLocalState) {
687 // Second run loads list of public accounts from Local State. 677 // Second run loads list of public accounts from Local State.
688 } 678 }
689 679
690 } // namespace chromeos 680 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698