OLD | NEW |
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_factory.h" | 5 #include "extensions/common/matcher/url_matcher_factory.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 | 238 |
239 URLMatcher matcher; | 239 URLMatcher matcher; |
240 std::string error; | 240 std::string error; |
241 scoped_refptr<URLMatcherConditionSet> result; | 241 scoped_refptr<URLMatcherConditionSet> result; |
242 | 242 |
243 result = URLMatcherFactory::CreateFromURLFilterDictionary( | 243 result = URLMatcherFactory::CreateFromURLFilterDictionary( |
244 matcher.condition_factory(), &condition, 1, &error); | 244 matcher.condition_factory(), &condition, 1, &error); |
245 if (expected_result == CREATE_FAILURE) { | 245 if (expected_result == CREATE_FAILURE) { |
246 EXPECT_FALSE(error.empty()); | 246 EXPECT_FALSE(error.empty()); |
247 EXPECT_FALSE(result); | 247 EXPECT_FALSE(result.get()); |
248 return; | 248 return; |
249 } | 249 } |
250 EXPECT_EQ("", error); | 250 EXPECT_EQ("", error); |
251 ASSERT_TRUE(result.get()); | 251 ASSERT_TRUE(result.get()); |
252 | 252 |
253 URLMatcherConditionSet::Vector conditions; | 253 URLMatcherConditionSet::Vector conditions; |
254 conditions.push_back(result); | 254 conditions.push_back(result); |
255 matcher.AddConditionSets(conditions); | 255 matcher.AddConditionSets(conditions); |
256 EXPECT_EQ((expected_result == OK ? 1u : 0u), matcher.MatchURL(url_).size()) | 256 EXPECT_EQ((expected_result == OK ? 1u : 0u), matcher.MatchURL(url_).size()) |
257 << "while matching condition " << condition_key_ << " with value " | 257 << "while matching condition " << condition_key_ << " with value " |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), | 330 kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url), |
331 }; | 331 }; |
332 | 332 |
333 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(case_tests); ++i) { | 333 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(case_tests); ++i) { |
334 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); | 334 SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i)); |
335 case_tests[i].Test(); | 335 case_tests[i].Test(); |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 } // namespace extensions | 339 } // namespace extensions |
OLD | NEW |