| 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| 11 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 11 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 12 #include "chrome/browser/chromeos/login/users/user_manager.h" | 12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 13 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 13 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 14 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 14 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 15 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 15 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/browser/prefs/browser_prefs.h" | 17 #include "chrome/browser/prefs/browser_prefs.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/scoped_testing_local_state.h" | 19 #include "chrome/test/base/scoped_testing_local_state.h" |
| 20 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 21 #include "chrome/test/base/testing_pref_service_syncable.h" | 21 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/test/base/testing_profile_manager.h" | 23 #include "chrome/test/base/testing_profile_manager.h" |
| 24 #include "components/user_manager/user_manager.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 25 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 28 |
| 28 namespace chromeos { | 29 namespace chromeos { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; | 33 const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; |
| 33 | 34 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, | 95 MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
| 95 }, | 96 }, |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 99 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
| 99 // we've ensured the profile has been shut down. | 100 // we've ensured the profile has been shut down. |
| 100 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 101 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |
| 101 | 102 |
| 102 KeyedService* TestPolicyCertServiceFactory(content::BrowserContext* context) { | 103 KeyedService* TestPolicyCertServiceFactory(content::BrowserContext* context) { |
| 103 return policy::PolicyCertService::CreateForTesting( | 104 return policy::PolicyCertService::CreateForTesting( |
| 104 kUsers[0], g_policy_cert_verifier_for_factory, UserManager::Get()) | 105 kUsers[0], |
| 105 .release(); | 106 g_policy_cert_verifier_for_factory, |
| 107 user_manager::UserManager::Get()).release(); |
| 106 } | 108 } |
| 107 | 109 |
| 108 } // namespace | 110 } // namespace |
| 109 | 111 |
| 110 class MultiProfileUserControllerTest | 112 class MultiProfileUserControllerTest |
| 111 : public testing::Test, | 113 : public testing::Test, |
| 112 public MultiProfileUserControllerDelegate { | 114 public MultiProfileUserControllerDelegate { |
| 113 public: | 115 public: |
| 114 MultiProfileUserControllerTest() | 116 MultiProfileUserControllerTest() |
| 115 : fake_user_manager_(new FakeUserManager), | 117 : fake_user_manager_(new FakeUserManager), |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 434 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 433 reason); | 435 reason); |
| 434 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 436 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 435 MultiProfileUserController::GetPrimaryUserPolicy()); | 437 MultiProfileUserController::GetPrimaryUserPolicy()); |
| 436 | 438 |
| 437 // Flush tasks posted to IO. | 439 // Flush tasks posted to IO. |
| 438 base::RunLoop().RunUntilIdle(); | 440 base::RunLoop().RunUntilIdle(); |
| 439 } | 441 } |
| 440 | 442 |
| 441 } // namespace chromeos | 443 } // namespace chromeos |
| OLD | NEW |