#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_TEST_UTILS_H_
#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_TEST_UTILS_H_
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/sequence_checker.h"
#include "extensions/browser/api/declarative_net_request/constants.h"
#include "extensions/browser/api/declarative_net_request/file_backed_ruleset_source.h"
#include "extensions/browser/api/declarative_net_request/request_action.h"
#include "extensions/browser/api/declarative_net_request/ruleset_manager.h"
#include "extensions/browser/warning_service.h"
#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/api/declarative_net_request/constants.h"
#include "extensions/common/extension_id.h"
namespace content {
class BrowserContext;
}
namespace net {
class HttpResponseHeaders;
}
namespace extensions {
class Extension;
namespace declarative_net_request {
class FileBackedRulesetSource;
struct RequestParams;
class RulesetMatcher;
struct RuleCounts;
struct TestRule;
enum class ExtensionLoadType { … };
RequestAction CreateRequestActionForTesting(
RequestAction::Type type,
uint32_t rule_id = kMinValidID,
uint32_t rule_priority = kDefaultPriority,
RulesetID ruleset_id = kMinValidStaticRulesetID,
const ExtensionId& extension_id = "extensionid");
bool operator==(const RequestAction& lhs, const RequestAction& rhs);
std::ostream& operator<<(std::ostream& output, RequestAction::Type type);
std::ostream& operator<<(std::ostream& output, const RequestAction& action);
std::ostream& operator<<(std::ostream& output, const ParseResult& result);
std::ostream& operator<<(std::ostream& output,
const std::optional<RequestAction>& action);
std::ostream& operator<<(std::ostream& output, LoadRulesetResult result);
std::ostream& operator<<(std::ostream& output, const RuleCounts& count);
bool AreAllIndexedStaticRulesetsValid(
const Extension& extension,
content::BrowserContext* browser_context,
FileBackedRulesetSource::RulesetFilter ruleset_filter);
bool CreateVerifiedMatcher(const std::vector<TestRule>& rules,
const FileBackedRulesetSource& source,
std::unique_ptr<RulesetMatcher>* matcher,
int* expected_checksum = nullptr);
FileBackedRulesetSource CreateTemporarySource(
RulesetID id = kMinValidStaticRulesetID,
size_t rule_count_limit = 100,
ExtensionId extension_id = "extensionid");
api::declarative_net_request::ModifyHeaderInfo CreateModifyHeaderInfo(
api::declarative_net_request::HeaderOperation operation,
std::string header,
std::optional<std::string> value,
std::optional<std::string> regex_filter = std::nullopt,
std::optional<std::string> regex_substitution = std::nullopt);
bool EqualsForTesting(
const api::declarative_net_request::ModifyHeaderInfo& lhs,
const api::declarative_net_request::ModifyHeaderInfo& rhs);
api::declarative_net_request::HeaderInfo CreateHeaderInfo(
std::string header,
std::optional<std::vector<std::string>> values,
std::optional<std::vector<std::string>> excluded_values);
class RulesetManagerObserver : public RulesetManager::TestObserver { … };
class WarningServiceObserver : public WarningService::Observer { … };
base::flat_set<int> GetDisabledRuleIdsFromMatcherForTesting(
const RulesetManager& ruleset_manager,
const Extension& extension,
const std::string& ruleset_id_string);
RequestParams CreateRequestWithResponseHeaders(
const GURL& url,
const net::HttpResponseHeaders* headers);
}
}
#endif