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/policy/device_cloud_policy_invalidator.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 RegisterTestingFactory(BuildProfileInvalidationProvider); | 165 RegisterTestingFactory(BuildProfileInvalidationProvider); |
166 | 166 |
167 invalidator_.reset(new DeviceCloudPolicyInvalidator); | 167 invalidator_.reset(new DeviceCloudPolicyInvalidator); |
168 } | 168 } |
169 | 169 |
170 void DeviceCloudPolicyInvalidatorTest::TearDown() { | 170 void DeviceCloudPolicyInvalidatorTest::TearDown() { |
171 invalidator_.reset(); | 171 invalidator_.reset(); |
172 base::RunLoop().RunUntilIdle(); | 172 base::RunLoop().RunUntilIdle(); |
173 | 173 |
174 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> | 174 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> |
175 RegisterTestingFactory(NULL); | 175 RegisterTestingFactory(nullptr); |
176 chromeos::DeviceSettingsService::Get()->UnsetSessionManager(); | 176 chromeos::DeviceSettingsService::Get()->UnsetSessionManager(); |
177 TestingBrowserProcess::GetGlobal()->SetBrowserPolicyConnector(NULL); | 177 TestingBrowserProcess::GetGlobal()->SetBrowserPolicyConnector(nullptr); |
178 chromeos::DeviceOAuth2TokenServiceFactory::Shutdown(); | 178 chromeos::DeviceOAuth2TokenServiceFactory::Shutdown(); |
179 chromeos::DBusThreadManager::Shutdown(); | 179 chromeos::DBusThreadManager::Shutdown(); |
180 chromeos::SystemSaltGetter::Shutdown(); | 180 chromeos::SystemSaltGetter::Shutdown(); |
181 } | 181 } |
182 | 182 |
183 Profile *DeviceCloudPolicyInvalidatorTest::LogInAndReturnProfile( | 183 Profile *DeviceCloudPolicyInvalidatorTest::LogInAndReturnProfile( |
184 const std::string& user_id) { | 184 const std::string& user_id) { |
185 fake_user_manager_->AddUser(user_id); | 185 fake_user_manager_->AddUser(user_id); |
186 Profile* profile = profile_manager_.CreateTestingProfile(user_id); | 186 Profile* profile = profile_manager_.CreateTestingProfile(user_id); |
187 content::NotificationService::current()->Notify( | 187 content::NotificationService::current()->Notify( |
(...skipping 14 matching lines...) Expand all Loading... |
202 } | 202 } |
203 | 203 |
204 invalidation::FakeInvalidationService* | 204 invalidation::FakeInvalidationService* |
205 DeviceCloudPolicyInvalidatorTest::GetProfileInvalidationService( | 205 DeviceCloudPolicyInvalidatorTest::GetProfileInvalidationService( |
206 Profile* profile) { | 206 Profile* profile) { |
207 invalidation::ProfileInvalidationProvider* invalidation_provider = | 207 invalidation::ProfileInvalidationProvider* invalidation_provider = |
208 static_cast<invalidation::ProfileInvalidationProvider*>( | 208 static_cast<invalidation::ProfileInvalidationProvider*>( |
209 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> | 209 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> |
210 GetServiceForBrowserContext(profile, false)); | 210 GetServiceForBrowserContext(profile, false)); |
211 if (!invalidation_provider) | 211 if (!invalidation_provider) |
212 return NULL; | 212 return nullptr; |
213 return static_cast<invalidation::FakeInvalidationService*>( | 213 return static_cast<invalidation::FakeInvalidationService*>( |
214 invalidation_provider->GetInvalidationService()); | 214 invalidation_provider->GetInvalidationService()); |
215 } | 215 } |
216 | 216 |
217 int DeviceCloudPolicyInvalidatorTest:: | 217 int DeviceCloudPolicyInvalidatorTest:: |
218 GetProfileInvalidationServiceObserverCount() const { | 218 GetProfileInvalidationServiceObserverCount() const { |
219 return invalidator_->profile_invalidation_service_observers_.size(); | 219 return invalidator_->profile_invalidation_service_observers_.size(); |
220 } | 220 } |
221 | 221 |
222 const invalidation::InvalidationService* | 222 const invalidation::InvalidationService* |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 invalidator = GetCloudPolicyInvalidator(); | 737 invalidator = GetCloudPolicyInvalidator(); |
738 ASSERT_TRUE(invalidator); | 738 ASSERT_TRUE(invalidator); |
739 EXPECT_EQ(profile_2_invalidation_service, GetInvalidationService()); | 739 EXPECT_EQ(profile_2_invalidation_service, GetInvalidationService()); |
740 | 740 |
741 // Verify that the invalidator's highest handled invalidation version starts | 741 // Verify that the invalidator's highest handled invalidation version starts |
742 // out as one. | 742 // out as one. |
743 EXPECT_EQ(1, invalidator->highest_handled_invalidation_version()); | 743 EXPECT_EQ(1, invalidator->highest_handled_invalidation_version()); |
744 } | 744 } |
745 | 745 |
746 } // namespace policy | 746 } // namespace policy |
OLD | NEW |