Index: chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc |
diff --git a/chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc b/chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc |
index 3d6ff7fc0a5b7e1841b072cb602bdcd32651ae9e..072545379a9634bac165eae320472c3aae6f0f83 100644 |
--- a/chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc |
+++ b/chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc |
@@ -30,6 +30,7 @@ |
namespace { |
+const char kAutoLoginAccountId[] = "public_session_user@localhost"; |
// These values are only used to test the configuration. They don't |
// delay the test. |
const int kAutoLoginDelay1 = 60000; |
@@ -40,10 +41,14 @@ |
class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
protected: |
ExistingUserControllerAutoLoginTest() |
- : ui_thread_(content::BrowserThread::UI, &message_loop_), |
+ : auto_login_user_id_(policy::GenerateDeviceLocalAccountUserId( |
+ kAutoLoginAccountId, |
+ policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
+ ui_thread_(content::BrowserThread::UI, &message_loop_), |
local_state_(TestingBrowserProcess::GetGlobal()), |
mock_user_manager_(new MockUserManager()), |
- scoped_user_manager_(mock_user_manager_) {} |
+ scoped_user_manager_(mock_user_manager_) { |
+ } |
void SetUp() override { |
mock_login_display_host_.reset(new MockLoginDisplayHost); |
@@ -56,16 +61,17 @@ |
EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); |
EXPECT_CALL(*mock_user_manager_, FindUser(_)) |
.WillRepeatedly(ReturnNull()); |
- EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_account_id_)) |
- .WillRepeatedly(Return(mock_user_manager_->CreatePublicAccountUser( |
- auto_login_account_id_))); |
+ EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_user_id_)) |
+ .WillRepeatedly(Return( |
+ mock_user_manager_->CreatePublicAccountUser(auto_login_user_id_))); |
existing_user_controller_.reset( |
new ExistingUserController(mock_login_display_host_.get())); |
scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue); |
account->SetStringWithoutPathExpansion( |
- kAccountsPrefDeviceLocalAccountsKeyId, auto_login_user_id_); |
+ kAccountsPrefDeviceLocalAccountsKeyId, |
+ kAutoLoginAccountId); |
account->SetIntegerWithoutPathExpansion( |
kAccountsPrefDeviceLocalAccountsKeyType, |
policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
@@ -88,9 +94,10 @@ |
return ExistingUserController::current_controller(); |
} |
- void SetAutoLoginSettings(const std::string& user_id, int delay) { |
- CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
- user_id); |
+ void SetAutoLoginSettings(const std::string& account_id, int delay) { |
+ CrosSettings::Get()->SetString( |
+ kAccountsPrefDeviceLocalAccountAutoLoginId, |
+ account_id); |
CrosSettings::Get()->SetInteger( |
kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
delay); |
@@ -126,13 +133,7 @@ |
existing_user_controller()->ConfigurePublicSessionAutoLogin(); |
} |
- const std::string auto_login_user_id_ = |
- std::string("public_session_user@localhost"); |
- |
- const AccountId auto_login_account_id_ = |
- AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( |
- auto_login_user_id_, |
- policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)); |
+ const std::string auto_login_user_id_; |
private: |
// |mock_login_display_| is owned by the ExistingUserController, which calls |
@@ -157,7 +158,7 @@ |
TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { |
// Timer shouldn't start until signin screen is ready. |
- set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
+ set_auto_login_username(auto_login_user_id_); |
set_auto_login_delay(kAutoLoginDelay2); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
EXPECT_FALSE(auto_login_timer()); |
@@ -169,7 +170,7 @@ |
EXPECT_FALSE(auto_login_timer()); |
// Timer shouldn't fire in the middle of a login attempt. |
- set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
+ set_auto_login_username(auto_login_user_id_); |
set_is_login_in_progress(true); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
EXPECT_FALSE(auto_login_timer()); |
@@ -185,7 +186,7 @@ |
TEST_F(ExistingUserControllerAutoLoginTest, StopAutoLoginTimer) { |
existing_user_controller()->OnSigninScreenReady(); |
- set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
+ set_auto_login_username(auto_login_user_id_); |
set_auto_login_delay(kAutoLoginDelay2); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
@@ -199,7 +200,7 @@ |
TEST_F(ExistingUserControllerAutoLoginTest, ResetAutoLoginTimer) { |
existing_user_controller()->OnSigninScreenReady(); |
- set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
+ set_auto_login_username(auto_login_user_id_); |
// Timer starts off not running. |
EXPECT_FALSE(auto_login_timer()); |
@@ -243,24 +244,24 @@ |
EXPECT_EQ(auto_login_username(), ""); |
// Timer should start when the account ID is set. |
- SetAutoLoginSettings(auto_login_user_id_, kAutoLoginDelay1); |
+ SetAutoLoginSettings(kAutoLoginAccountId, kAutoLoginDelay1); |
ConfigureAutoLogin(); |
ASSERT_TRUE(auto_login_timer()); |
EXPECT_TRUE(auto_login_timer()->IsRunning()); |
EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), |
kAutoLoginDelay1); |
EXPECT_EQ(auto_login_delay(), kAutoLoginDelay1); |
- EXPECT_EQ(auto_login_username(), auto_login_account_id_.GetUserEmail()); |
+ EXPECT_EQ(auto_login_username(), auto_login_user_id_); |
// Timer should restart when the delay is changed. |
- SetAutoLoginSettings(auto_login_user_id_, kAutoLoginDelay2); |
+ SetAutoLoginSettings(kAutoLoginAccountId, kAutoLoginDelay2); |
ConfigureAutoLogin(); |
ASSERT_TRUE(auto_login_timer()); |
EXPECT_TRUE(auto_login_timer()->IsRunning()); |
EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), |
kAutoLoginDelay2); |
EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); |
- EXPECT_EQ(auto_login_username(), auto_login_account_id_.GetUserEmail()); |
+ EXPECT_EQ(auto_login_username(), auto_login_user_id_); |
// Timer should stop when the account ID is unset. |
SetAutoLoginSettings("", kAutoLoginDelay2); |