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

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

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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.h" 5 #include "components/url_matcher/url_matcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
9 #include <memory>
8 #include <utility> 10 #include <utility>
9 11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h" 15 #include "url/gurl.h"
14 16
15 namespace url_matcher { 17 namespace url_matcher {
16 18
17 // 19 //
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 std::set<StringPattern::ID> matching_patterns; 475 std::set<StringPattern::ID> matching_patterns;
474 matching_patterns.insert(m1.string_pattern()->id()); 476 matching_patterns.insert(m1.string_pattern()->id());
475 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url1)); 477 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url1));
476 478
477 matching_patterns.insert(m2.string_pattern()->id()); 479 matching_patterns.insert(m2.string_pattern()->id());
478 EXPECT_TRUE(condition_set->IsMatch(matching_patterns, url1)); 480 EXPECT_TRUE(condition_set->IsMatch(matching_patterns, url1));
479 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url2)); 481 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url2));
480 482
481 // Test scheme filters. 483 // Test scheme filters.
482 scoped_refptr<URLMatcherConditionSet> condition_set2( 484 scoped_refptr<URLMatcherConditionSet> condition_set2(
483 new URLMatcherConditionSet(1, 485 new URLMatcherConditionSet(1, conditions,
484 conditions, 486 std::unique_ptr<URLMatcherSchemeFilter>(
485 scoped_ptr<URLMatcherSchemeFilter>(
486 new URLMatcherSchemeFilter("https")), 487 new URLMatcherSchemeFilter("https")),
487 scoped_ptr<URLMatcherPortFilter>())); 488 std::unique_ptr<URLMatcherPortFilter>()));
488 EXPECT_FALSE(condition_set2->IsMatch(matching_patterns, url1)); 489 EXPECT_FALSE(condition_set2->IsMatch(matching_patterns, url1));
489 scoped_refptr<URLMatcherConditionSet> condition_set3( 490 scoped_refptr<URLMatcherConditionSet> condition_set3(
490 new URLMatcherConditionSet(1, 491 new URLMatcherConditionSet(1, conditions,
491 conditions, 492 std::unique_ptr<URLMatcherSchemeFilter>(
492 scoped_ptr<URLMatcherSchemeFilter>(
493 new URLMatcherSchemeFilter("http")), 493 new URLMatcherSchemeFilter("http")),
494 scoped_ptr<URLMatcherPortFilter>())); 494 std::unique_ptr<URLMatcherPortFilter>()));
495 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1)); 495 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1));
496 496
497 // Test port filters. 497 // Test port filters.
498 std::vector<URLMatcherPortFilter::Range> ranges; 498 std::vector<URLMatcherPortFilter::Range> ranges;
499 ranges.push_back(URLMatcherPortFilter::CreateRange(80)); 499 ranges.push_back(URLMatcherPortFilter::CreateRange(80));
500 scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges)); 500 std::unique_ptr<URLMatcherPortFilter> filter(
501 new URLMatcherPortFilter(ranges));
501 scoped_refptr<URLMatcherConditionSet> condition_set4( 502 scoped_refptr<URLMatcherConditionSet> condition_set4(
502 new URLMatcherConditionSet(1, conditions, 503 new URLMatcherConditionSet(1, conditions,
503 scoped_ptr<URLMatcherSchemeFilter>(), 504 std::unique_ptr<URLMatcherSchemeFilter>(),
504 std::move(filter))); 505 std::move(filter)));
505 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1)); 506 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1));
506 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3)); 507 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3));
507 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4)); 508 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4));
508 509
509 // Test regex patterns. 510 // Test regex patterns.
510 matching_patterns.clear(); 511 matching_patterns.clear();
511 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo"); 512 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo");
512 std::set<URLMatcherCondition> regex_conditions; 513 std::set<URLMatcherCondition> regex_conditions;
513 regex_conditions.insert(r1); 514 regex_conditions.insert(r1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 555
555 URLQueryElementMatcherCondition q1(key, 556 URLQueryElementMatcherCondition q1(key,
556 value, 557 value,
557 query_value_match_type, 558 query_value_match_type,
558 query_element_type, 559 query_element_type,
559 match_type, 560 match_type,
560 &factory); 561 &factory);
561 URLMatcherConditionSet::QueryConditions query_conditions; 562 URLMatcherConditionSet::QueryConditions query_conditions;
562 query_conditions.insert(q1); 563 query_conditions.insert(q1);
563 564
564 scoped_ptr<URLMatcherSchemeFilter> scheme_filter; 565 std::unique_ptr<URLMatcherSchemeFilter> scheme_filter;
565 scoped_ptr<URLMatcherPortFilter> port_filter; 566 std::unique_ptr<URLMatcherPortFilter> port_filter;
566 567
567 scoped_refptr<URLMatcherConditionSet> condition_set( 568 scoped_refptr<URLMatcherConditionSet> condition_set(
568 new URLMatcherConditionSet(1, conditions, query_conditions, 569 new URLMatcherConditionSet(1, conditions, query_conditions,
569 std::move(scheme_filter), 570 std::move(scheme_filter),
570 std::move(port_filter))); 571 std::move(port_filter)));
571 572
572 GURL url("http://www.example.com/foo?" + url_query); 573 GURL url("http://www.example.com/foo?" + url_query);
573 574
574 URLMatcher matcher; 575 URLMatcher matcher;
575 URLMatcherConditionSet::Vector vector; 576 URLMatcherConditionSet::Vector vector;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val")); 981 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val"));
981 const int kConditionSetId = 1; 982 const int kConditionSetId = 1;
982 URLMatcherConditionSet::Vector insert; 983 URLMatcherConditionSet::Vector insert;
983 insert.push_back(make_scoped_refptr( 984 insert.push_back(make_scoped_refptr(
984 new URLMatcherConditionSet(kConditionSetId, conditions))); 985 new URLMatcherConditionSet(kConditionSetId, conditions)));
985 matcher.AddConditionSets(insert); 986 matcher.AddConditionSets(insert);
986 EXPECT_EQ(0u, matcher.MatchURL(url).size()); 987 EXPECT_EQ(0u, matcher.MatchURL(url).size());
987 } 988 }
988 989
989 } // namespace url_matcher 990 } // namespace url_matcher
OLDNEW
« no previous file with comments | « components/url_matcher/url_matcher_factory.cc ('k') | components/user_manager/fake_user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698