| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 5 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 15 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 17 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 18 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 18 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 19 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 20 #include "chrome/browser/prefs/browser_prefs.h" | 21 #include "chrome/browser/prefs/browser_prefs.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 MultiProfileUserController::kBehaviorNotAllowed, | 97 MultiProfileUserController::kBehaviorNotAllowed, |
| 97 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, | 98 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
| 98 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, | 99 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
| 99 }, | 100 }, |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 103 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
| 103 // we've ensured the profile has been shut down. | 104 // we've ensured the profile has been shut down. |
| 104 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 105 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |
| 105 | 106 |
| 106 scoped_ptr<KeyedService> TestPolicyCertServiceFactory( | 107 std::unique_ptr<KeyedService> TestPolicyCertServiceFactory( |
| 107 content::BrowserContext* context) { | 108 content::BrowserContext* context) { |
| 108 return policy::PolicyCertService::CreateForTesting( | 109 return policy::PolicyCertService::CreateForTesting( |
| 109 kUsers[0], g_policy_cert_verifier_for_factory, | 110 kUsers[0], g_policy_cert_verifier_for_factory, |
| 110 user_manager::UserManager::Get()); | 111 user_manager::UserManager::Get()); |
| 111 } | 112 } |
| 112 | 113 |
| 113 } // namespace | 114 } // namespace |
| 114 | 115 |
| 115 class MultiProfileUserControllerTest | 116 class MultiProfileUserControllerTest |
| 116 : public testing::Test, | 117 : public testing::Test, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 205 } |
| 205 | 206 |
| 206 MultiProfileUserController* controller() { return controller_.get(); } | 207 MultiProfileUserController* controller() { return controller_.get(); } |
| 207 int user_not_allowed_count() const { return user_not_allowed_count_; } | 208 int user_not_allowed_count() const { return user_not_allowed_count_; } |
| 208 | 209 |
| 209 TestingProfile* profile(int index) { | 210 TestingProfile* profile(int index) { |
| 210 return user_profiles_[index]; | 211 return user_profiles_[index]; |
| 211 } | 212 } |
| 212 | 213 |
| 213 content::TestBrowserThreadBundle threads_; | 214 content::TestBrowserThreadBundle threads_; |
| 214 scoped_ptr<policy::PolicyCertVerifier> cert_verifier_; | 215 std::unique_ptr<policy::PolicyCertVerifier> cert_verifier_; |
| 215 scoped_ptr<TestingProfileManager> profile_manager_; | 216 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 216 FakeChromeUserManager* fake_user_manager_; // Not owned | 217 FakeChromeUserManager* fake_user_manager_; // Not owned |
| 217 ScopedUserManagerEnabler user_manager_enabler_; | 218 ScopedUserManagerEnabler user_manager_enabler_; |
| 218 | 219 |
| 219 scoped_ptr<MultiProfileUserController> controller_; | 220 std::unique_ptr<MultiProfileUserController> controller_; |
| 220 | 221 |
| 221 std::vector<TestingProfile*> user_profiles_; | 222 std::vector<TestingProfile*> user_profiles_; |
| 222 | 223 |
| 223 int user_not_allowed_count_; | 224 int user_not_allowed_count_; |
| 224 | 225 |
| 225 std::vector<AccountId> test_users_; | 226 std::vector<AccountId> test_users_; |
| 226 | 227 |
| 227 private: | 228 private: |
| 228 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserControllerTest); | 229 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserControllerTest); |
| 229 }; | 230 }; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 448 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 448 reason); | 449 reason); |
| 449 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 450 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 450 MultiProfileUserController::GetPrimaryUserPolicy()); | 451 MultiProfileUserController::GetPrimaryUserPolicy()); |
| 451 | 452 |
| 452 // Flush tasks posted to IO. | 453 // Flush tasks posted to IO. |
| 453 base::RunLoop().RunUntilIdle(); | 454 base::RunLoop().RunUntilIdle(); |
| 454 } | 455 } |
| 455 | 456 |
| 456 } // namespace chromeos | 457 } // namespace chromeos |
| OLD | NEW |