#include "services/proxy_resolver/proxy_resolver_impl.h"
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/completion_once_callback.h"
#include "net/base/net_errors.h"
#include "net/base/proxy_server.h"
#include "net/proxy_resolution/mock_proxy_resolver.h"
#include "net/proxy_resolution/proxy_info.h"
#include "net/proxy_resolution/proxy_resolve_dns_operation.h"
#include "net/test/event_waiter.h"
#include "net/test/gtest_util.h"
#include "services/proxy_resolver/proxy_resolver_v8_tracing.h"
#include "services/service_manager/public/cpp/service_context_ref.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"
IsError;
IsOk;
namespace proxy_resolver {
namespace {
class TestRequestClient : public mojom::ProxyResolverRequestClient { … };
TestRequestClient::TestRequestClient(
mojo::PendingReceiver<mojom::ProxyResolverRequestClient> receiver)
: … { … }
void TestRequestClient::WaitForResult() { … }
void TestRequestClient::ReportResult(int32_t error,
const net::ProxyInfo& results) { … }
void TestRequestClient::Alert(const std::string& message) { … }
void TestRequestClient::OnError(int32_t line_number,
const std::string& message) { … }
void TestRequestClient::ResolveDns(
const std::string& hostname,
net::ProxyResolveDnsOperation operation,
const net::NetworkAnonymizationKey& network_anonymization_key,
mojo::PendingRemote<mojom::HostResolverRequestClient> client) { … }
void TestRequestClient::OnDisconnect() { … }
class MockProxyResolverV8Tracing : public ProxyResolverV8Tracing { … };
void MockProxyResolverV8Tracing::GetProxyForURL(
const GURL& url,
const net::NetworkAnonymizationKey& network_anonymization_key,
net::ProxyInfo* results,
net::CompletionOnceCallback callback,
std::unique_ptr<net::ProxyResolver::Request>* request,
std::unique_ptr<Bindings> bindings) { … }
void MockProxyResolverV8Tracing::WaitForCancel() { … }
}
class ProxyResolverImplTest : public testing::Test { … };
TEST_F(ProxyResolverImplTest, GetProxyForUrl) { … }
TEST_F(ProxyResolverImplTest, GetProxyForUrlWithNetworkAnonymizationKey) { … }
TEST_F(ProxyResolverImplTest, GetProxyForUrlFailure) { … }
TEST_F(ProxyResolverImplTest, GetProxyForUrlMultiple) { … }
TEST_F(ProxyResolverImplTest, DestroyClient) { … }
TEST_F(ProxyResolverImplTest, DestroyService) { … }
}