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

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

Issue 2666093002: Remove base::FundamentalValue (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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
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, base::MakeUnique<base::Value>(false),
117 base::MakeUnique<base::FundamentalValue>(false), nullptr); 117 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, base::MakeUnique<base::Value>(true), nullptr);
129 base::MakeUnique<base::FundamentalValue>(true), nullptr);
130 UpdateProviderPolicy(policy); 129 UpdateProviderPolicy(policy);
131 value = NULL; 130 value = NULL;
132 EXPECT_TRUE(store_->GetValue(kTestPref, &value)); 131 EXPECT_TRUE(store_->GetValue(kTestPref, &value));
133 boolean_value = false; 132 boolean_value = false;
134 result = value->GetAsBoolean(&boolean_value); 133 result = value->GetAsBoolean(&boolean_value);
135 ASSERT_TRUE(result); 134 ASSERT_TRUE(result);
136 EXPECT_TRUE(boolean_value); 135 EXPECT_TRUE(boolean_value);
137 } 136 }
138 137
139 // Test cases for integer-valued policy settings. 138 // Test cases for integer-valued policy settings.
140 class ConfigurationPolicyPrefStoreIntegerTest 139 class ConfigurationPolicyPrefStoreIntegerTest
141 : public ConfigurationPolicyPrefStoreTest { 140 : public ConfigurationPolicyPrefStoreTest {
142 void SetUp() override { 141 void SetUp() override {
143 handler_list_.AddHandler( 142 handler_list_.AddHandler(
144 base::WrapUnique<ConfigurationPolicyHandler>(new SimplePolicyHandler( 143 base::WrapUnique<ConfigurationPolicyHandler>(new SimplePolicyHandler(
145 kTestPolicy, kTestPref, base::Value::Type::INTEGER))); 144 kTestPolicy, kTestPref, base::Value::Type::INTEGER)));
146 } 145 }
147 }; 146 };
148 147
149 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) { 148 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) {
150 EXPECT_FALSE(store_->GetValue(kTestPref, NULL)); 149 EXPECT_FALSE(store_->GetValue(kTestPref, NULL));
151 } 150 }
152 151
153 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { 152 TEST_F(ConfigurationPolicyPrefStoreIntegerTest, SetValue) {
154 PolicyMap policy; 153 PolicyMap policy;
155 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 154 policy.Set(kTestPolicy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
156 POLICY_SOURCE_CLOUD, base::MakeUnique<base::FundamentalValue>(2), 155 POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(2), nullptr);
157 nullptr);
158 UpdateProviderPolicy(policy); 156 UpdateProviderPolicy(policy);
159 const base::Value* value = NULL; 157 const base::Value* value = NULL;
160 EXPECT_TRUE(store_->GetValue(kTestPref, &value)); 158 EXPECT_TRUE(store_->GetValue(kTestPref, &value));
161 EXPECT_TRUE(base::FundamentalValue(2).Equals(value)); 159 EXPECT_TRUE(base::Value(2).Equals(value));
162 } 160 }
163 161
164 // Exercises the policy refresh mechanism. 162 // Exercises the policy refresh mechanism.
165 class ConfigurationPolicyPrefStoreRefreshTest 163 class ConfigurationPolicyPrefStoreRefreshTest
166 : public ConfigurationPolicyPrefStoreTest { 164 : public ConfigurationPolicyPrefStoreTest {
167 protected: 165 protected:
168 void SetUp() override { 166 void SetUp() override {
169 ConfigurationPolicyPrefStoreTest::SetUp(); 167 ConfigurationPolicyPrefStoreTest::SetUp();
170 store_->AddObserver(&observer_); 168 store_->AddObserver(&observer_);
171 handler_list_.AddHandler( 169 handler_list_.AddHandler(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 .WillRepeatedly(Return(true)); 208 .WillRepeatedly(Return(true));
211 PolicyMap policy; 209 PolicyMap policy;
212 UpdateProviderPolicy(policy); 210 UpdateProviderPolicy(policy);
213 EXPECT_TRUE(observer_.initialized); 211 EXPECT_TRUE(observer_.initialized);
214 EXPECT_TRUE(observer_.initialization_success); 212 EXPECT_TRUE(observer_.initialization_success);
215 Mock::VerifyAndClearExpectations(&observer_); 213 Mock::VerifyAndClearExpectations(&observer_);
216 EXPECT_TRUE(store_->IsInitializationComplete()); 214 EXPECT_TRUE(store_->IsInitializationComplete());
217 } 215 }
218 216
219 } // namespace policy 217 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698