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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 const char kAffiliatedUserID2[] = "test_2@example.com"; | 58 const char kAffiliatedUserID2[] = "test_2@example.com"; |
59 const char kUnaffiliatedUserID[] = "test_2@other_domain.test"; | 59 const char kUnaffiliatedUserID[] = "test_2@other_domain.test"; |
60 | 60 |
61 KeyedService* BuildProfileInvalidationProvider( | 61 KeyedService* BuildProfileInvalidationProvider( |
62 content::BrowserContext* context) { | 62 content::BrowserContext* context) { |
63 scoped_ptr<invalidation::FakeInvalidationService> invalidation_service( | 63 scoped_ptr<invalidation::FakeInvalidationService> invalidation_service( |
64 new invalidation::FakeInvalidationService); | 64 new invalidation::FakeInvalidationService); |
65 invalidation_service->SetInvalidatorState( | 65 invalidation_service->SetInvalidatorState( |
66 syncer::TRANSIENT_INVALIDATION_ERROR); | 66 syncer::TRANSIENT_INVALIDATION_ERROR); |
67 return new invalidation::ProfileInvalidationProvider( | 67 return new invalidation::ProfileInvalidationProvider( |
68 invalidation_service.PassAs<invalidation::InvalidationService>()); | 68 invalidation_service.Pass()); |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 class DeviceCloudPolicyInvalidatorTest : public testing::Test { | 73 class DeviceCloudPolicyInvalidatorTest : public testing::Test { |
74 public: | 74 public: |
75 DeviceCloudPolicyInvalidatorTest(); | 75 DeviceCloudPolicyInvalidatorTest(); |
76 virtual ~DeviceCloudPolicyInvalidatorTest(); | 76 virtual ~DeviceCloudPolicyInvalidatorTest(); |
77 | 77 |
78 // testing::Test: | 78 // testing::Test: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 device_policy_.policy_data().set_invalidation_name("invalidation"); | 151 device_policy_.policy_data().set_invalidation_name("invalidation"); |
152 device_policy_.Build(); | 152 device_policy_.Build(); |
153 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 153 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
154 device_settings_test_helper_.Flush(); | 154 device_settings_test_helper_.Flush(); |
155 | 155 |
156 scoped_ptr<MockCloudPolicyClient> policy_client(new MockCloudPolicyClient); | 156 scoped_ptr<MockCloudPolicyClient> policy_client(new MockCloudPolicyClient); |
157 EXPECT_CALL(*policy_client, SetupRegistration("token", "device-id")); | 157 EXPECT_CALL(*policy_client, SetupRegistration("token", "device-id")); |
158 CloudPolicyCore* core = TestingBrowserProcess::GetGlobal()->platform_part()-> | 158 CloudPolicyCore* core = TestingBrowserProcess::GetGlobal()->platform_part()-> |
159 browser_policy_connector_chromeos()->GetDeviceCloudPolicyManager()-> | 159 browser_policy_connector_chromeos()->GetDeviceCloudPolicyManager()-> |
160 core(); | 160 core(); |
161 core->Connect(policy_client.PassAs<CloudPolicyClient>()); | 161 core->Connect(policy_client.Pass()); |
162 core->StartRefreshScheduler(); | 162 core->StartRefreshScheduler(); |
163 | 163 |
164 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> | 164 invalidation::ProfileInvalidationProviderFactory::GetInstance()-> |
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(); |
(...skipping 565 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 |