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

Side by Side Diff: components/policy/core/browser/configuration_policy_pref_store_unittest.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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 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 "components/policy/core/browser/configuration_policy_pref_store.h" 5 #include "components/policy/core/browser/configuration_policy_pref_store.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 }; 107 };
108 108
109 TEST_F(ConfigurationPolicyPrefStoreBooleanTest, GetDefault) { 109 TEST_F(ConfigurationPolicyPrefStoreBooleanTest, GetDefault) {
110 EXPECT_FALSE(store_->GetValue(kTestPref, NULL)); 110 EXPECT_FALSE(store_->GetValue(kTestPref, NULL));
111 } 111 }
112 112
113 TEST_F(ConfigurationPolicyPrefStoreBooleanTest, SetValue) { 113 TEST_F(ConfigurationPolicyPrefStoreBooleanTest, SetValue) {
114 PolicyMap policy; 114 PolicyMap policy;
115 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 115 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
116 POLICY_SOURCE_CLOUD, 116 POLICY_SOURCE_CLOUD,
117 base::MakeUnique<base::FundamentalValue>(false), nullptr); 117 base::MakeUnique<base::Value>(false), nullptr);
118 UpdateProviderPolicy(policy); 118 UpdateProviderPolicy(policy);
119 const base::Value* value = NULL; 119 const base::Value* value = NULL;
120 EXPECT_TRUE(store_->GetValue(kTestPref, &value)); 120 EXPECT_TRUE(store_->GetValue(kTestPref, &value));
121 ASSERT_TRUE(value); 121 ASSERT_TRUE(value);
122 bool boolean_value = true; 122 bool boolean_value = true;
123 bool result = value->GetAsBoolean(&boolean_value); 123 bool result = value->GetAsBoolean(&boolean_value);
124 ASSERT_TRUE(result); 124 ASSERT_TRUE(result);
125 EXPECT_FALSE(boolean_value); 125 EXPECT_FALSE(boolean_value);
126 126
127 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 127 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
128 POLICY_SOURCE_CLOUD, 128 POLICY_SOURCE_CLOUD,
129 base::MakeUnique<base::FundamentalValue>(true), nullptr); 129 base::MakeUnique<base::Value>(true), nullptr);
130 UpdateProviderPolicy(policy); 130 UpdateProviderPolicy(policy);
131 value = NULL; 131 value = NULL;
132 EXPECT_TRUE(store_->GetValue(kTestPref, &value)); 132 EXPECT_TRUE(store_->GetValue(kTestPref, &value));
133 boolean_value = false; 133 boolean_value = false;
134 result = value->GetAsBoolean(&boolean_value); 134 result = value->GetAsBoolean(&boolean_value);
135 ASSERT_TRUE(result); 135 ASSERT_TRUE(result);
136 EXPECT_TRUE(boolean_value); 136 EXPECT_TRUE(boolean_value);
137 } 137 }
138 138
139 // Test cases for integer-valued policy settings. 139 // Test cases for integer-valued policy settings.
140 class ConfigurationPolicyPrefStoreIntegerTest 140 class ConfigurationPolicyPrefStoreIntegerTest
141 : public ConfigurationPolicyPrefStoreTest { 141 : public ConfigurationPolicyPrefStoreTest {
142 void SetUp() override { 142 void SetUp() override {
143 handler_list_.AddHandler( 143 handler_list_.AddHandler(
144 base::WrapUnique<ConfigurationPolicyHandler>(new SimplePolicyHandler( 144 base::WrapUnique<ConfigurationPolicyHandler>(new SimplePolicyHandler(
145 kTestPolicy, kTestPref, base::Value::TYPE_INTEGER))); 145 kTestPolicy, kTestPref, base::Value::TYPE_INTEGER)));
146 } 146 }
147 }; 147 };
148 148
149 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) { 149 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) {
150 EXPECT_FALSE(store_->GetValue(kTestPref, NULL)); 150 EXPECT_FALSE(store_->GetValue(kTestPref, NULL));
151 } 151 }
152 152
153 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { 153 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, SetValue) {
154 PolicyMap policy; 154 PolicyMap policy;
155 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 155 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
156 POLICY_SOURCE_CLOUD, base::MakeUnique<base::FundamentalValue>(2), 156 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(2),
157 nullptr); 157 nullptr);
158 UpdateProviderPolicy(policy); 158 UpdateProviderPolicy(policy);
159 const base::Value* value = NULL; 159 const base::Value* value = NULL;
160 EXPECT_TRUE(store_->GetValue(kTestPref, &value)); 160 EXPECT_TRUE(store_->GetValue(kTestPref, &value));
161 EXPECT_TRUE(base::FundamentalValue(2).Equals(value)); 161 EXPECT_TRUE(base::Value(2).Equals(value));
162 } 162 }
163 163
164 // Exercises the policy refresh mechanism. 164 // Exercises the policy refresh mechanism.
165 class ConfigurationPolicyPrefStoreRefreshTest 165 class ConfigurationPolicyPrefStoreRefreshTest
166 : public ConfigurationPolicyPrefStoreTest { 166 : public ConfigurationPolicyPrefStoreTest {
167 protected: 167 protected:
168 void SetUp() override { 168 void SetUp() override {
169 ConfigurationPolicyPrefStoreTest::SetUp(); 169 ConfigurationPolicyPrefStoreTest::SetUp();
170 store_->AddObserver(&observer_); 170 store_->AddObserver(&observer_);
171 handler_list_.AddHandler( 171 handler_list_.AddHandler(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 .WillRepeatedly(Return(true)); 210 .WillRepeatedly(Return(true));
211 PolicyMap policy; 211 PolicyMap policy;
212 UpdateProviderPolicy(policy); 212 UpdateProviderPolicy(policy);
213 EXPECT_TRUE(observer_.initialized); 213 EXPECT_TRUE(observer_.initialized);
214 EXPECT_TRUE(observer_.initialization_success); 214 EXPECT_TRUE(observer_.initialization_success);
215 Mock::VerifyAndClearExpectations(&observer_); 215 Mock::VerifyAndClearExpectations(&observer_);
216 EXPECT_TRUE(store_->IsInitializationComplete()); 216 EXPECT_TRUE(store_->IsInitializationComplete());
217 } 217 }
218 218
219 } // namespace policy 219 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698