| Index: components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc
|
| diff --git a/components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc b/components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc
|
| index 9c1dd1137e416a89666ad9bd8eef6e2e523119a1..9ad0523c31ba6efc4e1e4699e7e6a6a3bb577271 100644
|
| --- a/components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc
|
| +++ b/components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc
|
| @@ -150,18 +150,15 @@ class ComponentCloudPolicyServiceTest : public testing::Test {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| - void Connect(size_t expected_namespaces_in_client) {
|
| + void Connect() {
|
| client_ = new MockCloudPolicyClient();
|
| client_->SetDMToken(ComponentPolicyBuilder::kFakeToken);
|
| EXPECT_EQ(0u, client_->namespaces_to_fetch_.size());
|
|
|
| + // Connecting adds the user-policy fetch type as a namespace to fetch to
|
| + // the client, but no other namespaces are added for the components.
|
| core_.Connect(scoped_ptr<CloudPolicyClient>(client_));
|
| -
|
| - // |expected_namespaces_in_client| is the expected number of components
|
| - // that the ComponentCloudPolicyService will set at the |client_| at
|
| - // OnCoreConnected.
|
| - EXPECT_EQ(expected_namespaces_in_client,
|
| - client_->namespaces_to_fetch_.size());
|
| + EXPECT_EQ(1u, client_->namespaces_to_fetch_.size());
|
|
|
| // Also initialize the refresh scheduler, so that calls to
|
| // core()->RefreshSoon() trigger a FetchPolicy() call on the mock |client_|.
|
| @@ -245,7 +242,7 @@ class ComponentCloudPolicyServiceTest : public testing::Test {
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, InitializedAtConstructionTime) {
|
| service_.reset();
|
| - Connect(1u);
|
| + Connect();
|
| LoadStore();
|
| InitializeRegistry();
|
|
|
| @@ -266,13 +263,13 @@ TEST_F(ComponentCloudPolicyServiceTest, InitializedAtConstructionTime) {
|
| Mock::VerifyAndClearExpectations(&delegate_);
|
|
|
| EXPECT_TRUE(service_->is_initialized());
|
| - EXPECT_EQ(2u, client_->namespaces_to_fetch_.size());
|
| + EXPECT_EQ(1u, client_->namespaces_to_fetch_.size());
|
| const PolicyBundle empty_bundle;
|
| EXPECT_TRUE(service_->policy().Equals(empty_bundle));
|
| }
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, InitializeStoreThenRegistry) {
|
| - Connect(1u);
|
| + Connect();
|
|
|
| EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated()).Times(0);
|
| EXPECT_CALL(*client_, FetchPolicy()).Times(0);
|
| @@ -294,7 +291,7 @@ TEST_F(ComponentCloudPolicyServiceTest, InitializeStoreThenRegistry) {
|
| }
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, InitializeRegistryThenStore) {
|
| - Connect(1u);
|
| + Connect();
|
|
|
| EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated()).Times(0);
|
| EXPECT_CALL(*client_, FetchPolicy()).Times(0);
|
| @@ -310,14 +307,14 @@ TEST_F(ComponentCloudPolicyServiceTest, InitializeRegistryThenStore) {
|
| Mock::VerifyAndClearExpectations(client_);
|
| Mock::VerifyAndClearExpectations(&delegate_);
|
| EXPECT_TRUE(service_->is_initialized());
|
| - EXPECT_EQ(2u, client_->namespaces_to_fetch_.size());
|
| + EXPECT_EQ(1u, client_->namespaces_to_fetch_.size());
|
| const PolicyBundle empty_bundle;
|
| EXPECT_TRUE(service_->policy().Equals(empty_bundle));
|
| }
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, InitializeWithCachedPolicy) {
|
| PopulateCache();
|
| - Connect(1u);
|
| + Connect();
|
|
|
| EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
|
| EXPECT_CALL(*client_, FetchPolicy());
|
| @@ -327,7 +324,7 @@ TEST_F(ComponentCloudPolicyServiceTest, InitializeWithCachedPolicy) {
|
| Mock::VerifyAndClearExpectations(&delegate_);
|
|
|
| EXPECT_TRUE(service_->is_initialized());
|
| - EXPECT_EQ(2u, client_->namespaces_to_fetch_.size());
|
| + EXPECT_EQ(1u, client_->namespaces_to_fetch_.size());
|
|
|
| // kTestExtension2 is not in the registry so it was dropped.
|
| std::map<std::string, std::string> contents;
|
| @@ -342,7 +339,7 @@ TEST_F(ComponentCloudPolicyServiceTest, InitializeWithCachedPolicy) {
|
| }
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, FetchPolicy) {
|
| - Connect(1u);
|
| + Connect();
|
| // Initialize the store and create the backend.
|
| // A refresh is not needed, because no components are registered yet.
|
| EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
|
| @@ -389,7 +386,7 @@ TEST_F(ComponentCloudPolicyServiceTest, FetchPolicy) {
|
| }
|
|
|
| TEST_F(ComponentCloudPolicyServiceTest, LoadAndPurgeCache) {
|
| - Connect(1u);
|
| + Connect();
|
| // Insert data in the cache.
|
| PopulateCache();
|
| registry_.RegisterComponent(
|
| @@ -448,7 +445,7 @@ TEST_F(ComponentCloudPolicyServiceTest, SignInAfterStartup) {
|
| RunUntilIdle();
|
|
|
| // Now signin. A fetch will be requested for the new extension.
|
| - Connect(2u);
|
| + Connect();
|
|
|
| // Send the response to the service. The response data will be ignored,
|
| // because the store doesn't have the updated credentials yet.
|
| @@ -510,7 +507,7 @@ TEST_F(ComponentCloudPolicyServiceTest, SignOut) {
|
| ASSERT_EQ(1u, contents.size());
|
|
|
| // Now sign in.
|
| - Connect(2u);
|
| + Connect();
|
|
|
| // Signing out removes all of the component policies from the service and
|
| // from the cache. It does not trigger a refresh.
|
|
|