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 072545379a9634bac165eae320472c3aae6f0f83..3d6ff7fc0a5b7e1841b072cb602bdcd32651ae9e 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,7 +30,6 @@ namespace chromeos { |
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; |
@@ -41,14 +40,10 @@ const int kAutoLoginDelay2 = 180000; |
class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
protected: |
ExistingUserControllerAutoLoginTest() |
- : auto_login_user_id_(policy::GenerateDeviceLocalAccountUserId( |
- kAutoLoginAccountId, |
- policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
- ui_thread_(content::BrowserThread::UI, &message_loop_), |
+ : 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); |
@@ -61,17 +56,16 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); |
EXPECT_CALL(*mock_user_manager_, FindUser(_)) |
.WillRepeatedly(ReturnNull()); |
- EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_user_id_)) |
- .WillRepeatedly(Return( |
- mock_user_manager_->CreatePublicAccountUser(auto_login_user_id_))); |
+ EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_account_id_)) |
+ .WillRepeatedly(Return(mock_user_manager_->CreatePublicAccountUser( |
+ auto_login_account_id_))); |
existing_user_controller_.reset( |
new ExistingUserController(mock_login_display_host_.get())); |
scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue); |
account->SetStringWithoutPathExpansion( |
- kAccountsPrefDeviceLocalAccountsKeyId, |
- kAutoLoginAccountId); |
+ kAccountsPrefDeviceLocalAccountsKeyId, auto_login_user_id_); |
account->SetIntegerWithoutPathExpansion( |
kAccountsPrefDeviceLocalAccountsKeyType, |
policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
@@ -94,10 +88,9 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
return ExistingUserController::current_controller(); |
} |
- void SetAutoLoginSettings(const std::string& account_id, int delay) { |
- CrosSettings::Get()->SetString( |
- kAccountsPrefDeviceLocalAccountAutoLoginId, |
- account_id); |
+ void SetAutoLoginSettings(const std::string& user_id, int delay) { |
+ CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
+ user_id); |
CrosSettings::Get()->SetInteger( |
kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
delay); |
@@ -133,7 +126,13 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
existing_user_controller()->ConfigurePublicSessionAutoLogin(); |
} |
- const std::string auto_login_user_id_; |
+ 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)); |
private: |
// |mock_login_display_| is owned by the ExistingUserController, which calls |
@@ -158,7 +157,7 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { |
// Timer shouldn't start until signin screen is ready. |
- set_auto_login_username(auto_login_user_id_); |
+ set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
set_auto_login_delay(kAutoLoginDelay2); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
EXPECT_FALSE(auto_login_timer()); |
@@ -170,7 +169,7 @@ TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { |
EXPECT_FALSE(auto_login_timer()); |
// Timer shouldn't fire in the middle of a login attempt. |
- set_auto_login_username(auto_login_user_id_); |
+ set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
set_is_login_in_progress(true); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
EXPECT_FALSE(auto_login_timer()); |
@@ -186,7 +185,7 @@ TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { |
TEST_F(ExistingUserControllerAutoLoginTest, StopAutoLoginTimer) { |
existing_user_controller()->OnSigninScreenReady(); |
- set_auto_login_username(auto_login_user_id_); |
+ set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
set_auto_login_delay(kAutoLoginDelay2); |
existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
@@ -200,7 +199,7 @@ TEST_F(ExistingUserControllerAutoLoginTest, StopAutoLoginTimer) { |
TEST_F(ExistingUserControllerAutoLoginTest, ResetAutoLoginTimer) { |
existing_user_controller()->OnSigninScreenReady(); |
- set_auto_login_username(auto_login_user_id_); |
+ set_auto_login_username(auto_login_account_id_.GetUserEmail()); |
// Timer starts off not running. |
EXPECT_FALSE(auto_login_timer()); |
@@ -244,24 +243,24 @@ TEST_F(ExistingUserControllerAutoLoginTest, ConfigureAutoLogin) { |
EXPECT_EQ(auto_login_username(), ""); |
// Timer should start when the account ID is set. |
- SetAutoLoginSettings(kAutoLoginAccountId, kAutoLoginDelay1); |
+ SetAutoLoginSettings(auto_login_user_id_, 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_user_id_); |
+ EXPECT_EQ(auto_login_username(), auto_login_account_id_.GetUserEmail()); |
// Timer should restart when the delay is changed. |
- SetAutoLoginSettings(kAutoLoginAccountId, kAutoLoginDelay2); |
+ SetAutoLoginSettings(auto_login_user_id_, 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_user_id_); |
+ EXPECT_EQ(auto_login_username(), auto_login_account_id_.GetUserEmail()); |
// Timer should stop when the account ID is unset. |
SetAutoLoginSettings("", kAutoLoginDelay2); |