#include "net/dns/dns_task_results_manager.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <string_view>
#include "base/check.h"
#include "base/functional/callback_forward.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "net/base/connection_endpoint_metadata.h"
#include "net/base/net_errors.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/host_resolver_results_test_util.h"
#include "net/dns/https_record_rdata.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
ElementsAre;
IsEmpty;
UnorderedElementsAre;
namespace net {
namespace {
class FakeDelegate : public DnsTaskResultsManager::Delegate { … };
IPEndPoint MakeIPEndPoint(std::string_view ip_literal, uint16_t port = 0) { … }
std::unique_ptr<HostResolverInternalDataResult> CreateDataResult(
std::string_view domain_name,
std::vector<IPEndPoint> ip_endpoints,
DnsQueryType query_type) { … }
std::unique_ptr<HostResolverInternalErrorResult> CreateNoData(
std::string_view domain_name,
DnsQueryType query_type) { … }
std::unique_ptr<HostResolverInternalMetadataResult> CreateMetadata(
std::string_view domain_name,
std::multimap<HttpsRecordPriority, ConnectionEndpointMetadata> metadatas) { … }
std::unique_ptr<HostResolverInternalAliasResult> CreateAlias(
std::string_view domain_name,
DnsQueryType query_type,
std::string_view alias_target) { … }
std::vector<IPEndPoint> WithPort(const std::vector<IPEndPoint>& endpoints,
uint16_t port) { … }
static constexpr std::string_view kHostName = …;
static constexpr std::string_view kAliasTarget1 = …;
static constexpr std::string_view kAliasTarget2 = …;
static const ConnectionEndpointMetadata kMetadata1(
{ … },
{ … },
std::string(kHostName));
static const ConnectionEndpointMetadata kMetadata2(
{ … },
{ … },
std::string(kHostName));
static const std::multimap<HttpsRecordPriority, ConnectionEndpointMetadata>
kMetadatas{ … };
class ManagerFactory { … };
}
class DnsTaskResultsManagerTest : public TestWithTaskEnvironment { … };
TEST_F(DnsTaskResultsManagerTest, IsMetadataReady) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6NotQueried) { … }
TEST_F(DnsTaskResultsManagerTest, IPv4First) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6First) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6Timedout) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6NoDataBeforeIPv4) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6NoDataAfterIPv4) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6EmptyDataAfterIPv4) { … }
TEST_F(DnsTaskResultsManagerTest, IPv4AndIPv6NoData) { … }
TEST_F(DnsTaskResultsManagerTest, IPv4NoDataIPv6AfterResolutionDelay) { … }
TEST_F(DnsTaskResultsManagerTest, MetadataFirst) { … }
TEST_F(DnsTaskResultsManagerTest, MetadataDifferentTargetName) { … }
TEST_F(DnsTaskResultsManagerTest, MetadataAfterIPv6) { … }
TEST_F(DnsTaskResultsManagerTest, IPv6TimedoutAfterMetadata) { … }
TEST_F(DnsTaskResultsManagerTest, IPv4NoDataIPv6TimedoutAfterMetadata) { … }
TEST_F(DnsTaskResultsManagerTest, EndpointOrdering) { … }
TEST_F(DnsTaskResultsManagerTest, Aliases) { … }
}