| 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" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 class MultiProfileUserControllerTest | 112 class MultiProfileUserControllerTest |
| 113 : public testing::Test, | 113 : public testing::Test, |
| 114 public MultiProfileUserControllerDelegate { | 114 public MultiProfileUserControllerDelegate { |
| 115 public: | 115 public: |
| 116 MultiProfileUserControllerTest() | 116 MultiProfileUserControllerTest() |
| 117 : fake_user_manager_(new FakeUserManager), | 117 : fake_user_manager_(new FakeUserManager), |
| 118 user_manager_enabler_(fake_user_manager_), | 118 user_manager_enabler_(fake_user_manager_), |
| 119 user_not_allowed_count_(0) {} | 119 user_not_allowed_count_(0) {} |
| 120 virtual ~MultiProfileUserControllerTest() {} | 120 virtual ~MultiProfileUserControllerTest() {} |
| 121 | 121 |
| 122 virtual void SetUp() OVERRIDE { | 122 virtual void SetUp() override { |
| 123 profile_manager_.reset( | 123 profile_manager_.reset( |
| 124 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 124 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 125 ASSERT_TRUE(profile_manager_->SetUp()); | 125 ASSERT_TRUE(profile_manager_->SetUp()); |
| 126 controller_.reset(new MultiProfileUserController( | 126 controller_.reset(new MultiProfileUserController( |
| 127 this, TestingBrowserProcess::GetGlobal()->local_state())); | 127 this, TestingBrowserProcess::GetGlobal()->local_state())); |
| 128 | 128 |
| 129 for (size_t i = 0; i < arraysize(kUsers); ++i) { | 129 for (size_t i = 0; i < arraysize(kUsers); ++i) { |
| 130 const std::string user_email(kUsers[i]); | 130 const std::string user_email(kUsers[i]); |
| 131 const user_manager::User* user = fake_user_manager_->AddUser(user_email); | 131 const user_manager::User* user = fake_user_manager_->AddUser(user_email); |
| 132 | 132 |
| 133 // Note that user profiles are created after user login in reality. | 133 // Note that user profiles are created after user login in reality. |
| 134 TestingProfile* user_profile = | 134 TestingProfile* user_profile = |
| 135 profile_manager_->CreateTestingProfile(user_email); | 135 profile_manager_->CreateTestingProfile(user_email); |
| 136 user_profile->set_profile_name(user_email); | 136 user_profile->set_profile_name(user_email); |
| 137 user_profiles_.push_back(user_profile); | 137 user_profiles_.push_back(user_profile); |
| 138 | 138 |
| 139 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, | 139 ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, |
| 140 user_profile); | 140 user_profile); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 virtual void TearDown() OVERRIDE { | 144 virtual void TearDown() override { |
| 145 // Clear our cached pointer to the PolicyCertVerifier. | 145 // Clear our cached pointer to the PolicyCertVerifier. |
| 146 g_policy_cert_verifier_for_factory = NULL; | 146 g_policy_cert_verifier_for_factory = NULL; |
| 147 | 147 |
| 148 // We must ensure that the PolicyCertVerifier outlives the | 148 // We must ensure that the PolicyCertVerifier outlives the |
| 149 // PolicyCertService so shutdown the profile here. Additionally, we need | 149 // PolicyCertService so shutdown the profile here. Additionally, we need |
| 150 // to run the message loop between freeing the PolicyCertService and | 150 // to run the message loop between freeing the PolicyCertService and |
| 151 // freeing the PolicyCertVerifier (see | 151 // freeing the PolicyCertVerifier (see |
| 152 // PolicyCertService::OnTrustAnchorsChanged() which is called from | 152 // PolicyCertService::OnTrustAnchorsChanged() which is called from |
| 153 // PolicyCertService::Shutdown()). | 153 // PolicyCertService::Shutdown()). |
| 154 controller_.reset(); | 154 controller_.reset(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 182 void SetCachedBehavior(size_t user_index, | 182 void SetCachedBehavior(size_t user_index, |
| 183 const std::string& behavior) { | 183 const std::string& behavior) { |
| 184 controller_->SetCachedValue(kUsers[user_index], behavior); | 184 controller_->SetCachedValue(kUsers[user_index], behavior); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void ResetCounts() { | 187 void ResetCounts() { |
| 188 user_not_allowed_count_ = 0; | 188 user_not_allowed_count_ = 0; |
| 189 } | 189 } |
| 190 | 190 |
| 191 // MultiProfileUserControllerDeleagte overrides: | 191 // MultiProfileUserControllerDeleagte overrides: |
| 192 virtual void OnUserNotAllowed(const std::string& user_email) OVERRIDE { | 192 virtual void OnUserNotAllowed(const std::string& user_email) override { |
| 193 ++user_not_allowed_count_; | 193 ++user_not_allowed_count_; |
| 194 } | 194 } |
| 195 | 195 |
| 196 MultiProfileUserController* controller() { return controller_.get(); } | 196 MultiProfileUserController* controller() { return controller_.get(); } |
| 197 int user_not_allowed_count() const { return user_not_allowed_count_; } | 197 int user_not_allowed_count() const { return user_not_allowed_count_; } |
| 198 | 198 |
| 199 TestingProfile* profile(int index) { | 199 TestingProfile* profile(int index) { |
| 200 return user_profiles_[index]; | 200 return user_profiles_[index]; |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 434 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 435 reason); | 435 reason); |
| 436 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 436 EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
| 437 MultiProfileUserController::GetPrimaryUserPolicy()); | 437 MultiProfileUserController::GetPrimaryUserPolicy()); |
| 438 | 438 |
| 439 // Flush tasks posted to IO. | 439 // Flush tasks posted to IO. |
| 440 base::RunLoop().RunUntilIdle(); | 440 base::RunLoop().RunUntilIdle(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace chromeos | 443 } // namespace chromeos |
| OLD | NEW |