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

Side by Side Diff: components/url_matcher/url_matcher_factory_unittest.cc

Issue 2030833003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/url_matcher/url_matcher_factory.h" 5 #include "components/url_matcher/url_matcher_factory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Valid values: 43 // Valid values:
44 // { 44 // {
45 // "port_range": [80, [1000, 1010]], 45 // "port_range": [80, [1000, 1010]],
46 // "schemes": ["http"], 46 // "schemes": ["http"],
47 // "hostSuffix": "example.com" 47 // "hostSuffix": "example.com"
48 // "hostPrefix": "www" 48 // "hostPrefix": "www"
49 // } 49 // }
50 50
51 // Port range: Allow 80;1000-1010. 51 // Port range: Allow 80;1000-1010.
52 base::ListValue* port_range = new base::ListValue(); 52 base::ListValue* port_range = new base::ListValue();
53 port_range->Append(new base::FundamentalValue(1000)); 53 port_range->AppendInteger(1000);
54 port_range->Append(new base::FundamentalValue(1010)); 54 port_range->AppendInteger(1010);
55 base::ListValue* port_ranges = new base::ListValue(); 55 base::ListValue* port_ranges = new base::ListValue();
56 port_ranges->Append(new base::FundamentalValue(80)); 56 port_ranges->AppendInteger(80);
57 port_ranges->Append(port_range); 57 port_ranges->Append(port_range);
58 58
59 base::ListValue* scheme_list = new base::ListValue(); 59 base::ListValue* scheme_list = new base::ListValue();
60 scheme_list->Append(new base::StringValue("http")); 60 scheme_list->AppendString("http");
61 61
62 base::DictionaryValue valid_condition; 62 base::DictionaryValue valid_condition;
63 valid_condition.SetString(keys::kHostSuffixKey, "example.com"); 63 valid_condition.SetString(keys::kHostSuffixKey, "example.com");
64 valid_condition.SetString(keys::kHostPrefixKey, "www"); 64 valid_condition.SetString(keys::kHostPrefixKey, "www");
65 valid_condition.Set(keys::kPortsKey, port_ranges); 65 valid_condition.Set(keys::kPortsKey, port_ranges);
66 valid_condition.Set(keys::kSchemesKey, scheme_list); 66 valid_condition.Set(keys::kSchemesKey, scheme_list);
67 67
68 // Test wrong condition name passed. 68 // Test wrong condition name passed.
69 error.clear(); 69 error.clear();
70 result = URLMatcherFactory::CreateFromURLFilterDictionary( 70 result = URLMatcherFactory::CreateFromURLFilterDictionary(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // {"hostPrefix": "WWw."} 132 // {"hostPrefix": "WWw."}
133 base::DictionaryValue invalid_condition3; 133 base::DictionaryValue invalid_condition3;
134 invalid_condition3.SetString(keys::kHostPrefixKey, "WWw."); 134 invalid_condition3.SetString(keys::kHostPrefixKey, "WWw.");
135 135
136 // {"hostEquals": "WWW.example.Com"} 136 // {"hostEquals": "WWW.example.Com"}
137 base::DictionaryValue invalid_condition4; 137 base::DictionaryValue invalid_condition4;
138 invalid_condition4.SetString(keys::kHostEqualsKey, "WWW.example.Com"); 138 invalid_condition4.SetString(keys::kHostEqualsKey, "WWW.example.Com");
139 139
140 // {"scheme": ["HTTP"]} 140 // {"scheme": ["HTTP"]}
141 base::ListValue* scheme_list = new base::ListValue(); 141 base::ListValue* scheme_list = new base::ListValue();
142 scheme_list->Append(new base::StringValue("HTTP")); 142 scheme_list->AppendString("HTTP");
143 base::DictionaryValue invalid_condition5; 143 base::DictionaryValue invalid_condition5;
144 invalid_condition5.Set(keys::kSchemesKey, scheme_list); 144 invalid_condition5.Set(keys::kSchemesKey, scheme_list);
145 145
146 const base::DictionaryValue* invalid_conditions[] = { 146 const base::DictionaryValue* invalid_conditions[] = {
147 &invalid_condition1, 147 &invalid_condition1,
148 &invalid_condition2, 148 &invalid_condition2,
149 &invalid_condition3, 149 &invalid_condition3,
150 &invalid_condition4, 150 &invalid_condition4,
151 &invalid_condition5 151 &invalid_condition5
152 }; 152 };
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 CheckCondition(expected_value_, OK); 225 CheckCondition(expected_value_, OK);
226 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_); 226 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_);
227 } 227 }
228 228
229 void UrlConditionCaseTest::CheckCondition( 229 void UrlConditionCaseTest::CheckCondition(
230 const std::string& value, 230 const std::string& value,
231 UrlConditionCaseTest::ResultType expected_result) const { 231 UrlConditionCaseTest::ResultType expected_result) const {
232 base::DictionaryValue condition; 232 base::DictionaryValue condition;
233 if (use_list_of_strings_) { 233 if (use_list_of_strings_) {
234 base::ListValue* list = new base::ListValue(); 234 base::ListValue* list = new base::ListValue();
235 list->Append(new base::StringValue(value)); 235 list->AppendString(value);
236 condition.SetWithoutPathExpansion(condition_key_, list); 236 condition.SetWithoutPathExpansion(condition_key_, list);
237 } else { 237 } else {
238 condition.SetStringWithoutPathExpansion(condition_key_, value); 238 condition.SetStringWithoutPathExpansion(condition_key_, value);
239 } 239 }
240 240
241 URLMatcher matcher; 241 URLMatcher matcher;
242 std::string error; 242 std::string error;
243 scoped_refptr<URLMatcherConditionSet> result; 243 scoped_refptr<URLMatcherConditionSet> result;
244 244
245 result = URLMatcherFactory::CreateFromURLFilterDictionary( 245 result = URLMatcherFactory::CreateFromURLFilterDictionary(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), 332 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url),
333 }; 333 };
334 334
335 for (size_t i = 0; i < arraysize(case_tests); ++i) { 335 for (size_t i = 0; i < arraysize(case_tests); ++i) {
336 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); 336 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i));
337 case_tests[i].Test(); 337 case_tests[i].Test();
338 } 338 }
339 } 339 }
340 340
341 } // namespace url_matcher 341 } // namespace url_matcher
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_prefs.cc ('k') | components/version_ui/version_handler_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698