#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/cronet/stale_host_resolver.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/cronet/url_request_context_config.h"
#include "net/base/address_family.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_endpoint.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/network_change_notifier.h"
#include "net/cert/cert_verifier.h"
#include "net/dns/context_host_resolver.h"
#include "net/dns/dns_config.h"
#include "net/dns/dns_hosts.h"
#include "net/dns/dns_test_util.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver_manager.h"
#include "net/dns/host_resolver_proc.h"
#include "net/dns/host_resolver_system_task.h"
#include "net/dns/public/dns_protocol.h"
#include "net/dns/public/dns_query_type.h"
#include "net/dns/public/host_resolver_source.h"
#include "net/http/http_network_session.h"
#include "net/log/net_log_with_source.h"
#include "net/proxy_resolution/proxy_config.h"
#include "net/proxy_resolution/proxy_config_service_fixed.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cronet {
namespace {
const char kHostname[] = …;
const char kCacheAddress[] = …;
const char kNetworkAddress[] = …;
const char kHostsAddress[] = …;
const int kCacheEntryTTLSec = …;
const int kNoStaleDelaySec = …;
const int kLongStaleDelaySec = …;
const uint16_t kPort = …;
const int kAgeFreshSec = …;
const int kAgeExpiredSec = …;
const int kWaitTimeoutSec = …;
std::vector<net::IPEndPoint> MakeEndpoints(const char* ip_address_str) { … }
net::AddressList MakeAddressList(const char* ip_address_str) { … }
std::unique_ptr<net::DnsClient> CreateMockDnsClientForHosts() { … }
std::unique_ptr<net::MockDnsClient> CreateHangingMockDnsClient() { … }
class MockHostResolverProc : public net::HostResolverProc { … };
class StaleHostResolverTest : public testing::Test { … };
TEST_F(StaleHostResolverTest, Null) { … }
TEST_F(StaleHostResolverTest, Create) { … }
TEST_F(StaleHostResolverTest, Network) { … }
TEST_F(StaleHostResolverTest, Hosts) { … }
TEST_F(StaleHostResolverTest, FreshCache) { … }
#if defined(ADDRESS_SANITIZER)
#define MAYBE_StaleCache …
#else
#define MAYBE_StaleCache …
#endif
TEST_F(StaleHostResolverTest, MAYBE_StaleCache) { … }
TEST_F(StaleHostResolverTest, StaleCache_DestroyedResolver) { … }
TEST_F(StaleHostResolverTest, StaleCacheNameNotResolvedEnabled) { … }
TEST_F(StaleHostResolverTest, StaleCacheNameNotResolvedDisabled) { … }
TEST_F(StaleHostResolverTest, NetworkWithStaleCache) { … }
TEST_F(StaleHostResolverTest, CancelWithNoCache) { … }
TEST_F(StaleHostResolverTest, CancelWithStaleCache) { … }
TEST_F(StaleHostResolverTest, ReturnStaleCacheSync) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_StaleUsability …
#else
#define MAYBE_StaleUsability …
#endif
TEST_F(StaleHostResolverTest, MAYBE_StaleUsability) { … }
TEST_F(StaleHostResolverTest, CreatedByContext) { … }
}
}