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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); | 56 EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AnyNumber()); |
57 EXPECT_CALL(*mock_user_manager_, FindUser(_)) | 57 EXPECT_CALL(*mock_user_manager_, FindUser(_)) |
58 .WillRepeatedly(ReturnNull()); | 58 .WillRepeatedly(ReturnNull()); |
59 EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_account_id_)) | 59 EXPECT_CALL(*mock_user_manager_, FindUser(auto_login_account_id_)) |
60 .WillRepeatedly(Return(mock_user_manager_->CreatePublicAccountUser( | 60 .WillRepeatedly(Return(mock_user_manager_->CreatePublicAccountUser( |
61 auto_login_account_id_))); | 61 auto_login_account_id_))); |
62 | 62 |
63 existing_user_controller_.reset( | 63 existing_user_controller_.reset( |
64 new ExistingUserController(mock_login_display_host_.get())); | 64 new ExistingUserController(mock_login_display_host_.get())); |
65 | 65 |
66 scoped_ptr<base::DictionaryValue> account(new base::DictionaryValue); | 66 std::unique_ptr<base::DictionaryValue> account(new base::DictionaryValue); |
67 account->SetStringWithoutPathExpansion( | 67 account->SetStringWithoutPathExpansion( |
68 kAccountsPrefDeviceLocalAccountsKeyId, auto_login_user_id_); | 68 kAccountsPrefDeviceLocalAccountsKeyId, auto_login_user_id_); |
69 account->SetIntegerWithoutPathExpansion( | 69 account->SetIntegerWithoutPathExpansion( |
70 kAccountsPrefDeviceLocalAccountsKeyType, | 70 kAccountsPrefDeviceLocalAccountsKeyType, |
71 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); | 71 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); |
72 base::ListValue accounts; | 72 base::ListValue accounts; |
73 accounts.Append(account.release()); | 73 accounts.Append(account.release()); |
74 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, accounts); | 74 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, accounts); |
75 | 75 |
76 // Prevent settings changes from auto-starting the timer. | 76 // Prevent settings changes from auto-starting the timer. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const AccountId auto_login_account_id_ = | 133 const AccountId auto_login_account_id_ = |
134 AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( | 134 AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( |
135 auto_login_user_id_, | 135 auto_login_user_id_, |
136 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)); | 136 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)); |
137 | 137 |
138 private: | 138 private: |
139 // |mock_login_display_| is owned by the ExistingUserController, which calls | 139 // |mock_login_display_| is owned by the ExistingUserController, which calls |
140 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 140 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
141 MockLoginDisplay* mock_login_display_; | 141 MockLoginDisplay* mock_login_display_; |
142 | 142 |
143 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; | 143 std::unique_ptr<MockLoginDisplayHost> mock_login_display_host_; |
144 base::MessageLoopForUI message_loop_; | 144 base::MessageLoopForUI message_loop_; |
145 content::TestBrowserThread ui_thread_; | 145 content::TestBrowserThread ui_thread_; |
146 ScopedTestingLocalState local_state_; | 146 ScopedTestingLocalState local_state_; |
147 | 147 |
148 // Required by ExistingUserController: | 148 // Required by ExistingUserController: |
149 ScopedDeviceSettingsTestHelper device_settings_test_helper_; | 149 ScopedDeviceSettingsTestHelper device_settings_test_helper_; |
150 ScopedTestCrosSettings test_cros_settings_; | 150 ScopedTestCrosSettings test_cros_settings_; |
151 MockUserManager* mock_user_manager_; | 151 MockUserManager* mock_user_manager_; |
152 ScopedUserManagerEnabler scoped_user_manager_; | 152 ScopedUserManagerEnabler scoped_user_manager_; |
153 | 153 |
154 // |existing_user_controller_| must be destroyed before | 154 // |existing_user_controller_| must be destroyed before |
155 // |device_settings_test_helper_|. | 155 // |device_settings_test_helper_|. |
156 scoped_ptr<ExistingUserController> existing_user_controller_; | 156 std::unique_ptr<ExistingUserController> existing_user_controller_; |
157 }; | 157 }; |
158 | 158 |
159 TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { | 159 TEST_F(ExistingUserControllerAutoLoginTest, StartAutoLoginTimer) { |
160 // Timer shouldn't start until signin screen is ready. | 160 // Timer shouldn't start until signin screen is ready. |
161 set_auto_login_account_id(auto_login_account_id_); | 161 set_auto_login_account_id(auto_login_account_id_); |
162 set_auto_login_delay(kAutoLoginDelay2); | 162 set_auto_login_delay(kAutoLoginDelay2); |
163 existing_user_controller()->StartPublicSessionAutoLoginTimer(); | 163 existing_user_controller()->StartPublicSessionAutoLoginTimer(); |
164 EXPECT_FALSE(auto_login_timer()); | 164 EXPECT_FALSE(auto_login_timer()); |
165 | 165 |
166 // Timer shouldn't start if the policy isn't set. | 166 // Timer shouldn't start if the policy isn't set. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ConfigureAutoLogin(); | 268 ConfigureAutoLogin(); |
269 ASSERT_TRUE(auto_login_timer()); | 269 ASSERT_TRUE(auto_login_timer()); |
270 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 270 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
271 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), | 271 EXPECT_EQ(auto_login_timer()->GetCurrentDelay().InMilliseconds(), |
272 kAutoLoginDelay2); | 272 kAutoLoginDelay2); |
273 EXPECT_EQ(auto_login_account_id(), EmptyAccountId()); | 273 EXPECT_EQ(auto_login_account_id(), EmptyAccountId()); |
274 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); | 274 EXPECT_EQ(auto_login_delay(), kAutoLoginDelay2); |
275 } | 275 } |
276 | 276 |
277 } // namespace chromeos | 277 } // namespace chromeos |
OLD | NEW |