Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: components/policy/core/common/cloud/component_cloud_policy_service_unittest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "components/policy/core/common/cloud/component_cloud_policy_service.h" 5 #include "components/policy/core/common/cloud/component_cloud_policy_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 loop_.task_runner()) { 121 loop_.task_runner()) {
122 builder_.SetDefaultSigningKey(); 122 builder_.SetDefaultSigningKey();
123 builder_.policy_data().set_policy_type( 123 builder_.policy_data().set_policy_type(
124 dm_protocol::kChromeExtensionPolicyType); 124 dm_protocol::kChromeExtensionPolicyType);
125 builder_.policy_data().set_settings_entity_id(kTestExtension); 125 builder_.policy_data().set_settings_entity_id(kTestExtension);
126 builder_.payload().set_download_url(kTestDownload); 126 builder_.payload().set_download_url(kTestDownload);
127 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy)); 127 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy));
128 128
129 public_key_ = builder_.GetPublicSigningKeyAsString(); 129 public_key_ = builder_.GetPublicSigningKeyAsString();
130 130
131 expected_policy_.Set( 131 expected_policy_.Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
132 "Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 132 POLICY_SOURCE_CLOUD,
133 base::MakeUnique<base::StringValue>("disabled"), nullptr); 133 base::MakeUnique<base::Value>("disabled"), nullptr);
134 expected_policy_.Set("Second", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER, 134 expected_policy_.Set("Second", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER,
135 POLICY_SOURCE_CLOUD, 135 POLICY_SOURCE_CLOUD,
136 base::MakeUnique<base::StringValue>("maybe"), nullptr); 136 base::MakeUnique<base::Value>("maybe"), nullptr);
137 } 137 }
138 138
139 void SetUp() override { 139 void SetUp() override {
140 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 140 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
141 141
142 owned_cache_.reset( 142 owned_cache_.reset(
143 new ResourceCache(temp_dir_.GetPath(), loop_.task_runner())); 143 new ResourceCache(temp_dir_.GetPath(), loop_.task_runner()));
144 cache_ = owned_cache_.get(); 144 cache_ = owned_cache_.get();
145 } 145 }
146 146
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 InitializeRegistry(); 589 InitializeRegistry();
590 590
591 // The initial, cached policy will be served once the backend is initialized. 591 // The initial, cached policy will be served once the backend is initialized.
592 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated()); 592 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
593 Connect(); 593 Connect();
594 Mock::VerifyAndClearExpectations(&delegate_); 594 Mock::VerifyAndClearExpectations(&delegate_);
595 595
596 PolicyBundle expected_bundle; 596 PolicyBundle expected_bundle;
597 expected_bundle.Get(kTestExtensionNS) 597 expected_bundle.Get(kTestExtensionNS)
598 .Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 598 .Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
599 POLICY_SOURCE_CLOUD, 599 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>("published"),
600 base::MakeUnique<base::StringValue>("published"), nullptr); 600 nullptr);
601 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); 601 EXPECT_TRUE(service_->policy().Equals(expected_bundle));
602 } 602 }
603 603
604 TEST_F(ComponentCloudPolicyServiceTest, PurgeWhenServerRemovesPolicy) { 604 TEST_F(ComponentCloudPolicyServiceTest, PurgeWhenServerRemovesPolicy) {
605 // Initialize with cached policy. 605 // Initialize with cached policy.
606 PopulateCache(); 606 PopulateCache();
607 Connect(); 607 Connect();
608 608
609 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated()); 609 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
610 EXPECT_CALL(*client_, FetchPolicy()).Times(0); 610 EXPECT_CALL(*client_, FetchPolicy()).Times(0);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 RunUntilIdle(); 695 RunUntilIdle();
696 Mock::VerifyAndClearExpectations(&delegate_); 696 Mock::VerifyAndClearExpectations(&delegate_);
697 697
698 // The policy is now being served. 698 // The policy is now being served.
699 PolicyBundle expected_bundle; 699 PolicyBundle expected_bundle;
700 expected_bundle.Get(kTestExtensionNS).CopyFrom(expected_policy_); 700 expected_bundle.Get(kTestExtensionNS).CopyFrom(expected_policy_);
701 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); 701 EXPECT_TRUE(service_->policy().Equals(expected_bundle));
702 } 702 }
703 703
704 } // namespace policy 704 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698