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.h" | 5 #include "components/url_matcher/url_matcher.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 << "Test " << i << " of test_equal failed"; | 140 << "Test " << i << " of test_equal failed"; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 // | 144 // |
145 // URLMatcherConditionFactory | 145 // URLMatcherConditionFactory |
146 // | 146 // |
147 | 147 |
148 namespace { | 148 namespace { |
149 | 149 |
150 bool Matches(const URLMatcherCondition& condition, std::string text) { | 150 bool Matches(const URLMatcherCondition& condition, const std::string& text) { |
151 return text.find(condition.string_pattern()->pattern()) != | 151 return text.find(condition.string_pattern()->pattern()) != |
152 std::string::npos; | 152 std::string::npos; |
153 } | 153 } |
154 | 154 |
155 } // namespace | 155 } // namespace |
156 | 156 |
157 TEST(URLMatcherConditionFactoryTest, GURLCharacterSet) { | 157 TEST(URLMatcherConditionFactoryTest, GURLCharacterSet) { |
158 // GURL guarantees that neither domain, nor path, nor query may contain | 158 // GURL guarantees that neither domain, nor path, nor query may contain |
159 // non ASCII-7 characters. We test this here, because a change to this | 159 // non ASCII-7 characters. We test this here, because a change to this |
160 // guarantee breaks this implementation horribly. | 160 // guarantee breaks this implementation horribly. |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val")); | 977 conditions.insert(factory->CreateOriginAndPathMatchesCondition("val")); |
978 const int kConditionSetId = 1; | 978 const int kConditionSetId = 1; |
979 URLMatcherConditionSet::Vector insert; | 979 URLMatcherConditionSet::Vector insert; |
980 insert.push_back(make_scoped_refptr( | 980 insert.push_back(make_scoped_refptr( |
981 new URLMatcherConditionSet(kConditionSetId, conditions))); | 981 new URLMatcherConditionSet(kConditionSetId, conditions))); |
982 matcher.AddConditionSets(insert); | 982 matcher.AddConditionSets(insert); |
983 EXPECT_EQ(0u, matcher.MatchURL(url).size()); | 983 EXPECT_EQ(0u, matcher.MatchURL(url).size()); |
984 } | 984 } |
985 | 985 |
986 } // namespace url_matcher | 986 } // namespace url_matcher |
OLD | NEW |