OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/subresource_filter/core/common/unindexed_ruleset.h" | 5 #include "components/subresource_filter/core/common/unindexed_ruleset.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 proto::UrlRule CreateRule(const UrlPattern& url_pattern, | 37 proto::UrlRule CreateRule(const UrlPattern& url_pattern, |
38 proto::SourceType source_type, | 38 proto::SourceType source_type, |
39 bool is_whitelist) { | 39 bool is_whitelist) { |
40 proto::UrlRule rule; | 40 proto::UrlRule rule; |
41 rule.set_semantics(is_whitelist ? proto::RULE_SEMANTICS_WHITELIST | 41 rule.set_semantics(is_whitelist ? proto::RULE_SEMANTICS_WHITELIST |
42 : proto::RULE_SEMANTICS_BLACKLIST); | 42 : proto::RULE_SEMANTICS_BLACKLIST); |
43 | 43 |
44 rule.set_source_type(source_type); | 44 rule.set_source_type(source_type); |
45 rule.set_element_types(proto::ELEMENT_TYPE_ALL); | 45 rule.set_element_types(proto::ELEMENT_TYPE_ALL); |
46 | 46 |
47 rule.set_url_pattern_type(url_pattern.type); | 47 rule.set_url_pattern_type(url_pattern.type()); |
48 rule.set_anchor_left(url_pattern.anchor_left); | 48 rule.set_anchor_left(url_pattern.anchor_left()); |
49 rule.set_anchor_right(url_pattern.anchor_right); | 49 rule.set_anchor_right(url_pattern.anchor_right()); |
50 rule.set_match_case(url_pattern.match_case); | 50 rule.set_match_case(url_pattern.match_case()); |
51 rule.set_url_pattern(url_pattern.url_pattern.as_string()); | 51 rule.set_url_pattern(url_pattern.url_pattern().as_string()); |
52 return rule; | 52 return rule; |
53 } | 53 } |
54 | 54 |
55 // The helper class used for building UnindexedRulesets. | 55 // The helper class used for building UnindexedRulesets. |
56 class UnindexedRulesetTestBuilder { | 56 class UnindexedRulesetTestBuilder { |
57 public: | 57 public: |
58 // Initializes the builder that writes the ruleset to StringOutputStream. | 58 // Initializes the builder that writes the ruleset to StringOutputStream. |
59 UnindexedRulesetTestBuilder() | 59 UnindexedRulesetTestBuilder() |
60 : output_( | 60 : output_( |
61 new google::protobuf::io::StringOutputStream(&ruleset_contents_)), | 61 new google::protobuf::io::StringOutputStream(&ruleset_contents_)), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 { | 195 { |
196 std::string ruleset_contents = builder.ruleset_contents(); | 196 std::string ruleset_contents = builder.ruleset_contents(); |
197 ASSERT_GT(ruleset_contents.size(), static_cast<size_t>(100)); | 197 ASSERT_GT(ruleset_contents.size(), static_cast<size_t>(100)); |
198 ruleset_contents.resize(100); | 198 ruleset_contents.resize(100); |
199 EXPECT_FALSE(IsRulesetValid(ruleset_contents, builder.url_rules())); | 199 EXPECT_FALSE(IsRulesetValid(ruleset_contents, builder.url_rules())); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 } // namespace subresource_filter | 203 } // namespace subresource_filter |
OLD | NEW |