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

Side by Side Diff: extensions/common/matcher/url_matcher_unittest.cc

Issue 16866009: Rewrite scoped_ptr<T>(NULL) to use the default ctor in extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/matcher/url_matcher_factory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/common/matcher/url_matcher.h" 5 #include "extensions/common/matcher/url_matcher.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 std::set<StringPattern::ID> matching_patterns; 442 std::set<StringPattern::ID> matching_patterns;
443 matching_patterns.insert(m1.string_pattern()->id()); 443 matching_patterns.insert(m1.string_pattern()->id());
444 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url1)); 444 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url1));
445 445
446 matching_patterns.insert(m2.string_pattern()->id()); 446 matching_patterns.insert(m2.string_pattern()->id());
447 EXPECT_TRUE(condition_set->IsMatch(matching_patterns, url1)); 447 EXPECT_TRUE(condition_set->IsMatch(matching_patterns, url1));
448 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url2)); 448 EXPECT_FALSE(condition_set->IsMatch(matching_patterns, url2));
449 449
450 // Test scheme filters. 450 // Test scheme filters.
451 scoped_refptr<URLMatcherConditionSet> condition_set2( 451 scoped_refptr<URLMatcherConditionSet> condition_set2(
452 new URLMatcherConditionSet(1, conditions, 452 new URLMatcherConditionSet(1,
453 scoped_ptr<URLMatcherSchemeFilter>( 453 conditions,
454 new URLMatcherSchemeFilter("https")), 454 scoped_ptr<URLMatcherSchemeFilter>(
455 scoped_ptr<URLMatcherPortFilter>(NULL))); 455 new URLMatcherSchemeFilter("https")),
456 scoped_ptr<URLMatcherPortFilter>()));
456 EXPECT_FALSE(condition_set2->IsMatch(matching_patterns, url1)); 457 EXPECT_FALSE(condition_set2->IsMatch(matching_patterns, url1));
457 scoped_refptr<URLMatcherConditionSet> condition_set3( 458 scoped_refptr<URLMatcherConditionSet> condition_set3(
458 new URLMatcherConditionSet(1, conditions, 459 new URLMatcherConditionSet(1,
459 scoped_ptr<URLMatcherSchemeFilter>( 460 conditions,
460 new URLMatcherSchemeFilter("http")), 461 scoped_ptr<URLMatcherSchemeFilter>(
461 scoped_ptr<URLMatcherPortFilter>(NULL))); 462 new URLMatcherSchemeFilter("http")),
463 scoped_ptr<URLMatcherPortFilter>()));
462 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1)); 464 EXPECT_TRUE(condition_set3->IsMatch(matching_patterns, url1));
463 465
464 // Test port filters. 466 // Test port filters.
465 std::vector<URLMatcherPortFilter::Range> ranges; 467 std::vector<URLMatcherPortFilter::Range> ranges;
466 ranges.push_back(URLMatcherPortFilter::CreateRange(80)); 468 ranges.push_back(URLMatcherPortFilter::CreateRange(80));
467 scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges)); 469 scoped_ptr<URLMatcherPortFilter> filter(new URLMatcherPortFilter(ranges));
468 scoped_refptr<URLMatcherConditionSet> condition_set4( 470 scoped_refptr<URLMatcherConditionSet> condition_set4(
469 new URLMatcherConditionSet(1, conditions, 471 new URLMatcherConditionSet(
470 scoped_ptr<URLMatcherSchemeFilter>(NULL), filter.Pass())); 472 1, conditions, scoped_ptr<URLMatcherSchemeFilter>(), filter.Pass()));
471 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1)); 473 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url1));
472 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3)); 474 EXPECT_TRUE(condition_set4->IsMatch(matching_patterns, url3));
473 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4)); 475 EXPECT_FALSE(condition_set4->IsMatch(matching_patterns, url4));
474 476
475 // Test regex patterns. 477 // Test regex patterns.
476 matching_patterns.clear(); 478 matching_patterns.clear();
477 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo"); 479 URLMatcherCondition r1 = factory.CreateURLMatchesCondition("/fo?oo");
478 std::set<URLMatcherCondition> regex_conditions; 480 std::set<URLMatcherCondition> regex_conditions;
479 regex_conditions.insert(r1); 481 regex_conditions.insert(r1);
480 scoped_refptr<URLMatcherConditionSet> condition_set5( 482 scoped_refptr<URLMatcherConditionSet> condition_set5(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val")); 673 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val"));
672 const int kConditionSetId = 1; 674 const int kConditionSetId = 1;
673 URLMatcherConditionSet::Vector insert; 675 URLMatcherConditionSet::Vector insert;
674 insert.push_back(make_scoped_refptr( 676 insert.push_back(make_scoped_refptr(
675 new URLMatcherConditionSet(kConditionSetId, conditions))); 677 new URLMatcherConditionSet(kConditionSetId, conditions)));
676 matcher.AddConditionSets(insert); 678 matcher.AddConditionSets(insert);
677 EXPECT_EQ(0u, matcher.MatchURL(url).size()); 679 EXPECT_EQ(0u, matcher.MatchURL(url).size());
678 } 680 }
679 681
680 } // namespace extensions 682 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/matcher/url_matcher_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698