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

Unified Diff: chrome/browser/chromeos/login/existing_user_controller_auto_login_unittest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Update after review. Created 5 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 side-by-side diff with in-line comments
Download patch
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..6d02dd67c735610501265bfa0810b9e0a49e5bd4 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,9 +56,9 @@ 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()));
@@ -71,7 +66,7 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test {
scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue);
account->SetStringWithoutPathExpansion(
kAccountsPrefDeviceLocalAccountsKeyId,
- kAutoLoginAccountId);
+ auto_login_account_id_.GetUserEmail());
account->SetIntegerWithoutPathExpansion(
kAccountsPrefDeviceLocalAccountsKeyType,
policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION);
@@ -94,10 +89,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 AccountId& account_id, int delay) {
+ CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
+ account_id.GetUserEmail());
CrosSettings::Get()->SetInteger(
kAccountsPrefDeviceLocalAccountAutoLoginDelay,
delay);
@@ -133,7 +127,10 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test {
existing_user_controller()->ConfigurePublicSessionAutoLogin();
}
- const std::string auto_login_user_id_;
+ const AccountId auto_login_account_id_ =
+ AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId(
+ "public_session_user@localhost",
+ policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION));
private:
// |mock_login_display_| is owned by the ExistingUserController, which calls
@@ -158,7 +155,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 +167,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 +183,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 +197,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());
@@ -237,34 +234,34 @@ TEST_F(ExistingUserControllerAutoLoginTest, ConfigureAutoLogin) {
EXPECT_EQ(auto_login_username(), "");
// Timer shouldn't start when the delay alone is set.
- SetAutoLoginSettings("", kAutoLoginDelay1);
+ SetAutoLoginSettings(EmptyAccountId(), kAutoLoginDelay1);
ConfigureAutoLogin();
EXPECT_FALSE(auto_login_timer());
EXPECT_EQ(auto_login_delay(), kAutoLoginDelay1);
EXPECT_EQ(auto_login_username(), "");
// Timer should start when the account ID is set.
- SetAutoLoginSettings(kAutoLoginAccountId, kAutoLoginDelay1);
+ SetAutoLoginSettings(auto_login_account_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_account_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);
+ SetAutoLoginSettings(EmptyAccountId(), kAutoLoginDelay2);
ConfigureAutoLogin();
ASSERT_TRUE(auto_login_timer());
EXPECT_FALSE(auto_login_timer()->IsRunning());

Powered by Google App Engine
This is Rietveld 408576698