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

Unified Diff: components/policy/core/browser/configuration_policy_handler_unittest.cc

Issue 341723002: Refactored StringToIntEnumListPolicyHandler to be more general purpose (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar clang issues. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/browser/configuration_policy_handler_unittest.cc
diff --git a/components/policy/core/browser/configuration_policy_handler_unittest.cc b/components/policy/core/browser/configuration_policy_handler_unittest.cc
index 6145ae9afb39d0eb5ddfd4627ab18c555588fa03..e77462f02d042d22a4199f84610baec7162862a9 100644
--- a/components/policy/core/browser/configuration_policy_handler_unittest.cc
+++ b/components/policy/core/browser/configuration_policy_handler_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/callback.h"
#include "base/json/json_reader.h"
#include "base/memory/scoped_ptr.h"
@@ -17,10 +18,13 @@ namespace policy {
namespace {
-StringToIntEnumListPolicyHandler::MappingEntry kTestTypeMap[] = {
- { "one", 1 },
- { "two", 2 },
-};
+void GetIntegerTypeMap(
+ ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "one", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(1))));
+ result->push_back(new StringMappingListPolicyHandler::MappingEntry(
+ "two", scoped_ptr<base::Value>(base::Value::CreateIntegerValue(2))));
Joao da Silva 2014/06/18 08:45:26 CreateIntegerValue() is deprecated, use new base::
+}
const char kTestPolicy[] = "unit_test.test_policy";
const char kTestPref[] = "unit_test.test_pref";
@@ -49,11 +53,10 @@ TEST(StringToIntEnumListPolicyHandlerTest, CheckPolicySettings) {
base::ListValue list;
PolicyMap policy_map;
PolicyErrorMap errors;
- StringToIntEnumListPolicyHandler handler(
+ StringMappingListPolicyHandler handler(
kTestPolicy,
kTestPref,
- kTestTypeMap,
- kTestTypeMap + arraysize(kTestTypeMap));
+ base::Bind(GetIntegerTypeMap));
policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, list.DeepCopy(), NULL);
@@ -85,17 +88,16 @@ TEST(StringToIntEnumListPolicyHandlerTest, CheckPolicySettings) {
EXPECT_FALSE(errors.GetErrors(kTestPolicy).empty());
}
-TEST(StringToIntEnumListPolicyHandlerTest, ApplyPolicySettings) {
+TEST(StringMappingListPolicyHandlerTest, ApplyPolicySettings) {
base::ListValue list;
base::ListValue expected;
PolicyMap policy_map;
PrefValueMap prefs;
base::Value* value;
- StringToIntEnumListPolicyHandler handler(
+ StringMappingListPolicyHandler handler(
kTestPolicy,
kTestPref,
- kTestTypeMap,
- kTestTypeMap + arraysize(kTestTypeMap));
+ base::Bind(GetIntegerTypeMap));
policy_map.Set(kTestPolicy, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, list.DeepCopy(), NULL);

Powered by Google App Engine
This is Rietveld 408576698