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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Similar to CreateRulesetToDisallowURLsWithPathSuffix, but the resulting | 78 // Similar to CreateRulesetToDisallowURLsWithPathSuffix, but the resulting |
79 // ruleset consists of |num_of_suffixes| rules, each of them disallowing URLs | 79 // ruleset consists of |num_of_suffixes| rules, each of them disallowing URLs |
80 // with suffixes of the form |suffix|_k, 0 <= k < |num_of_suffixes|. | 80 // with suffixes of the form |suffix|_k, 0 <= k < |num_of_suffixes|. |
81 void CreateRulesetToDisallowURLsWithManySuffixes( | 81 void CreateRulesetToDisallowURLsWithManySuffixes( |
82 base::StringPiece suffix, | 82 base::StringPiece suffix, |
83 int num_of_suffixes, | 83 int num_of_suffixes, |
84 TestRulesetPair* test_ruleset_pair); | 84 TestRulesetPair* test_ruleset_pair); |
85 | 85 |
86 void CreateRulesetWithRules(const std::vector<proto::UrlRule>& rules, | 86 void CreateRulesetWithRules(const std::vector<proto::UrlRule>& rules, |
87 TestRulesetPair* test_ruleset_pair); | 87 TestRulesetPair* test_ruleset_pair); |
| 88 void CreateUnindexedRulesetWithRules(const std::vector<proto::UrlRule>& rules, |
| 89 TestRuleset* test_unindexed_ruleset); |
88 | 90 |
89 // Returns a unique |path| that is valid for the lifetime of this instance. | 91 // Returns a unique |path| that is valid for the lifetime of this instance. |
90 // No file at |path| will be automatically created. | 92 // No file at |path| will be automatically created. |
91 void GetUniqueTemporaryPath(base::FilePath* path); | 93 void GetUniqueTemporaryPath(base::FilePath* path); |
92 | 94 |
93 private: | 95 private: |
94 // Writes the |ruleset_contents| to a temporary file, and initializes | 96 // Writes the |ruleset_contents| to a temporary file, and initializes |
95 // |ruleset| to have the same |contents|, and the |path| to this file. | 97 // |ruleset| to have the same |contents|, and the |path| to this file. |
96 void CreateTestRulesetFromContents(std::vector<uint8_t> ruleset_contents, | 98 void CreateTestRulesetFromContents(std::vector<uint8_t> ruleset_contents, |
97 TestRuleset* ruleset); | 99 TestRuleset* ruleset); |
98 | 100 |
99 base::ScopedTempDir scoped_temp_dir_; | 101 base::ScopedTempDir scoped_temp_dir_; |
100 int next_unique_file_suffix = 1; | 102 int next_unique_file_suffix = 1; |
101 | 103 |
102 DISALLOW_COPY_AND_ASSIGN(TestRulesetCreator); | 104 DISALLOW_COPY_AND_ASSIGN(TestRulesetCreator); |
103 }; | 105 }; |
104 | 106 |
105 } // namespace testing | 107 } // namespace testing |
106 } // namespace subresource_filter | 108 } // namespace subresource_filter |
107 | 109 |
108 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ | 110 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ |
OLD | NEW |