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

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

Issue 10590004: [cros] Fake a stub user login when no --login-manager and --login-user are given. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further test fixes. Created 8 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 392
393 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); 393 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
394 }; 394 };
395 395
396 class LoginUtilsBlockingLoginTest 396 class LoginUtilsBlockingLoginTest
397 : public LoginUtilsTest, 397 : public LoginUtilsTest,
398 public testing::WithParamInterface<int> {}; 398 public testing::WithParamInterface<int> {};
399 399
400 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { 400 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) {
401 UserManager* user_manager = UserManager::Get(); 401 UserManager* user_manager = UserManager::Get();
402 ASSERT_TRUE(!user_manager->IsUserLoggedIn() || 402 ASSERT_TRUE(!user_manager->IsUserLoggedIn());
403 user_manager->IsLoggedInAsStub());
404 EXPECT_FALSE(connector_->IsEnterpriseManaged()); 403 EXPECT_FALSE(connector_->IsEnterpriseManaged());
405 EXPECT_FALSE(prepared_profile_); 404 EXPECT_FALSE(prepared_profile_);
406 405
407 // The profile will be created without waiting for a policy response. 406 // The profile will be created without waiting for a policy response.
408 PrepareProfile(kUsername); 407 PrepareProfile(kUsername);
409 408
410 EXPECT_TRUE(prepared_profile_); 409 EXPECT_TRUE(prepared_profile_);
411 ASSERT_TRUE(user_manager->IsUserLoggedIn() && 410 ASSERT_TRUE(user_manager->IsUserLoggedIn());
412 !user_manager->IsLoggedInAsStub());
413 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser().email()); 411 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser().email());
414 } 412 }
415 413
416 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { 414 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) {
417 UserManager* user_manager = UserManager::Get(); 415 UserManager* user_manager = UserManager::Get();
418 ASSERT_TRUE(!user_manager->IsUserLoggedIn() || 416 ASSERT_TRUE(!user_manager->IsUserLoggedIn());
419 user_manager->IsLoggedInAsStub());
420 EXPECT_FALSE(connector_->IsEnterpriseManaged()); 417 EXPECT_FALSE(connector_->IsEnterpriseManaged());
421 EXPECT_FALSE(prepared_profile_); 418 EXPECT_FALSE(prepared_profile_);
422 419
423 // Enroll the device. 420 // Enroll the device.
424 LockDevice(kUsername); 421 LockDevice(kUsername);
425 422
426 ASSERT_TRUE(!user_manager->IsUserLoggedIn() || 423 ASSERT_TRUE(!user_manager->IsUserLoggedIn());
427 user_manager->IsLoggedInAsStub());
428 EXPECT_TRUE(connector_->IsEnterpriseManaged()); 424 EXPECT_TRUE(connector_->IsEnterpriseManaged());
429 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); 425 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
430 EXPECT_FALSE(prepared_profile_); 426 EXPECT_FALSE(prepared_profile_);
431 427
432 // Login with a non-enterprise user shouldn't block. 428 // Login with a non-enterprise user shouldn't block.
433 PrepareProfile(kUsernameOtherDomain); 429 PrepareProfile(kUsernameOtherDomain);
434 430
435 EXPECT_TRUE(prepared_profile_); 431 EXPECT_TRUE(prepared_profile_);
436 ASSERT_TRUE(user_manager->IsUserLoggedIn() && 432 ASSERT_TRUE(user_manager->IsUserLoggedIn());
437 !user_manager->IsLoggedInAsStub());
438 EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser().email()); 433 EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser().email());
439 } 434 }
440 435
441 TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) { 436 TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) {
442 UserManager* user_manager = UserManager::Get(); 437 UserManager* user_manager = UserManager::Get();
443 ASSERT_TRUE(!user_manager->IsUserLoggedIn() || 438 ASSERT_TRUE(!user_manager->IsUserLoggedIn());
444 user_manager->IsLoggedInAsStub());
445 EXPECT_FALSE(connector_->IsEnterpriseManaged()); 439 EXPECT_FALSE(connector_->IsEnterpriseManaged());
446 EXPECT_FALSE(prepared_profile_); 440 EXPECT_FALSE(prepared_profile_);
447 441
448 // Enroll the device. 442 // Enroll the device.
449 LockDevice(kUsername); 443 LockDevice(kUsername);
450 444
451 ASSERT_TRUE(!user_manager->IsUserLoggedIn() || 445 ASSERT_TRUE(!user_manager->IsUserLoggedIn());
452 user_manager->IsLoggedInAsStub());
453 EXPECT_TRUE(connector_->IsEnterpriseManaged()); 446 EXPECT_TRUE(connector_->IsEnterpriseManaged());
454 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); 447 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
455 EXPECT_FALSE(prepared_profile_); 448 EXPECT_FALSE(prepared_profile_);
456 449
457 // Login with a user of the enterprise domain waits for policy. 450 // Login with a user of the enterprise domain waits for policy.
458 PrepareProfile(kUsername); 451 PrepareProfile(kUsername);
459 452
460 EXPECT_FALSE(prepared_profile_); 453 EXPECT_FALSE(prepared_profile_);
461 ASSERT_TRUE(user_manager->IsUserLoggedIn() && 454 ASSERT_TRUE(user_manager->IsUserLoggedIn());
462 !user_manager->IsLoggedInAsStub());
463 455
464 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); 456 GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
465 net::TestURLFetcher* fetcher; 457 net::TestURLFetcher* fetcher;
466 458
467 // |steps| is the test parameter, and is the number of successful fetches. 459 // |steps| is the test parameter, and is the number of successful fetches.
468 // The first incomplete fetch will fail. In any case, the profile creation 460 // The first incomplete fetch will fail. In any case, the profile creation
469 // should resume. 461 // should resume.
470 int steps = GetParam(); 462 int steps = GetParam();
471 463
472 do { 464 do {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 519 }
528 520
529 INSTANTIATE_TEST_CASE_P( 521 INSTANTIATE_TEST_CASE_P(
530 LoginUtilsBlockingLoginTestInstance, 522 LoginUtilsBlockingLoginTestInstance,
531 LoginUtilsBlockingLoginTest, 523 LoginUtilsBlockingLoginTest,
532 testing::Values(0, 1, 2, 3, 4, 5)); 524 testing::Values(0, 1, 2, 3, 4, 5));
533 525
534 } // namespace 526 } // namespace
535 527
536 } 528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698