chromium/components/subresource_filter/core/common/test_ruleset_creator.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/subresource_filter/core/common/test_ruleset_creator.h"

#include <memory>
#include <string>
#include <string_view>

#include "base/check.h"
#include "base/files/file_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "components/subresource_filter/core/common/indexed_ruleset.h"
#include "components/subresource_filter/core/common/test_ruleset_utils.h"
#include "components/subresource_filter/core/common/unindexed_ruleset.h"
#include "components/url_pattern_index/proto/rules.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h"

namespace subresource_filter {

proto;

namespace {

// The methods below assume that char and uint8_t are interchangeable.
static_assert;

void WriteRulesetContents(const std::vector<uint8_t>& contents,
                          base::FilePath path) {}

std::vector<uint8_t> SerializeUnindexedRulesetWithMultipleRules(
    const std::vector<proto::UrlRule>& rules) {}

std::vector<uint8_t> SerializeIndexedRulesetWithMultipleRules(
    const std::vector<proto::UrlRule>& rules) {}

}  // namespace

namespace testing {

// TestRuleset -----------------------------------------------------------------

TestRuleset::TestRuleset() = default;
TestRuleset::~TestRuleset() = default;

// static
base::File TestRuleset::Open(const TestRuleset& ruleset) {}

// static
void TestRuleset::CorruptByTruncating(const TestRuleset& ruleset,
                                      size_t tail_size) {}

// static
void TestRuleset::CorruptByFilling(const TestRuleset& ruleset,
                                   size_t from,
                                   size_t to,
                                   uint8_t fill_with) {}

// TestRulesetPair -------------------------------------------------------------

TestRulesetPair::TestRulesetPair() = default;
TestRulesetPair::~TestRulesetPair() = default;

// TestRulesetCreator ----------------------------------------------------------

TestRulesetCreator::TestRulesetCreator()
    :{}

TestRulesetCreator::~TestRulesetCreator() {}

void TestRulesetCreator::CreateRulesetToDisallowURLsWithPathSuffix(
    std::string_view suffix,
    TestRulesetPair* test_ruleset_pair) {}

void TestRulesetCreator::CreateUnindexedRulesetToDisallowURLsWithPathSuffix(
    std::string_view suffix,
    TestRuleset* test_unindexed_ruleset) {}

void TestRulesetCreator::CreateRulesetToDisallowURLWithSubstrings(
    std::vector<std::string_view> substrings,
    TestRulesetPair* test_ruleset_pair) {}

void TestRulesetCreator::CreateRulesetToDisallowURLsWithManySuffixes(
    std::string_view suffix,
    int num_of_suffixes,
    TestRulesetPair* test_ruleset_pair) {}

void TestRulesetCreator::CreateRulesetWithRules(
    const std::vector<proto::UrlRule>& rules,
    TestRulesetPair* test_ruleset_pair) {}

void TestRulesetCreator::CreateUnindexedRulesetWithRules(
    const std::vector<proto::UrlRule>& rules,
    TestRuleset* test_unindexed_ruleset) {}

void TestRulesetCreator::GetUniqueTemporaryPath(base::FilePath* path) {}

void TestRulesetCreator::CreateTestRulesetFromContents(
    std::vector<uint8_t> ruleset_contents,
    TestRuleset* ruleset) {}

}  // namespace testing
}  // namespace subresource_filter