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

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

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 #include <utility>
8 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace url_matcher { 15 namespace url_matcher {
15 16
16 // 17 //
17 // URLMatcherCondition 18 // URLMatcherCondition
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 scoped_ptr<URLMatcherSchemeFilter>( 492 scoped_ptr<URLMatcherSchemeFilter>(
492 new URLMatcherSchemeFilter("http")), 493 new URLMatcherSchemeFilter("http")),
493 scoped_ptr<URLMatcherPortFilter>())); 494 scoped_ptr<URLMatcherPortFilter>()));
494 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1)); 495 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1));
495 496
496 // Test port filters. 497 // Test port filters.
497 std::vector<URLMatcherPortFilter::Range> ranges; 498 std::vector<URLMatcherPortFilter::Range> ranges;
498 ranges.push_back(URLMatcherPortFilter::CreateRange(80)); 499 ranges.push_back(URLMatcherPortFilter::CreateRange(80));
499 scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges)); 500 scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges));
500 scoped_refptr<URLMatcherConditionSet> condition_set4( 501 scoped_refptr<URLMatcherConditionSet> condition_set4(
501 new URLMatcherConditionSet( 502 new URLMatcherConditionSet(1, conditions,
502 1, conditions, scoped_ptr<URLMatcherSchemeFilter>(), filter.Pass())); 503 scoped_ptr<URLMatcherSchemeFilter>(),
504 std::move(filter)));
503 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1)); 505 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1));
504 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3)); 506 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3));
505 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4)); 507 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4));
506 508
507 // Test regex patterns. 509 // Test regex patterns.
508 matching_patterns.clear(); 510 matching_patterns.clear();
509 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo"); 511 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo");
510 std::set<URLMatcherCondition> regex_conditions; 512 std::set<URLMatcherCondition> regex_conditions;
511 regex_conditions.insert(r1); 513 regex_conditions.insert(r1);
512 scoped_refptr<URLMatcherConditionSet> condition_set5( 514 scoped_refptr<URLMatcherConditionSet> condition_set5(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 query_element_type, 558 query_element_type,
557 match_type, 559 match_type,
558 &factory); 560 &factory);
559 URLMatcherConditionSet::QueryConditions query_conditions; 561 URLMatcherConditionSet::QueryConditions query_conditions;
560 query_conditions.insert(q1); 562 query_conditions.insert(q1);
561 563
562 scoped_ptr<URLMatcherSchemeFilter> scheme_filter; 564 scoped_ptr<URLMatcherSchemeFilter> scheme_filter;
563 scoped_ptr<URLMatcherPortFilter> port_filter; 565 scoped_ptr<URLMatcherPortFilter> port_filter;
564 566
565 scoped_refptr<URLMatcherConditionSet> condition_set( 567 scoped_refptr<URLMatcherConditionSet> condition_set(
566 new URLMatcherConditionSet(1, 568 new URLMatcherConditionSet(1, conditions, query_conditions,
567 conditions, 569 std::move(scheme_filter),
568 query_conditions, 570 std::move(port_filter)));
569 scheme_filter.Pass(),
570 port_filter.Pass()));
571 571
572 GURL url("http://www.example.com/foo?" + url_query); 572 GURL url("http://www.example.com/foo?" + url_query);
573 573
574 URLMatcher matcher; 574 URLMatcher matcher;
575 URLMatcherConditionSet::Vector vector; 575 URLMatcherConditionSet::Vector vector;
576 vector.push_back(condition_set); 576 vector.push_back(condition_set);
577 matcher.AddConditionSets(vector); 577 matcher.AddConditionSets(vector);
578 578
579 return matcher.MatchURL(url).size() == 1; 579 return matcher.MatchURL(url).size() == 1;
580 } 580 }
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val")); 980 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val"));
981 const int kConditionSetId = 1; 981 const int kConditionSetId = 1;
982 URLMatcherConditionSet::Vector insert; 982 URLMatcherConditionSet::Vector insert;
983 insert.push_back(make_scoped_refptr( 983 insert.push_back(make_scoped_refptr(
984 new URLMatcherConditionSet(kConditionSetId, conditions))); 984 new URLMatcherConditionSet(kConditionSetId, conditions)));
985 matcher.AddConditionSets(insert); 985 matcher.AddConditionSets(insert);
986 EXPECT_EQ(0u, matcher.MatchURL(url).size()); 986 EXPECT_EQ(0u, matcher.MatchURL(url).size());
987 } 987 }
988 988
989 } // namespace url_matcher 989 } // namespace url_matcher
OLDNEW
« no previous file with comments | « components/url_matcher/url_matcher_factory.cc ('k') | components/user_prefs/tracked/interceptable_pref_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698