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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller_browsertest.cc

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: shorten timer delay in test; add two more stop/start timer cases Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h"
6 #include "base/command_line.h" 7 #include "base/command_line.h"
7 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h"
11 #include "base/stl_util.h"
9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" 12 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
10 #include "chrome/browser/chromeos/cros/cros_mock.h" 13 #include "chrome/browser/chromeos/cros/cros_mock.h"
11 #include "chrome/browser/chromeos/cros/mock_network_library.h" 14 #include "chrome/browser/chromeos/cros/mock_network_library.h"
12 #include "chrome/browser/chromeos/login/existing_user_controller.h" 15 #include "chrome/browser/chromeos/login/existing_user_controller.h"
13 #include "chrome/browser/chromeos/login/helper.h" 16 #include "chrome/browser/chromeos/login/helper.h"
14 #include "chrome/browser/chromeos/login/login_display.h" 17 #include "chrome/browser/chromeos/login/login_display.h"
15 #include "chrome/browser/chromeos/login/login_display_host.h" 18 #include "chrome/browser/chromeos/login/login_display_host.h"
16 #include "chrome/browser/chromeos/login/login_performer.h" 19 #include "chrome/browser/chromeos/login/login_performer.h"
17 #include "chrome/browser/chromeos/login/login_status_consumer.h" 20 #include "chrome/browser/chromeos/login/login_status_consumer.h"
18 #include "chrome/browser/chromeos/login/login_utils.h" 21 #include "chrome/browser/chromeos/login/login_utils.h"
19 #include "chrome/browser/chromeos/login/mock_authenticator.h" 22 #include "chrome/browser/chromeos/login/mock_authenticator.h"
23 #include "chrome/browser/chromeos/login/mock_login_display.h"
24 #include "chrome/browser/chromeos/login/mock_login_display_host.h"
20 #include "chrome/browser/chromeos/login/mock_login_utils.h" 25 #include "chrome/browser/chromeos/login/mock_login_utils.h"
21 #include "chrome/browser/chromeos/login/mock_url_fetchers.h" 26 #include "chrome/browser/chromeos/login/mock_url_fetchers.h"
22 #include "chrome/browser/chromeos/login/mock_user_manager.h" 27 #include "chrome/browser/chromeos/login/mock_user_manager.h"
23 #include "chrome/browser/chromeos/login/wizard_controller.h" 28 #include "chrome/browser/chromeos/login/wizard_controller.h"
29 #include "chrome/browser/chromeos/settings/cros_settings.h"
30 #include "chrome/browser/policy/browser_policy_connector.h"
31 #include "chrome/browser/policy/cloud_policy_constants.h"
32 #include "chrome/browser/policy/cloud_policy_store.h"
33 #include "chrome/browser/policy/device_local_account_policy_service.h"
34 #include "chrome/browser/policy/mock_cloud_policy_store.h"
35 #include "chrome/browser/policy/policy_builder.h"
36 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h"
37 #include "chrome/common/chrome_notification_types.h"
38 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_profile.h" 41 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/ui_test_utils.h" 42 #include "chrome/test/base/ui_test_utils.h"
43 #include "chromeos/dbus/fake_session_manager_client.h"
27 #include "chromeos/dbus/mock_dbus_thread_manager.h" 44 #include "chromeos/dbus/mock_dbus_thread_manager.h"
28 #include "chromeos/dbus/mock_session_manager_client.h" 45 #include "chromeos/dbus/mock_session_manager_client.h"
29 #include "chromeos/dbus/mock_shill_manager_client.h" 46 #include "chromeos/dbus/mock_shill_manager_client.h"
47 #include "content/public/test/mock_notification_observer.h"
48 #include "content/public/test/notification_watcher.h"
30 #include "google_apis/gaia/mock_url_fetcher_factory.h" 49 #include "google_apis/gaia/mock_url_fetcher_factory.h"
31 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
32 #include "testing/gmock/include/gmock/gmock.h" 51 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
34 #include "ui/base/l10n/l10n_util.h" 53 #include "ui/base/l10n/l10n_util.h"
35 54
36 using ::testing::_; 55 using ::testing::_;
37 using ::testing::AnyNumber; 56 using ::testing::AnyNumber;
38 using ::testing::AnyOf; 57 using ::testing::AnyOf;
39 using ::testing::Invoke; 58 using ::testing::Invoke;
40 using ::testing::InvokeWithoutArgs; 59 using ::testing::InvokeWithoutArgs;
41 using ::testing::Return; 60 using ::testing::Return;
61 using ::testing::ReturnRef;
42 using ::testing::ReturnNull; 62 using ::testing::ReturnNull;
43 using ::testing::Sequence; 63 using ::testing::Sequence;
44 using ::testing::WithArg; 64 using ::testing::WithArg;
45 65
66 namespace em = enterprise_management;
67
46 namespace chromeos { 68 namespace chromeos {
47 69
48 namespace { 70 namespace {
49 71
50 const char kUsername[] = "test_user@gmail.com"; 72 const char kUsername[] = "test_user@gmail.com";
51 const char kNewUsername[] = "test_new_user@gmail.com"; 73 const char kNewUsername[] = "test_new_user@gmail.com";
52 const char kPassword[] = "test_password"; 74 const char kPassword[] = "test_password";
53 75
54 class MockLoginDisplay : public LoginDisplay { 76 const char kAutoLoginUsername[] = "public_session_user@localhost";
55 public: 77 const int kAutoLoginNoDelay = 0;
56 MockLoginDisplay() 78 const int kAutoLoginShortDelay = 5;
57 : LoginDisplay(NULL, gfx::Rect()) { 79 const int kAutoLoginLongDelay = 10000;
58 }
59
60 MOCK_METHOD4(Init, void(const UserList&, bool, bool, bool));
61 MOCK_METHOD0(OnPreferencesChanged, void(void));
62 MOCK_METHOD1(OnUserImageChanged, void(const User&));
63 MOCK_METHOD0(OnFadeOut, void(void));
64 MOCK_METHOD1(OnLoginSuccess, void(const std::string&));
65 MOCK_METHOD1(SetUIEnabled, void(bool));
66 MOCK_METHOD1(SelectPod, void(int));
67 MOCK_METHOD3(ShowError, void(int, int, HelpAppLauncher::HelpTopic));
68 MOCK_METHOD1(ShowErrorScreen, void(LoginDisplay::SigninError));
69 MOCK_METHOD1(ShowGaiaPasswordChanged, void(const std::string&));
70 MOCK_METHOD1(ShowPasswordChangedDialog, void(bool));
71 MOCK_METHOD1(ShowSigninUI, void(const std::string&));
72 MOCK_METHOD1(OnBeforeUserRemoved, void(const std::string&));
73 MOCK_METHOD1(OnUserRemoved, void(const std::string&));
74
75 private:
76 DISALLOW_COPY_AND_ASSIGN(MockLoginDisplay);
77 };
78
79 class MockLoginDisplayHost : public LoginDisplayHost {
80 public:
81 MockLoginDisplayHost() {
82 }
83
84 MOCK_METHOD1(CreateLoginDisplay, LoginDisplay*(LoginDisplay::Delegate*));
85 MOCK_CONST_METHOD0(GetNativeWindow, gfx::NativeWindow(void));
86 MOCK_CONST_METHOD0(GetWidget, views::Widget*(void));
87 MOCK_METHOD0(BeforeSessionStart, void(void));
88 MOCK_METHOD0(OnSessionStart, void(void));
89 MOCK_METHOD0(OnCompleteLogin, void(void));
90 MOCK_METHOD0(OpenProxySettings, void(void));
91 MOCK_METHOD1(SetOobeProgressBarVisible, void(bool));
92 MOCK_METHOD1(SetShutdownButtonEnabled, void(bool));
93 MOCK_METHOD1(SetStatusAreaVisible, void(bool));
94 MOCK_METHOD0(ShowBackground, void(void));
95 MOCK_METHOD0(CheckForAutoEnrollment, void(void));
96 MOCK_METHOD2(StartWizard, void(const std::string&, DictionaryValue*));
97 MOCK_METHOD0(StartSignInScreen, void(void));
98 MOCK_METHOD0(ResumeSignInScreen, void(void));
99 MOCK_METHOD0(OnPreferencesChanged, void(void));
100
101 private:
102 DISALLOW_COPY_AND_ASSIGN(MockLoginDisplayHost);
103 };
104 80
105 scoped_refptr<Authenticator> CreateAuthenticator( 81 scoped_refptr<Authenticator> CreateAuthenticator(
106 LoginStatusConsumer* consumer) { 82 LoginStatusConsumer* consumer) {
107 return new MockAuthenticator(consumer, kUsername, kPassword); 83 return new MockAuthenticator(consumer, kUsername, kPassword);
108 } 84 }
109 85
110 scoped_refptr<Authenticator> CreateAuthenticatorNewUser( 86 scoped_refptr<Authenticator> CreateAuthenticatorNewUser(
111 LoginStatusConsumer* consumer) { 87 LoginStatusConsumer* consumer) {
112 return new MockAuthenticator(consumer, kNewUsername, kPassword); 88 return new MockAuthenticator(consumer, kNewUsername, kPassword);
113 } 89 }
114 90
91 scoped_refptr<Authenticator> CreateAuthenticatorForPublicSession(
92 LoginStatusConsumer* consumer) {
93 return new MockAuthenticator(consumer, kAutoLoginUsername, "");
94 }
95
115 } // namespace 96 } // namespace
116 97
117 class ExistingUserControllerTest : public CrosInProcessBrowserTest { 98 class ExistingUserControllerTest : public CrosInProcessBrowserTest {
118 protected: 99 protected:
119 ExistingUserControllerTest() 100 ExistingUserControllerTest()
120 : mock_network_library_(NULL), 101 : mock_network_library_(NULL),
121 mock_login_display_(NULL), 102 mock_login_display_(NULL),
122 mock_login_display_host_(NULL), 103 mock_login_display_host_(NULL),
123 testing_profile_(NULL) { 104 testing_profile_(NULL) {
124 } 105 }
(...skipping 12 matching lines...) Expand all
137 Return(reinterpret_cast<IBusInputContextClient*>(NULL))); 118 Return(reinterpret_cast<IBusInputContextClient*>(NULL)));
138 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), 119 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(),
139 GetProperties(_)) 120 GetProperties(_))
140 .Times(AnyNumber()); 121 .Times(AnyNumber());
141 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), 122 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(),
142 AddPropertyChangedObserver(_)) 123 AddPropertyChangedObserver(_))
143 .Times(AnyNumber()); 124 .Times(AnyNumber());
144 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(), 125 EXPECT_CALL(*mock_dbus_thread_manager->mock_shill_manager_client(),
145 RemovePropertyChangedObserver(_)) 126 RemovePropertyChangedObserver(_))
146 .Times(AnyNumber()); 127 .Times(AnyNumber());
128
129 SetUpSessionManager(mock_dbus_thread_manager);
130
147 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); 131 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager);
148 CrosInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 132 CrosInProcessBrowserTest::SetUpInProcessBrowserTestFixture();
149 cros_mock_->InitStatusAreaMocks(); 133 cros_mock_->InitStatusAreaMocks();
150 cros_mock_->SetStatusAreaMocksExpectations(); 134 cros_mock_->SetStatusAreaMocksExpectations();
151 135
152 mock_network_library_ = cros_mock_->mock_network_library(); 136 mock_network_library_ = cros_mock_->mock_network_library();
153 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_)) 137 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_))
154 .Times(AnyNumber()); 138 .Times(AnyNumber());
155 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _)) 139 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _))
156 .WillRepeatedly(Return(true)); 140 .WillRepeatedly(Return(true));
157 141
158 MockSessionManagerClient* mock_session_manager_client =
159 mock_dbus_thread_manager->mock_session_manager_client();
160 EXPECT_CALL(*mock_session_manager_client, EmitLoginPromptReady())
161 .Times(1);
162 EXPECT_CALL(*mock_session_manager_client, RetrieveDevicePolicy(_))
163 .Times(AnyNumber());
164
165 mock_login_utils_ = new MockLoginUtils(); 142 mock_login_utils_ = new MockLoginUtils();
166 LoginUtils::Set(mock_login_utils_); 143 LoginUtils::Set(mock_login_utils_);
167 EXPECT_CALL(*mock_login_utils_, PrewarmAuthentication()) 144 EXPECT_CALL(*mock_login_utils_, PrewarmAuthentication())
168 .Times(AnyNumber()); 145 .Times(AnyNumber());
169 EXPECT_CALL(*mock_login_utils_, StopBackgroundFetchers()) 146 EXPECT_CALL(*mock_login_utils_, StopBackgroundFetchers())
170 .Times(AnyNumber()); 147 .Times(AnyNumber());
171 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) 148 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_))
172 .Times(1); 149 .Times(1);
173 150
174 mock_login_display_host_.reset(new MockLoginDisplayHost()); 151 mock_login_display_host_.reset(new MockLoginDisplayHost());
152 mock_login_display_ = new MockLoginDisplay();
153 SetUpLoginDisplay();
154 }
175 155
176 EXPECT_CALL(*mock_user_manager_.user_manager(), IsKnownUser(kUsername)) 156 virtual void SetUpSessionManager(
157 MockDBusThreadManager* mock_dbus_thread_manager) {
158 mock_user_manager_.reset(new ScopedMockUserManagerEnabler);
159 EXPECT_CALL(*mock_user_manager_->user_manager(), IsKnownUser(kUsername))
177 .Times(AnyNumber()) 160 .Times(AnyNumber())
178 .WillRepeatedly(Return(true)); 161 .WillRepeatedly(Return(true));
179 EXPECT_CALL(*mock_user_manager_.user_manager(), IsKnownUser(kNewUsername)) 162 EXPECT_CALL(*mock_user_manager_->user_manager(), IsKnownUser(kNewUsername))
180 .Times(AnyNumber()) 163 .Times(AnyNumber())
181 .WillRepeatedly(Return(false)); 164 .WillRepeatedly(Return(false));
182 EXPECT_CALL(*mock_user_manager_.user_manager(), IsUserLoggedIn()) 165 EXPECT_CALL(*mock_user_manager_->user_manager(), IsUserLoggedIn())
183 .Times(AnyNumber()) 166 .Times(AnyNumber())
184 .WillRepeatedly(Return(false)); 167 .WillRepeatedly(Return(false));
185 EXPECT_CALL(*mock_user_manager_.user_manager(), IsLoggedInAsGuest()) 168 EXPECT_CALL(*mock_user_manager_->user_manager(), IsLoggedInAsGuest())
186 .Times(AnyNumber()) 169 .Times(AnyNumber())
187 .WillRepeatedly(Return(false)); 170 .WillRepeatedly(Return(false));
188 EXPECT_CALL(*mock_user_manager_.user_manager(), IsLoggedInAsDemoUser()) 171 EXPECT_CALL(*mock_user_manager_->user_manager(), IsLoggedInAsDemoUser())
189 .Times(AnyNumber()) 172 .Times(AnyNumber())
190 .WillRepeatedly(Return(false)); 173 .WillRepeatedly(Return(false));
191 EXPECT_CALL(*mock_user_manager_.user_manager(), IsLoggedInAsPublicAccount()) 174 EXPECT_CALL(*mock_user_manager_->user_manager(),
175 IsLoggedInAsPublicAccount())
192 .Times(AnyNumber()) 176 .Times(AnyNumber())
193 .WillRepeatedly(Return(false)); 177 .WillRepeatedly(Return(false));
194 EXPECT_CALL(*mock_user_manager_.user_manager(), IsSessionStarted()) 178 EXPECT_CALL(*mock_user_manager_->user_manager(), IsSessionStarted())
195 .Times(AnyNumber()) 179 .Times(AnyNumber())
196 .WillRepeatedly(Return(false)); 180 .WillRepeatedly(Return(false));
181 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew())
182 .Times(AnyNumber())
183 .WillRepeatedly(Return(false));
184 EXPECT_CALL(*mock_user_manager_->user_manager(), Shutdown())
185 .Times(1);
197 186
187 MockSessionManagerClient* mock_session_manager_client =
188 mock_dbus_thread_manager->mock_session_manager_client();
189 EXPECT_CALL(*mock_session_manager_client, EmitLoginPromptReady())
190 .Times(1);
191 EXPECT_CALL(*mock_session_manager_client, RetrieveDevicePolicy(_))
192 .Times(AnyNumber());
193 }
194
195 virtual void SetUpLoginDisplay() {
198 // |mock_login_display_| is owned by the ExistingUserController, which calls 196 // |mock_login_display_| is owned by the ExistingUserController, which calls
199 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. 197 // CreateLoginDisplay() on the |mock_login_display_host_| to get it.
200 mock_login_display_ = new MockLoginDisplay();
201 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) 198 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_))
202 .Times(1) 199 .Times(1)
203 .WillOnce(Return(mock_login_display_)); 200 .WillOnce(Return(mock_login_display_));
204 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) 201 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow())
205 .Times(1) 202 .Times(1)
206 .WillOnce(ReturnNull()); 203 .WillOnce(ReturnNull());
207 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) 204 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged())
208 .Times(1); 205 .Times(1);
209 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) 206 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true))
210 .Times(1); 207 .Times(1);
211 } 208 }
212 209
213 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 210 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
214 command_line->AppendSwitch(switches::kLoginManager); 211 command_line->AppendSwitch(switches::kLoginManager);
215 } 212 }
216 213
217 virtual void SetUpOnMainThread() OVERRIDE { 214 virtual void SetUpOnMainThread() OVERRIDE {
218 testing_profile_.reset(new TestingProfile()); 215 testing_profile_.reset(new TestingProfile());
219 existing_user_controller_.reset( 216 existing_user_controller_.reset(
220 new ExistingUserController(mock_login_display_host_.get())); 217 new ExistingUserController(mock_login_display_host_.get()));
221 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get()); 218 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get());
222 existing_user_controller_->Init(UserList()); 219 existing_user_controller_->Init(UserList());
223 profile_prepared_cb_ = 220 profile_prepared_cb_ =
224 base::Bind(&ExistingUserController::OnProfilePrepared, 221 base::Bind(&ExistingUserController::OnProfilePrepared,
225 base::Unretained(existing_user_controller()), 222 base::Unretained(existing_user_controller()),
226 testing_profile_.get()); 223 testing_profile_.get());
227 } 224 }
228 225
229 virtual void CleanUpOnMainThread() OVERRIDE { 226 virtual void CleanUpOnMainThread() OVERRIDE {
227 // ExistingUserController must be deleted before the thread is cleaned up:
228 // If there is an outstanding login attempt when ExistingUserController is
229 // deleted, its LoginPerformer instance will be deleted, which in turn
230 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must
231 // be deleted on the UI thread.
232 existing_user_controller_.reset();
230 CrosInProcessBrowserTest::CleanUpOnMainThread(); 233 CrosInProcessBrowserTest::CleanUpOnMainThread();
231 testing_profile_.reset(NULL); 234 testing_profile_.reset(NULL);
232 } 235 }
233 236
234 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { 237 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
235 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); 238 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
236 DBusThreadManager::Shutdown(); 239 DBusThreadManager::Shutdown();
237 } 240 }
238 241
242 // ExistingUserController private member accessors.
243 base::OneShotTimer<ExistingUserController>* auto_login_timer() {
244 return existing_user_controller()->auto_login_timer_.get();
245 }
246
247 std::string auto_login_username() {
248 return existing_user_controller()->public_session_auto_login_username_;
249 }
250 void set_auto_login_username(const std::string& username) {
251 existing_user_controller()->public_session_auto_login_username_ = username;
252 }
253
254 int auto_login_delay() {
255 return existing_user_controller()->public_session_auto_login_delay_;
256 }
257 void set_auto_login_delay(int delay) {
258 existing_user_controller()->public_session_auto_login_delay_ = delay;
259 }
260
261 bool is_login_in_progress() {
262 return existing_user_controller()->is_login_in_progress_;
263 }
264 void set_is_login_in_progress(bool is_login_in_progress) {
265 existing_user_controller()->is_login_in_progress_ = is_login_in_progress;
266 }
267
239 scoped_ptr<ExistingUserController> existing_user_controller_; 268 scoped_ptr<ExistingUserController> existing_user_controller_;
240 269
241 // These mocks are owned by CrosLibrary class. 270 // These mocks are owned by CrosLibrary class.
242 MockNetworkLibrary* mock_network_library_; 271 MockNetworkLibrary* mock_network_library_;
243 272
244 MockLoginDisplay* mock_login_display_; 273 MockLoginDisplay* mock_login_display_;
245 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; 274 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_;
246 275
247 ScopedMockUserManagerEnabler mock_user_manager_; 276 scoped_ptr<ScopedMockUserManagerEnabler> mock_user_manager_;
248 277
249 // Owned by LoginUtilsWrapper. 278 // Owned by LoginUtilsWrapper.
250 MockLoginUtils* mock_login_utils_; 279 MockLoginUtils* mock_login_utils_;
251 280
252 scoped_ptr<TestingProfile> testing_profile_; 281 scoped_ptr<TestingProfile> testing_profile_;
253 282
254 // Mock URLFetcher. 283 // Mock URLFetcher.
255 MockURLFetcherFactory<SuccessFetcher> factory_; 284 MockURLFetcherFactory<SuccessFetcher> factory_;
256 285
257 base::Callback<void(void)> profile_prepared_cb_; 286 base::Callback<void(void)> profile_prepared_cb_;
(...skipping 21 matching lines...) Expand all
279 .Times(1); 308 .Times(1);
280 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername)) 309 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kUsername))
281 .Times(1); 310 .Times(1);
282 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 311 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
283 .Times(1); 312 .Times(1);
284 EXPECT_CALL(*mock_login_display_, OnFadeOut()) 313 EXPECT_CALL(*mock_login_display_, OnFadeOut())
285 .Times(1); 314 .Times(1);
286 EXPECT_CALL(*mock_login_display_host_, 315 EXPECT_CALL(*mock_login_display_host_,
287 StartWizard(WizardController::kTermsOfServiceScreenName, NULL)) 316 StartWizard(WizardController::kTermsOfServiceScreenName, NULL))
288 .Times(0); 317 .Times(0);
289 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) 318 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew())
290 .Times(AnyNumber()) 319 .Times(AnyNumber())
291 .WillRepeatedly(Return(false)); 320 .WillRepeatedly(Return(false));
292 existing_user_controller()->Login(kUsername, kPassword); 321 existing_user_controller()->Login(kUsername, kPassword);
293 content::RunAllPendingInMessageLoop(); 322 content::RunAllPendingInMessageLoop();
294 } 323 }
295 324
296 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) { 325 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, AutoEnrollAfterSignIn) {
297 EXPECT_CALL(*mock_login_display_host_, 326 EXPECT_CALL(*mock_login_display_host_,
298 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _)) 327 StartWizard(WizardController::kEnterpriseEnrollmentScreenName, _))
299 .Times(1); 328 .Times(1);
300 EXPECT_CALL(*mock_login_display_, OnFadeOut()) 329 EXPECT_CALL(*mock_login_display_, OnFadeOut())
301 .Times(1); 330 .Times(1);
302 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) 331 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin())
303 .Times(1); 332 .Times(1);
304 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) 333 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew())
305 .Times(AnyNumber()) 334 .Times(AnyNumber())
306 .WillRepeatedly(Return(false)); 335 .WillRepeatedly(Return(false));
307 // The order of these expected calls matters: the UI if first disabled 336 // The order of these expected calls matters: the UI if first disabled
308 // during the login sequence, and is enabled again for the enrollment screen. 337 // during the login sequence, and is enabled again for the enrollment screen.
309 Sequence uiEnabledSequence; 338 Sequence uiEnabledSequence;
310 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 339 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
311 .Times(1) 340 .Times(1)
312 .InSequence(uiEnabledSequence); 341 .InSequence(uiEnabledSequence);
313 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 342 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
314 .Times(1) 343 .Times(1)
(...skipping 24 matching lines...) Expand all
339 PrepareProfile(kNewUsername, _, kPassword, _, _, _)) 368 PrepareProfile(kNewUsername, _, kPassword, _, _, _))
340 .Times(1) 369 .Times(1)
341 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, 370 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
342 &base::Callback<void(void)>::Run)); 371 &base::Callback<void(void)>::Run));
343 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kNewUsername)) 372 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(kNewUsername))
344 .Times(1); 373 .Times(1);
345 EXPECT_CALL(*mock_login_display_, OnFadeOut()) 374 EXPECT_CALL(*mock_login_display_, OnFadeOut())
346 .Times(1); 375 .Times(1);
347 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin()) 376 EXPECT_CALL(*mock_login_display_host_.get(), OnCompleteLogin())
348 .Times(1); 377 .Times(1);
349 EXPECT_CALL(*mock_user_manager_.user_manager(), IsCurrentUserNew()) 378 EXPECT_CALL(*mock_user_manager_->user_manager(), IsCurrentUserNew())
350 .Times(AnyNumber()) 379 .Times(AnyNumber())
351 .WillRepeatedly(Return(true)); 380 .WillRepeatedly(Return(true));
352 381
353 // The order of these expected calls matters: the UI if first disabled 382 // The order of these expected calls matters: the UI if first disabled
354 // during the login sequence, and is enabled again after login completion. 383 // during the login sequence, and is enabled again after login completion.
355 Sequence uiEnabledSequence; 384 Sequence uiEnabledSequence;
356 // This is disabled twice: once right after signin but before checking for 385 // This is disabled twice: once right after signin but before checking for
357 // auto-enrollment, and again after doing an ownership status check. 386 // auto-enrollment, and again after doing an ownership status check.
358 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 387 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
359 .Times(2) 388 .Times(2)
360 .InSequence(uiEnabledSequence); 389 .InSequence(uiEnabledSequence);
361 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) 390 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
362 .Times(1) 391 .Times(1)
363 .InSequence(uiEnabledSequence); 392 .InSequence(uiEnabledSequence);
364 393
365 existing_user_controller()->CompleteLogin(kNewUsername, kPassword); 394 existing_user_controller()->CompleteLogin(kNewUsername, kPassword);
366 content::RunAllPendingInMessageLoop(); 395 content::RunAllPendingInMessageLoop();
367 } 396 }
368 397
398 MATCHER_P(HasDetails, expected, "") {
399 return expected == *content::Details<const std::string>(arg).ptr();
400 }
401
402 class ExistingUserControllerPublicSessionTest
403 : public ExistingUserControllerTest {
404 protected:
405 ExistingUserControllerPublicSessionTest() {
406 }
407
408 virtual void SetUpOnMainThread() OVERRIDE {
409 ExistingUserControllerTest::SetUpOnMainThread();
410
411 // Wait for the public session user to be created.
412 if (!chromeos::UserManager::Get()->IsKnownUser(kAutoLoginUsername)) {
413 content::NotificationWatcher(
414 chrome::NOTIFICATION_USER_LIST_CHANGED,
415 base::Bind(&chromeos::UserManager::IsKnownUser,
416 base::Unretained(chromeos::UserManager::Get()),
417 kAutoLoginUsername)).Run();
418 }
419
420 // Wait for the device local account policy to be installed.
421 policy::MockCloudPolicyStoreObserver observer;
422 content::MessageLoopRunner* runner = new content::MessageLoopRunner;
423 policy::CloudPolicyStore* store = TestingBrowserProcess::GetGlobal()->
424 browser_policy_connector()->GetDeviceLocalAccountPolicyService()->
425 GetBrokerForAccount(kAutoLoginUsername)->core()->store();
426 store->AddObserver(&observer);
427 EXPECT_CALL(observer, OnStoreLoaded(store))
428 .Times(1)
429 .WillOnce(InvokeWithoutArgs(runner, &content::MessageLoopRunner::Quit));
430 runner->Run();
431 store->RemoveObserver(&observer);
432 }
433
434 virtual void SetUpSessionManager(
435 MockDBusThreadManager* mock_dbus_thread_manager) OVERRIDE {
436 EXPECT_CALL(*mock_dbus_thread_manager, GetSessionManagerClient())
437 .WillRepeatedly(Return(&session_manager_client_));
438
439 // Install the owner key.
440 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
441 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key");
442 std::vector<uint8> owner_key_bits;
443 ASSERT_TRUE(device_policy_.signing_key()->ExportPublicKey(&owner_key_bits));
444 ASSERT_EQ(
445 file_util::WriteFile(
446 owner_key_file,
447 reinterpret_cast<const char*>(vector_as_array(&owner_key_bits)),
448 owner_key_bits.size()),
449 static_cast<int>(owner_key_bits.size()));
450 ASSERT_TRUE(PathService::Override(chrome::FILE_OWNER_KEY, owner_key_file));
451
452 // Setup the device policy.
453 em::ChromeDeviceSettingsProto& proto(device_policy_.payload());
454 proto.mutable_device_local_accounts()->add_account()->set_id(
455 kAutoLoginUsername);
456 RefreshDevicePolicy();
457
458 // Setup the device local account policy.
459 policy::UserPolicyBuilder device_local_account_policy;
460 device_local_account_policy.policy_data().set_username(kAutoLoginUsername);
461 device_local_account_policy.policy_data().set_policy_type(
462 policy::dm_protocol::kChromePublicAccountPolicyType);
463 device_local_account_policy.policy_data().set_settings_entity_id(
464 kAutoLoginUsername);
465 device_local_account_policy.Build();
466 session_manager_client_.set_device_local_account_policy(
467 kAutoLoginUsername,
468 device_local_account_policy.GetBlob());
469 }
470
471 virtual void SetUpLoginDisplay() {
472 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_))
473 .Times(1)
474 .WillOnce(Return(mock_login_display_));
475 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow())
476 .Times(AnyNumber())
477 .WillRepeatedly(ReturnNull());
478 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged())
479 .Times(AnyNumber());
480 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _))
481 .Times(AnyNumber());
482 }
483
484 void DisableAutoLoginPolicyNotifications() {
485 CrosSettings::Get()->RemoveSettingsObserver(
486 kAccountsPrefDeviceLocalAccountAutoLoginId,
487 existing_user_controller());
488 CrosSettings::Get()->RemoveSettingsObserver(
489 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
490 existing_user_controller());
491 }
492
493 void ExpectSuccessfulLogin(const std::string& username,
494 const std::string& password,
495 scoped_refptr<Authenticator> create_authenticator(
496 LoginStatusConsumer* consumer)) {
497 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
498 .Times(AnyNumber());
499 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
500 .Times(1)
501 .WillOnce(WithArg<0>(Invoke(create_authenticator)));
502 EXPECT_CALL(*mock_login_utils_,
503 PrepareProfile(username, _, password, _, _, _))
504 .Times(1)
505 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
506 &base::Callback<void(void)>::Run));
507 EXPECT_CALL(*mock_login_utils_,
508 DoBrowserLaunch(testing_profile_.get(),
509 mock_login_display_host_.get()))
510 .Times(1);
511 EXPECT_CALL(*mock_login_display_, OnLoginSuccess(username))
512 .Times(1);
513 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true))
514 .Times(1);
515 EXPECT_CALL(*mock_login_display_, OnFadeOut())
516 .Times(1);
517 EXPECT_CALL(*mock_login_display_host_,
518 StartWizard(WizardController::kTermsOfServiceScreenName, NULL))
519 .Times(0);
520 }
521
522 content::MessageLoopRunner* CreateSettingsObserverRunLoop(
523 content::MockNotificationObserver& observer, const char* setting) {
524 content::MessageLoopRunner* runner = new content::MessageLoopRunner;
525 EXPECT_CALL(observer, Observe(chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED,
526 _, HasDetails(setting)))
527 .Times(1)
528 .WillOnce(InvokeWithoutArgs(runner, &content::MessageLoopRunner::Quit));
529 CrosSettings::Get()->AddSettingsObserver(setting, &observer);
530 return runner;
531 }
532
533 void RefreshDevicePolicy() {
534 // Reset the key to its original state.
535 device_policy_.set_signing_key(
536 policy::PolicyBuilder::CreateTestSigningKey());
537 device_policy_.Build();
538 // Clear the key so the device can't write owner settings.
539 device_policy_.set_signing_key(
540 make_scoped_ptr<crypto::RSAPrivateKey>(NULL));
541 device_policy_.set_new_signing_key(
542 make_scoped_ptr<crypto::RSAPrivateKey>(NULL));
543 session_manager_client_.set_device_policy(device_policy_.GetBlob());
544 }
545
546 void SetAutoLoginPolicy(const std::string& username, int delay) {
547 // Wait until ExistingUserController has finished auto-login
548 // configuration by observing the same settings that trigger
549 // ConfigurePublicSessionAutoLogin.
550 content::MockNotificationObserver observer;
551
552 em::ChromeDeviceSettingsProto& proto(device_policy_.payload());
553
554 // If both settings have changed we need to wait for both to
555 // propagate, so check the new values against the old ones.
556 content::MessageLoopRunner* runner1 = NULL;
557 if (!proto.has_device_local_accounts() ||
558 !proto.device_local_accounts().has_auto_login_id() ||
559 proto.device_local_accounts().auto_login_id() != username) {
560 runner1 = CreateSettingsObserverRunLoop(
561 observer, kAccountsPrefDeviceLocalAccountAutoLoginId);
562 }
563 content::MessageLoopRunner* runner2 = NULL;
564 if (!proto.has_device_local_accounts() ||
565 !proto.device_local_accounts().has_auto_login_delay() ||
566 proto.device_local_accounts().auto_login_delay() != delay) {
567 runner2 = CreateSettingsObserverRunLoop(
568 observer, kAccountsPrefDeviceLocalAccountAutoLoginDelay);
569 }
570
571 // Update the policy.
572 proto.mutable_device_local_accounts()->set_auto_login_id(username);
573 proto.mutable_device_local_accounts()->set_auto_login_delay(delay);
574 RefreshDevicePolicy();
575
576 // Wait for ExistingUserController to read the updated settings.
577 if (runner1)
578 runner1->Run();
579 if (runner2)
580 runner2->Run();
581
582 // Clean up.
583 CrosSettings::Get()->RemoveSettingsObserver(
584 kAccountsPrefDeviceLocalAccountAutoLoginId,
585 &observer);
586 CrosSettings::Get()->RemoveSettingsObserver(
587 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
588 &observer);
589 }
590
591 void ConfigureAutoLogin() {
592 existing_user_controller()->ConfigurePublicSessionAutoLogin();
593 }
594
595 void FireAutoLogin() {
596 existing_user_controller()->OnPublicSessionAutoLoginTimerFire();
597 }
598
599 // Mock out policy loads/stores from/to the device.
600 FakeSessionManagerClient session_manager_client_;
601
602 // Stores the device owner key.
603 base::ScopedTempDir temp_dir_;
604
605 // Carries Chrome OS device policies for tests.
606 policy::DevicePolicyBuilder device_policy_;
607
608 private:
609 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest);
610 };
611
612 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
613 ConfigureAutoLoginUsingPolicy) {
614 existing_user_controller()->OnSigninScreenReady();
615 EXPECT_EQ("", auto_login_username());
616 EXPECT_EQ(0, auto_login_delay());
617 EXPECT_FALSE(auto_login_timer());
618
619 // Set the policy.
620 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginLongDelay);
621 EXPECT_EQ(kAutoLoginUsername, auto_login_username());
622 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay());
623 ASSERT_TRUE(auto_login_timer());
624 EXPECT_TRUE(auto_login_timer()->IsRunning());
625
626 // Unset the policy.
627 SetAutoLoginPolicy("", 0);
628 EXPECT_EQ("", auto_login_username());
629 EXPECT_EQ(0, auto_login_delay());
630 ASSERT_TRUE(auto_login_timer());
631 EXPECT_FALSE(auto_login_timer()->IsRunning());
632 }
633
634 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
635 OnAutoLoginFire) {
636 // Set up mocks to check login success.
637 ExpectSuccessfulLogin(kAutoLoginUsername, "",
638 CreateAuthenticatorForPublicSession);
639 existing_user_controller()->OnSigninScreenReady();
640
641 // Directly set auto-login parameters to avoid starting the timer.
642 set_auto_login_username(kAutoLoginUsername);
643 set_auto_login_delay(kAutoLoginLongDelay);
644
645 // Manually fire auto-login and wait for the login tasks to complete.
646 FireAutoLogin();
647 content::RunAllPendingInMessageLoop();
648 }
649
650 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
651 AutoLoginNoDelay) {
652 // Set up mocks to check login success.
653 ExpectSuccessfulLogin(kAutoLoginUsername, "",
654 CreateAuthenticatorForPublicSession);
655 existing_user_controller()->OnSigninScreenReady();
656
657 // Start auto-login and wait for login tasks to complete.
658 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginNoDelay);
659 content::RunAllPendingInMessageLoop();
660 }
661
662 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
663 AutoLoginShortDelay) {
664 // Set up mocks to check login success.
665 ExpectSuccessfulLogin(kAutoLoginUsername, "",
666 CreateAuthenticatorForPublicSession);
667 existing_user_controller()->OnSigninScreenReady();
668 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginShortDelay);
669 ASSERT_TRUE(auto_login_timer());
670 ASSERT_TRUE(auto_login_timer()->IsRunning());
671
672 // Wait for the timer to fire.
673 content::MessageLoopRunner* runner = new content::MessageLoopRunner;
674 base::OneShotTimer<content::MessageLoopRunner> timer;
675 timer.Start(FROM_HERE,
676 base::TimeDelta::FromMilliseconds(2 * kAutoLoginShortDelay),
677 base::Bind(&content::MessageLoopRunner::Quit,
678 base::Unretained(runner)));
679 runner->Run();
680
681 // Wait for login tasks to complete.
682 content::RunAllPendingInMessageLoop();
683 }
684
685 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
686 LoginStopsAutoLogin) {
687 // Set up mocks to check login success.
688 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator);
689
690 existing_user_controller()->OnSigninScreenReady();
691 set_auto_login_username(kAutoLoginUsername);
692 set_auto_login_delay(kAutoLoginLongDelay);
693 existing_user_controller()->StartPublicSessionAutoLoginTimer();
694 ASSERT_TRUE(auto_login_timer());
695 EXPECT_TRUE(auto_login_timer()->IsRunning());
696
697 // Login and check that it stopped the timer.
698 existing_user_controller()->Login(kUsername, kPassword);
699 EXPECT_TRUE(is_login_in_progress());
700 ASSERT_TRUE(auto_login_timer());
701 EXPECT_FALSE(auto_login_timer()->IsRunning());
702
703 // Wait for login tasks to complete.
704 content::RunAllPendingInMessageLoop();
705
706 // Timer should still be stopped after login completes.
707 ASSERT_TRUE(auto_login_timer());
708 EXPECT_FALSE(auto_login_timer()->IsRunning());
709 }
710
711 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
712 GuestModeLoginStopsAutoLogin) {
713 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
714 .Times(1);
715 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
716 .Times(1)
717 .WillOnce(WithArg<0>(Invoke(CreateAuthenticator)));
718 ScopedMockUserManagerEnabler mock_user_manager;
719 EXPECT_CALL(*mock_login_utils_, CompleteOffTheRecordLogin(_))
720 .Times(1);
721
722 existing_user_controller()->OnSigninScreenReady();
723 set_auto_login_username(kAutoLoginUsername);
724 set_auto_login_delay(kAutoLoginLongDelay);
725 existing_user_controller()->StartPublicSessionAutoLoginTimer();
726 ASSERT_TRUE(auto_login_timer());
727 EXPECT_TRUE(auto_login_timer()->IsRunning());
728
729 // Login and check that it stopped the timer.
730 existing_user_controller()->LoginAsGuest();
731 EXPECT_TRUE(is_login_in_progress());
732 ASSERT_TRUE(auto_login_timer());
733 EXPECT_FALSE(auto_login_timer()->IsRunning());
734
735 // Wait for login tasks to complete.
736 content::RunAllPendingInMessageLoop();
737
738 // Timer should still be stopped after login completes.
739 ASSERT_TRUE(auto_login_timer());
740 EXPECT_FALSE(auto_login_timer()->IsRunning());
741 }
742
743 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
744 CompleteLoginStopsAutoLogin) {
745 // Set up mocks to check login success.
746 ExpectSuccessfulLogin(kUsername, kPassword, CreateAuthenticator);
747 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin())
748 .Times(1);
749
750 existing_user_controller()->OnSigninScreenReady();
751 set_auto_login_username(kAutoLoginUsername);
752 set_auto_login_delay(kAutoLoginLongDelay);
753 existing_user_controller()->StartPublicSessionAutoLoginTimer();
754 ASSERT_TRUE(auto_login_timer());
755 EXPECT_TRUE(auto_login_timer()->IsRunning());
756
757 // Check that login completes and stops the timer.
758 existing_user_controller()->CompleteLogin(kUsername, kPassword);
759 ASSERT_TRUE(auto_login_timer());
760 EXPECT_FALSE(auto_login_timer()->IsRunning());
761
762 // Wait for login tasks to complete.
763 content::RunAllPendingInMessageLoop();
764
765 // Timer should still be stopped after login completes.
766 ASSERT_TRUE(auto_login_timer());
767 EXPECT_FALSE(auto_login_timer()->IsRunning());
768 }
769
770 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
771 PublicSessionLoginStopsAutoLogin) {
772 // Set up mocks to check login success.
773 ExpectSuccessfulLogin(kAutoLoginUsername, "",
774 CreateAuthenticatorForPublicSession);
775 existing_user_controller()->OnSigninScreenReady();
776 SetAutoLoginPolicy(kAutoLoginUsername, kAutoLoginShortDelay);
777 ASSERT_TRUE(auto_login_timer());
778 EXPECT_TRUE(auto_login_timer()->IsRunning());
779
780 // Login and check that it stopped the timer.
781 existing_user_controller()->LoginAsPublicAccount(kAutoLoginUsername);
782 EXPECT_TRUE(is_login_in_progress());
783 ASSERT_TRUE(auto_login_timer());
784 EXPECT_FALSE(auto_login_timer()->IsRunning());
785
786 // Wait for login tasks to complete.
787 content::RunAllPendingInMessageLoop();
788
789 // Timer should still be stopped after login completes.
790 ASSERT_TRUE(auto_login_timer());
791 EXPECT_FALSE(auto_login_timer()->IsRunning());
792 }
793
369 } // namespace chromeos 794 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698