| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/affiliated_invalidation_service_provide
r_impl.h" | 5 #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide
r_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 11 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 11 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 12 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 12 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 13 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 14 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 14 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 15 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 16 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 17 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
| 17 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 18 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 36 |
| 36 namespace policy { | 37 namespace policy { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 const char kAffiliatedUserID1[] = "test_1@example.com"; | 41 const char kAffiliatedUserID1[] = "test_1@example.com"; |
| 41 const char kAffiliatedUserID2[] = "test_2@example.com"; | 42 const char kAffiliatedUserID2[] = "test_2@example.com"; |
| 42 const char kUnaffiliatedUserID[] = "test@other_domain.test"; | 43 const char kUnaffiliatedUserID[] = "test@other_domain.test"; |
| 43 | 44 |
| 44 KeyedService* BuildProfileInvalidationProvider( | 45 scoped_ptr<KeyedService> BuildProfileInvalidationProvider( |
| 45 content::BrowserContext* context) { | 46 content::BrowserContext* context) { |
| 46 scoped_ptr<invalidation::FakeInvalidationService> invalidation_service( | 47 scoped_ptr<invalidation::FakeInvalidationService> invalidation_service( |
| 47 new invalidation::FakeInvalidationService); | 48 new invalidation::FakeInvalidationService); |
| 48 invalidation_service->SetInvalidatorState( | 49 invalidation_service->SetInvalidatorState( |
| 49 syncer::TRANSIENT_INVALIDATION_ERROR); | 50 syncer::TRANSIENT_INVALIDATION_ERROR); |
| 50 return new invalidation::ProfileInvalidationProvider( | 51 return make_scoped_ptr(new invalidation::ProfileInvalidationProvider( |
| 51 invalidation_service.Pass()); | 52 invalidation_service.Pass())); |
| 52 } | 53 } |
| 53 | 54 |
| 54 } // namespace | 55 } // namespace |
| 55 | 56 |
| 56 // A simple AffiliatedInvalidationServiceProvider::Consumer that registers a | 57 // A simple AffiliatedInvalidationServiceProvider::Consumer that registers a |
| 57 // syncer::FakeInvalidationHandler with the invalidation::InvalidationService | 58 // syncer::FakeInvalidationHandler with the invalidation::InvalidationService |
| 58 // that is currently being made available. | 59 // that is currently being made available. |
| 59 class FakeConsumer : public AffiliatedInvalidationServiceProvider::Consumer { | 60 class FakeConsumer : public AffiliatedInvalidationServiceProvider::Consumer { |
| 60 public: | 61 public: |
| 61 explicit FakeConsumer(AffiliatedInvalidationServiceProviderImpl* provider); | 62 explicit FakeConsumer(AffiliatedInvalidationServiceProviderImpl* provider); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount()); | 652 EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount()); |
| 652 provider_->Shutdown(); | 653 provider_->Shutdown(); |
| 653 EXPECT_EQ(1, consumer_->GetAndClearInvalidationServiceSetCount()); | 654 EXPECT_EQ(1, consumer_->GetAndClearInvalidationServiceSetCount()); |
| 654 EXPECT_EQ(nullptr, consumer_->GetInvalidationService()); | 655 EXPECT_EQ(nullptr, consumer_->GetInvalidationService()); |
| 655 | 656 |
| 656 // Verify that the device-global invalidation service has been destroyed. | 657 // Verify that the device-global invalidation service has been destroyed. |
| 657 EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest()); | 658 EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest()); |
| 658 } | 659 } |
| 659 | 660 |
| 660 } // namespace policy | 661 } // namespace policy |
| OLD | NEW |