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

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

Issue 856493004: Update {virtual,override,final} to follow C++11 style in chrome/browser/chromeos/login. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 : mock_login_display_(NULL), mock_user_manager_(NULL) {} 120 : mock_login_display_(NULL), mock_user_manager_(NULL) {}
121 121
122 ExistingUserController* existing_user_controller() { 122 ExistingUserController* existing_user_controller() {
123 return ExistingUserController::current_controller(); 123 return ExistingUserController::current_controller();
124 } 124 }
125 125
126 const ExistingUserController* existing_user_controller() const { 126 const ExistingUserController* existing_user_controller() const {
127 return ExistingUserController::current_controller(); 127 return ExistingUserController::current_controller();
128 } 128 }
129 129
130 virtual void SetUpInProcessBrowserTestFixture() override { 130 void SetUpInProcessBrowserTestFixture() override {
131 SetUpSessionManager(); 131 SetUpSessionManager();
132 132
133 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); 133 DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture();
134 134
135 mock_login_utils_ = new MockLoginUtils(); 135 mock_login_utils_ = new MockLoginUtils();
136 LoginUtils::Set(mock_login_utils_); 136 LoginUtils::Set(mock_login_utils_);
137 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_)) 137 EXPECT_CALL(*mock_login_utils_, DelegateDeleted(_))
138 .Times(1); 138 .Times(1);
139 139
140 mock_login_display_host_.reset(new MockLoginDisplayHost()); 140 mock_login_display_host_.reset(new MockLoginDisplayHost());
(...skipping 10 matching lines...) Expand all
151 .WillOnce(Return(mock_login_display_)); 151 .WillOnce(Return(mock_login_display_));
152 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) 152 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow())
153 .Times(1) 153 .Times(1)
154 .WillOnce(ReturnNull()); 154 .WillOnce(ReturnNull());
155 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) 155 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged())
156 .Times(1); 156 .Times(1);
157 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true)) 157 EXPECT_CALL(*mock_login_display_, Init(_, false, true, true))
158 .Times(1); 158 .Times(1);
159 } 159 }
160 160
161 virtual void SetUpCommandLine(base::CommandLine* command_line) override { 161 void SetUpCommandLine(base::CommandLine* command_line) override {
162 command_line->AppendSwitch(switches::kLoginManager); 162 command_line->AppendSwitch(switches::kLoginManager);
163 } 163 }
164 164
165 virtual void SetUpUserManager() { 165 virtual void SetUpUserManager() {
166 // Replace the UserManager singleton with a mock. 166 // Replace the UserManager singleton with a mock.
167 mock_user_manager_ = new MockUserManager; 167 mock_user_manager_ = new MockUserManager;
168 user_manager_enabler_.reset( 168 user_manager_enabler_.reset(
169 new ScopedUserManagerEnabler(mock_user_manager_)); 169 new ScopedUserManagerEnabler(mock_user_manager_));
170 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername)) 170 EXPECT_CALL(*mock_user_manager_, IsKnownUser(kUsername))
171 .Times(AnyNumber()) 171 .Times(AnyNumber())
(...skipping 16 matching lines...) Expand all
188 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew()) 188 EXPECT_CALL(*mock_user_manager_, IsCurrentUserNew())
189 .Times(AnyNumber()) 189 .Times(AnyNumber())
190 .WillRepeatedly(Return(false)); 190 .WillRepeatedly(Return(false));
191 EXPECT_CALL(*mock_user_manager_, Shutdown()) 191 EXPECT_CALL(*mock_user_manager_, Shutdown())
192 .Times(1); 192 .Times(1);
193 EXPECT_CALL(*mock_user_manager_, FindUser(_)) 193 EXPECT_CALL(*mock_user_manager_, FindUser(_))
194 .Times(AnyNumber()) 194 .Times(AnyNumber())
195 .WillRepeatedly(ReturnNull()); 195 .WillRepeatedly(ReturnNull());
196 } 196 }
197 197
198 virtual void SetUpOnMainThread() override { 198 void SetUpOnMainThread() override {
199 testing_profile_.reset(new TestingProfile()); 199 testing_profile_.reset(new TestingProfile());
200 SetUpUserManager(); 200 SetUpUserManager();
201 existing_user_controller_.reset( 201 existing_user_controller_.reset(
202 new ExistingUserController(mock_login_display_host_.get())); 202 new ExistingUserController(mock_login_display_host_.get()));
203 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get()); 203 ASSERT_EQ(existing_user_controller(), existing_user_controller_.get());
204 existing_user_controller_->Init(user_manager::UserList()); 204 existing_user_controller_->Init(user_manager::UserList());
205 profile_prepared_cb_ = 205 profile_prepared_cb_ =
206 base::Bind(&ExistingUserController::OnProfilePrepared, 206 base::Bind(&ExistingUserController::OnProfilePrepared,
207 base::Unretained(existing_user_controller()), 207 base::Unretained(existing_user_controller()),
208 testing_profile_.get(), 208 testing_profile_.get(),
209 false); 209 false);
210 } 210 }
211 211
212 virtual void TearDownOnMainThread() override { 212 void TearDownOnMainThread() override {
213 // ExistingUserController must be deleted before the thread is cleaned up: 213 // ExistingUserController must be deleted before the thread is cleaned up:
214 // If there is an outstanding login attempt when ExistingUserController is 214 // If there is an outstanding login attempt when ExistingUserController is
215 // deleted, its LoginPerformer instance will be deleted, which in turn 215 // deleted, its LoginPerformer instance will be deleted, which in turn
216 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must 216 // deletes its OnlineAttemptHost instance. However, OnlineAttemptHost must
217 // be deleted on the UI thread. 217 // be deleted on the UI thread.
218 existing_user_controller_.reset(); 218 existing_user_controller_.reset();
219 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread(); 219 DevicePolicyCrosBrowserTest::InProcessBrowserTest::TearDownOnMainThread();
220 testing_profile_.reset(NULL); 220 testing_profile_.reset(NULL);
221 user_manager_enabler_.reset(); 221 user_manager_enabler_.reset();
222 } 222 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 class ExistingUserControllerPublicSessionTest 374 class ExistingUserControllerPublicSessionTest
375 : public ExistingUserControllerTest { 375 : public ExistingUserControllerTest {
376 protected: 376 protected:
377 ExistingUserControllerPublicSessionTest() 377 ExistingUserControllerPublicSessionTest()
378 : public_session_user_id_(policy::GenerateDeviceLocalAccountUserId( 378 : public_session_user_id_(policy::GenerateDeviceLocalAccountUserId(
379 kPublicSessionAccountId, 379 kPublicSessionAccountId,
380 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)) { 380 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)) {
381 } 381 }
382 382
383 virtual void SetUpOnMainThread() override { 383 void SetUpOnMainThread() override {
384 ExistingUserControllerTest::SetUpOnMainThread(); 384 ExistingUserControllerTest::SetUpOnMainThread();
385 385
386 // Wait for the public session user to be created. 386 // Wait for the public session user to be created.
387 if (!user_manager::UserManager::Get()->IsKnownUser( 387 if (!user_manager::UserManager::Get()->IsKnownUser(
388 public_session_user_id_)) { 388 public_session_user_id_)) {
389 content::WindowedNotificationObserver( 389 content::WindowedNotificationObserver(
390 chrome::NOTIFICATION_USER_LIST_CHANGED, 390 chrome::NOTIFICATION_USER_LIST_CHANGED,
391 base::Bind(&user_manager::UserManager::IsKnownUser, 391 base::Bind(&user_manager::UserManager::IsKnownUser,
392 base::Unretained(user_manager::UserManager::Get()), 392 base::Unretained(user_manager::UserManager::Get()),
393 public_session_user_id_)).Wait(); 393 public_session_user_id_)).Wait();
(...skipping 14 matching lines...) Expand all
408 base::RunLoop loop; 408 base::RunLoop loop;
409 store->AddObserver(&observer); 409 store->AddObserver(&observer);
410 EXPECT_CALL(observer, OnStoreLoaded(store)) 410 EXPECT_CALL(observer, OnStoreLoaded(store))
411 .Times(1) 411 .Times(1)
412 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); 412 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit));
413 loop.Run(); 413 loop.Run();
414 store->RemoveObserver(&observer); 414 store->RemoveObserver(&observer);
415 } 415 }
416 } 416 }
417 417
418 virtual void SetUpSessionManager() override { 418 void SetUpSessionManager() override {
419 InstallOwnerKey(); 419 InstallOwnerKey();
420 420
421 // Setup the device policy. 421 // Setup the device policy.
422 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 422 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
423 em::DeviceLocalAccountInfoProto* account = 423 em::DeviceLocalAccountInfoProto* account =
424 proto.mutable_device_local_accounts()->add_account(); 424 proto.mutable_device_local_accounts()->add_account();
425 account->set_account_id(kPublicSessionAccountId); 425 account->set_account_id(kPublicSessionAccountId);
426 account->set_type( 426 account->set_type(
427 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); 427 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION);
428 RefreshDevicePolicy(); 428 RefreshDevicePolicy();
429 429
430 // Setup the device local account policy. 430 // Setup the device local account policy.
431 policy::UserPolicyBuilder device_local_account_policy; 431 policy::UserPolicyBuilder device_local_account_policy;
432 device_local_account_policy.policy_data().set_username( 432 device_local_account_policy.policy_data().set_username(
433 kPublicSessionAccountId); 433 kPublicSessionAccountId);
434 device_local_account_policy.policy_data().set_policy_type( 434 device_local_account_policy.policy_data().set_policy_type(
435 policy::dm_protocol::kChromePublicAccountPolicyType); 435 policy::dm_protocol::kChromePublicAccountPolicyType);
436 device_local_account_policy.policy_data().set_settings_entity_id( 436 device_local_account_policy.policy_data().set_settings_entity_id(
437 kPublicSessionAccountId); 437 kPublicSessionAccountId);
438 device_local_account_policy.Build(); 438 device_local_account_policy.Build();
439 session_manager_client()->set_device_local_account_policy( 439 session_manager_client()->set_device_local_account_policy(
440 kPublicSessionAccountId, 440 kPublicSessionAccountId,
441 device_local_account_policy.GetBlob()); 441 device_local_account_policy.GetBlob());
442 } 442 }
443 443
444 virtual void SetUpLoginDisplay() override { 444 void SetUpLoginDisplay() override {
445 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) 445 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_))
446 .Times(1) 446 .Times(1)
447 .WillOnce(Return(mock_login_display_)); 447 .WillOnce(Return(mock_login_display_));
448 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) 448 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow())
449 .Times(AnyNumber()) 449 .Times(AnyNumber())
450 .WillRepeatedly(ReturnNull()); 450 .WillRepeatedly(ReturnNull());
451 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) 451 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged())
452 .Times(AnyNumber()); 452 .Times(AnyNumber());
453 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _)) 453 EXPECT_CALL(*mock_login_display_, Init(_, _, _, _))
454 .Times(AnyNumber()); 454 .Times(AnyNumber());
455 } 455 }
456 456
457 virtual void SetUpUserManager() override { 457 void SetUpUserManager() override {}
458 }
459 458
460 void ExpectSuccessfulLogin(const UserContext& user_context) { 459 void ExpectSuccessfulLogin(const UserContext& user_context) {
461 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) 460 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false))
462 .Times(AnyNumber()); 461 .Times(AnyNumber());
463 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_)) 462 EXPECT_CALL(*mock_login_utils_, CreateAuthenticator(_))
464 .Times(1) 463 .Times(1)
465 .WillOnce(WithArg<0>(CreateAuthenticator(user_context))); 464 .WillOnce(WithArg<0>(CreateAuthenticator(user_context)));
466 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _)) 465 EXPECT_CALL(*mock_login_utils_, PrepareProfile(user_context, _, _, _))
467 .Times(1) 466 .Times(1)
468 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_, 467 .WillOnce(InvokeWithoutArgs(&profile_prepared_cb_,
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 // First run propagates public accounts and stores them in Local State. 746 // First run propagates public accounts and stores them in Local State.
748 } 747 }
749 748
750 // See http://crbug.com/393704; flaky. 749 // See http://crbug.com/393704; flaky.
751 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, 750 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest,
752 DISABLED_TestLoadingPublicUsersFromLocalState) { 751 DISABLED_TestLoadingPublicUsersFromLocalState) {
753 // Second run loads list of public accounts from Local State. 752 // Second run loads list of public accounts from Local State.
754 } 753 }
755 754
756 } // namespace chromeos 755 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698