OLD | NEW |
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 <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "components/url_matcher/url_matcher_constants.h" | 17 #include "components/url_matcher/url_matcher_constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace url_matcher { | 21 namespace url_matcher { |
21 | 22 |
22 namespace keys = url_matcher_constants; | 23 namespace keys = url_matcher_constants; |
23 | 24 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void UrlConditionCaseTest::Test() const { | 228 void UrlConditionCaseTest::Test() const { |
228 CheckCondition(expected_value_, OK); | 229 CheckCondition(expected_value_, OK); |
229 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_); | 230 CheckCondition(incorrect_case_value_, expected_result_for_wrong_case_); |
230 } | 231 } |
231 | 232 |
232 void UrlConditionCaseTest::CheckCondition( | 233 void UrlConditionCaseTest::CheckCondition( |
233 const std::string& value, | 234 const std::string& value, |
234 UrlConditionCaseTest::ResultType expected_result) const { | 235 UrlConditionCaseTest::ResultType expected_result) const { |
235 base::DictionaryValue condition; | 236 base::DictionaryValue condition; |
236 if (use_list_of_strings_) { | 237 if (use_list_of_strings_) { |
237 base::ListValue* list = new base::ListValue(); | 238 auto list = base::MakeUnique<base::ListValue>(); |
238 list->AppendString(value); | 239 list->AppendString(value); |
239 condition.SetWithoutPathExpansion(condition_key_, list); | 240 condition.SetWithoutPathExpansion(condition_key_, std::move(list)); |
240 } else { | 241 } else { |
241 condition.SetStringWithoutPathExpansion(condition_key_, value); | 242 condition.SetStringWithoutPathExpansion(condition_key_, value); |
242 } | 243 } |
243 | 244 |
244 URLMatcher matcher; | 245 URLMatcher matcher; |
245 std::string error; | 246 std::string error; |
246 scoped_refptr<URLMatcherConditionSet> result; | 247 scoped_refptr<URLMatcherConditionSet> result; |
247 | 248 |
248 result = URLMatcherFactory::CreateFromURLFilterDictionary( | 249 result = URLMatcherFactory::CreateFromURLFilterDictionary( |
249 matcher.condition_factory(), &condition, 1, &error); | 250 matcher.condition_factory(), &condition, 1, &error); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), | 336 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), |
336 }; | 337 }; |
337 | 338 |
338 for (size_t i = 0; i < arraysize(case_tests); ++i) { | 339 for (size_t i = 0; i < arraysize(case_tests); ++i) { |
339 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); | 340 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); |
340 case_tests[i].Test(); | 341 case_tests[i].Test(); |
341 } | 342 } |
342 } | 343 } |
343 | 344 |
344 } // namespace url_matcher | 345 } // namespace url_matcher |
OLD | NEW |