Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 9 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 10 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" | 10 #include "chrome/browser/chromeos/login/ui/mock_login_display.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 // delay the test. | 35 // delay the test. |
| 36 const int kAutoLoginDelay1 = 60000; | 36 const int kAutoLoginDelay1 = 60000; |
| 37 const int kAutoLoginDelay2 = 180000; | 37 const int kAutoLoginDelay2 = 180000; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 class ExistingUserControllerAutoLoginTest : public ::testing::Test { | 41 class ExistingUserControllerAutoLoginTest : public ::testing::Test { |
| 42 protected: | 42 protected: |
| 43 ExistingUserControllerAutoLoginTest() | 43 ExistingUserControllerAutoLoginTest() |
| 44 : auto_login_user_id_(policy::GenerateDeviceLocalAccountUserId( | 44 : auto_login_user_id_(policy::GenerateDeviceLocalAccountUserId( |
| 45 kAutoLoginAccountId, | 45 kAutoLoginAccountId, |
|
achuithb
2015/10/23 00:08:49
Does this need to be changed as well?
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
| 46 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)), | 46 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
| 47 ui_thread_(content::BrowserThread::UI, &message_loop_), | 47 ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 48 local_state_(TestingBrowserProcess::GetGlobal()), | 48 local_state_(TestingBrowserProcess::GetGlobal()), |
| 49 mock_user_manager_(new MockUserManager()), | 49 mock_user_manager_(new MockUserManager()), |
| 50 scoped_user_manager_(mock_user_manager_) { | 50 scoped_user_manager_(mock_user_manager_) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SetUp() override { | 53 void SetUp() override { |
| 54 mock_login_display_host_.reset(new MockLoginDisplayHost); | 54 mock_login_display_host_.reset(new MockLoginDisplayHost); |
| 55 mock_login_display_ = new MockLoginDisplay(); | 55 mock_login_display_ = new MockLoginDisplay(); |
| 56 | 56 |
| 57 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) | 57 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) |
| 58 .Times(1) | 58 .Times(1) |
| 59 .WillOnce(Return(mock_login_display_)); | 59 .WillOnce(Return(mock_login_display_)); |
| 60 | 60 |
| 61 EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); | 61 EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); |
| 62 EXPECT_CALL(*mock_user_manager_, FindUser(_)) | 62 EXPECT_CALL(*mock_user_manager_, FindUser(_)) |
| 63 .WillRepeatedly(ReturnNull()); | 63 .WillRepeatedly(ReturnNull()); |
| 64 EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_user_id_)) | 64 EXPECT_CALL(*mock_user_manager_, |
| 65 .WillRepeatedly(Return( | 65 FindUser(AccountId::FromUserEmail(auto_login_user_id_))) |
| 66 mock_user_manager_->CreatePublicAccountUser(auto_login_user_id_))); | 66 .WillRepeatedly(Return(mock_user_manager_->CreatePublicAccountUser( |
| 67 AccountId::FromUserEmail(auto_login_user_id_)))); | |
| 67 | 68 |
| 68 existing_user_controller_.reset( | 69 existing_user_controller_.reset( |
| 69 new ExistingUserController(mock_login_display_host_.get())); | 70 new ExistingUserController(mock_login_display_host_.get())); |
| 70 | 71 |
| 71 scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue); | 72 scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue); |
| 72 account->SetStringWithoutPathExpansion( | 73 account->SetStringWithoutPathExpansion( |
| 73 kAccountsPrefDeviceLocalAccountsKeyId, | 74 kAccountsPrefDeviceLocalAccountsKeyId, |
| 74 kAutoLoginAccountId); | 75 kAutoLoginAccountId); |
|
achuithb
2015/10/23 00:08:49
and here?
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
| 75 account->SetIntegerWithoutPathExpansion( | 76 account->SetIntegerWithoutPathExpansion( |
| 76 kAccountsPrefDeviceLocalAccountsKeyType, | 77 kAccountsPrefDeviceLocalAccountsKeyType, |
| 77 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); | 78 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
| 78 base::ListValue accounts; | 79 base::ListValue accounts; |
| 79 accounts.Append(account.release()); | 80 accounts.Append(account.release()); |
| 80 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, accounts); | 81 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, accounts); |
| 81 | 82 |
| 82 // Prevent settings changes from auto-starting the timer. | 83 // Prevent settings changes from auto-starting the timer. |
| 83 existing_user_controller_-> | 84 existing_user_controller_-> |
| 84 local_account_auto_login_id_subscription_.reset(); | 85 local_account_auto_login_id_subscription_.reset(); |
| 85 existing_user_controller_-> | 86 existing_user_controller_-> |
| 86 local_account_auto_login_delay_subscription_.reset(); | 87 local_account_auto_login_delay_subscription_.reset(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 const ExistingUserController* existing_user_controller() const { | 90 const ExistingUserController* existing_user_controller() const { |
| 90 return ExistingUserController::current_controller(); | 91 return ExistingUserController::current_controller(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 ExistingUserController* existing_user_controller() { | 94 ExistingUserController* existing_user_controller() { |
| 94 return ExistingUserController::current_controller(); | 95 return ExistingUserController::current_controller(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void SetAutoLoginSettings(const std::string& account_id, int delay) { | 98 void SetAutoLoginSettings(const std::string& account_id, int delay) { |
|
achuithb
2015/10/23 00:08:49
here too?
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
| 98 CrosSettings::Get()->SetString( | 99 CrosSettings::Get()->SetString( |
| 99 kAccountsPrefDeviceLocalAccountAutoLoginId, | 100 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 100 account_id); | 101 account_id); |
| 101 CrosSettings::Get()->SetInteger( | 102 CrosSettings::Get()->SetInteger( |
| 102 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 103 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
| 103 delay); | 104 delay); |
| 104 } | 105 } |
| 105 | 106 |
| 106 // ExistingUserController private member accessors. | 107 // ExistingUserController private member accessors. |
| 107 base::OneShotTimer* auto_login_timer() { | 108 base::OneShotTimer* auto_login_timer() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 ConfigureAutoLogin(); | 269 ConfigureAutoLogin(); |
| 269 ASSERT_TRUE(auto_login_timer()); | 270 ASSERT_TRUE(auto_login_timer()); |
| 270 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 271 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
| 271 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), | 272 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), |
| 272 kAutoLoginDelay2); | 273 kAutoLoginDelay2); |
| 273 EXPECT_EQ(auto_login_username(), ""); | 274 EXPECT_EQ(auto_login_username(), ""); |
| 274 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); | 275 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace chromeos | 278 } // namespace chromeos |
| OLD | NEW |