chromium/net/dns/host_resolver_internal_result_test_util.cc

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

#include "net/dns/host_resolver_internal_result_test_util.h"

#include <map>
#include <optional>
#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/json/json_writer.h"
#include "base/time/time.h"
#include "net/base/connection_endpoint_metadata.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_endpoint.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/https_record_rdata.h"
#include "net/dns/public/dns_query_type.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace net {

AllOf;
Eq;
MakeMatcher;
Matcher;
MatchResultListener;
PrintToString;
Property;
StringMatchResultListener;

namespace {

class HostResolverInternalResultBaseMatcher
    : public ::testing::MatcherInterface<const HostResolverInternalResult&> {};

class HostResolverInternalDataResultMatcher
    : public HostResolverInternalResultBaseMatcher {};

class HostResolverInternalMetadataResultMatcher
    : public HostResolverInternalResultBaseMatcher {};

class HostResolverInternalErrorResultMatcher
    : public HostResolverInternalResultBaseMatcher {};

class HostResolverInternalAliasResultMatcher
    : public HostResolverInternalResultBaseMatcher {};

}  // namespace

Matcher<const HostResolverInternalResult&> ExpectHostResolverInternalDataResult(
    std::string expected_domain_name,
    DnsQueryType expected_query_type,
    HostResolverInternalResult::Source expected_source,
    Matcher<std::optional<base::TimeTicks>> expiration_matcher,
    Matcher<std::optional<base::Time>> timed_expiration_matcher,
    Matcher<std::vector<IPEndPoint>> endpoints_matcher,
    Matcher<std::vector<std::string>> strings_matcher,
    Matcher<std::vector<HostPortPair>> hosts_matcher) {}

testing::Matcher<const HostResolverInternalResult&>
ExpectHostResolverInternalMetadataResult(
    std::string expected_domain_name,
    DnsQueryType expected_query_type,
    HostResolverInternalResult::Source expected_source,
    testing::Matcher<std::optional<base::TimeTicks>> expiration_matcher,
    testing::Matcher<std::optional<base::Time>> timed_expiration_matcher,
    testing::Matcher<
        std::multimap<HttpsRecordPriority, ConnectionEndpointMetadata>>
        metadatas_matcher) {}

Matcher<const HostResolverInternalResult&>
ExpectHostResolverInternalErrorResult(
    std::string expected_domain_name,
    DnsQueryType expected_query_type,
    HostResolverInternalResult::Source expected_source,
    Matcher<std::optional<base::TimeTicks>> expiration_matcher,
    Matcher<std::optional<base::Time>> timed_expiration_matcher,
    int expected_error) {}

Matcher<const HostResolverInternalResult&>
ExpectHostResolverInternalAliasResult(
    std::string expected_domain_name,
    DnsQueryType expected_query_type,
    HostResolverInternalResult::Source expected_source,
    Matcher<std::optional<base::TimeTicks>> expiration_matcher,
    Matcher<std::optional<base::Time>> timed_expiration_matcher,
    std::string expected_alias_target) {}

std::ostream& operator<<(std::ostream& os,
                         const HostResolverInternalResult& result) {}

}  // namespace net