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

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

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 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 | Annotate | Revision Log
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Port range: Allow 80;1000-1010. 49 // Port range: Allow 80;1000-1010.
50 base::ListValue* port_range = new base::ListValue(); 50 base::ListValue* port_range = new base::ListValue();
51 port_range->Append(new base::FundamentalValue(1000)); 51 port_range->Append(new base::FundamentalValue(1000));
52 port_range->Append(new base::FundamentalValue(1010)); 52 port_range->Append(new base::FundamentalValue(1010));
53 base::ListValue* port_ranges = new base::ListValue(); 53 base::ListValue* port_ranges = new base::ListValue();
54 port_ranges->Append(new base::FundamentalValue(80)); 54 port_ranges->Append(new base::FundamentalValue(80));
55 port_ranges->Append(port_range); 55 port_ranges->Append(port_range);
56 56
57 base::ListValue* scheme_list = new base::ListValue(); 57 base::ListValue* scheme_list = new base::ListValue();
58 scheme_list->Append(base::Value::CreateStringValue("http")); 58 scheme_list->Append(new base::StringValue("http"));
59 59
60 base::DictionaryValue valid_condition; 60 base::DictionaryValue valid_condition;
61 valid_condition.SetString(keys::kHostSuffixKey, "example.com"); 61 valid_condition.SetString(keys::kHostSuffixKey, "example.com");
62 valid_condition.SetString(keys::kHostPrefixKey, "www"); 62 valid_condition.SetString(keys::kHostPrefixKey, "www");
63 valid_condition.Set(keys::kPortsKey, port_ranges); 63 valid_condition.Set(keys::kPortsKey, port_ranges);
64 valid_condition.Set(keys::kSchemesKey, scheme_list); 64 valid_condition.Set(keys::kSchemesKey, scheme_list);
65 65
66 // Test wrong condition name passed. 66 // Test wrong condition name passed.
67 error.clear(); 67 error.clear();
68 result = URLMatcherFactory::CreateFromURLFilterDictionary( 68 result = URLMatcherFactory::CreateFromURLFilterDictionary(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // {"hostPrefix": "WWw."} 130 // {"hostPrefix": "WWw."}
131 base::DictionaryValue invalid_condition3; 131 base::DictionaryValue invalid_condition3;
132 invalid_condition3.SetString(keys::kHostPrefixKey, "WWw."); 132 invalid_condition3.SetString(keys::kHostPrefixKey, "WWw.");
133 133
134 // {"hostEquals": "WWW.example.Com"} 134 // {"hostEquals": "WWW.example.Com"}
135 base::DictionaryValue invalid_condition4; 135 base::DictionaryValue invalid_condition4;
136 invalid_condition4.SetString(keys::kHostEqualsKey, "WWW.example.Com"); 136 invalid_condition4.SetString(keys::kHostEqualsKey, "WWW.example.Com");
137 137
138 // {"scheme": ["HTTP"]} 138 // {"scheme": ["HTTP"]}
139 base::ListValue* scheme_list = new base::ListValue(); 139 base::ListValue* scheme_list = new base::ListValue();
140 scheme_list->Append(base::Value::CreateStringValue("HTTP")); 140 scheme_list->Append(new base::StringValue("HTTP"));
141 base::DictionaryValue invalid_condition5; 141 base::DictionaryValue invalid_condition5;
142 invalid_condition5.Set(keys::kSchemesKey, scheme_list); 142 invalid_condition5.Set(keys::kSchemesKey, scheme_list);
143 143
144 const base::DictionaryValue* invalid_conditions[] = { 144 const base::DictionaryValue* invalid_conditions[] = {
145 &invalid_condition1, 145 &invalid_condition1,
146 &invalid_condition2, 146 &invalid_condition2,
147 &invalid_condition3, 147 &invalid_condition3,
148 &invalid_condition4, 148 &invalid_condition4,
149 &invalid_condition5 149 &invalid_condition5
150 }; 150 };
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 CheckCondition(expected_value_, OK); 223 CheckCondition(expected_value_, OK);
224 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_); 224 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_);
225 } 225 }
226 226
227 void UrlConditionCaseTest::CheckCondition( 227 void UrlConditionCaseTest::CheckCondition(
228 const std::string& value, 228 const std::string& value,
229 UrlConditionCaseTest::ResultType expected_result) const { 229 UrlConditionCaseTest::ResultType expected_result) const {
230 base::DictionaryValue condition; 230 base::DictionaryValue condition;
231 if (use_list_of_strings_) { 231 if (use_list_of_strings_) {
232 base::ListValue* list = new base::ListValue(); 232 base::ListValue* list = new base::ListValue();
233 list->Append(base::Value::CreateStringValue(value)); 233 list->Append(new base::StringValue(value));
234 condition.SetWithoutPathExpansion(condition_key_, list); 234 condition.SetWithoutPathExpansion(condition_key_, list);
235 } else { 235 } else {
236 condition.SetStringWithoutPathExpansion(condition_key_, value); 236 condition.SetStringWithoutPathExpansion(condition_key_, value);
237 } 237 }
238 238
239 URLMatcher matcher; 239 URLMatcher matcher;
240 std::string error; 240 std::string error;
241 scoped_refptr<URLMatcherConditionSet> result; 241 scoped_refptr<URLMatcherConditionSet> result;
242 242
243 result = URLMatcherFactory::CreateFromURLFilterDictionary( 243 result = URLMatcherFactory::CreateFromURLFilterDictionary(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), 330 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url),
331 }; 331 };
332 332
333 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(case_tests); ++i) { 333 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(case_tests); ++i) {
334 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); 334 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i));
335 case_tests[i].Test(); 335 case_tests[i].Test();
336 } 336 }
337 } 337 }
338 338
339 } // namespace url_matcher 339 } // namespace url_matcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698