Commit 28c9ed24 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Use mock proxy client socket in some tests.

This is necessary to avoid creating a DefaultClientSocketFactory, which
is a leaky singleton and therefore would hold a reference to
ScopedTaskEnvironment's reference counted MockTimeTaskRunner forever,
thus preventing the creating of another ScopedTaskEnvironment.

This is prework for https://crrev.com/c/1037405.

Bug: 791831
Change-Id: Iba9e17cc51d7002318f3a27d694b3d9230f36d4e
Reviewed-on: https://chromium-review.googlesource.com/1037324Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556028}
parent 42581713
...@@ -1865,6 +1865,10 @@ TEST_F(HttpStreamFactoryJobControllerTest, DelayedTCPAlternativeProxy) { ...@@ -1865,6 +1865,10 @@ TEST_F(HttpStreamFactoryJobControllerTest, DelayedTCPAlternativeProxy) {
// Verifies that if the alternative proxy server job fails immediately, the // Verifies that if the alternative proxy server job fails immediately, the
// main job is not blocked. // main job is not blocked.
TEST_F(HttpStreamFactoryJobControllerTest, FailAlternativeProxy) { TEST_F(HttpStreamFactoryJobControllerTest, FailAlternativeProxy) {
session_deps_.socket_factory->UseMockProxyClientSockets();
ProxyClientSocketDataProvider proxy_data(SYNCHRONOUS, OK);
session_deps_.socket_factory->AddProxyClientSocketDataProvider(&proxy_data);
quic_data_ = std::make_unique<MockQuicData>(); quic_data_ = std::make_unique<MockQuicData>();
quic_data_->AddConnect(SYNCHRONOUS, ERR_FAILED); quic_data_->AddConnect(SYNCHRONOUS, ERR_FAILED);
tcp_data_ = std::make_unique<SequencedSocketData>(nullptr, 0, nullptr, 0); tcp_data_ = std::make_unique<SequencedSocketData>(nullptr, 0, nullptr, 0);
...@@ -1914,6 +1918,10 @@ TEST_F(HttpStreamFactoryJobControllerTest, FailAlternativeProxy) { ...@@ -1914,6 +1918,10 @@ TEST_F(HttpStreamFactoryJobControllerTest, FailAlternativeProxy) {
// disconnection, then the proxy delegate is not notified. // disconnection, then the proxy delegate is not notified.
TEST_F(HttpStreamFactoryJobControllerTest, TEST_F(HttpStreamFactoryJobControllerTest,
InternetDisconnectedAlternativeProxy) { InternetDisconnectedAlternativeProxy) {
session_deps_.socket_factory->UseMockProxyClientSockets();
ProxyClientSocketDataProvider proxy_data(SYNCHRONOUS, OK);
session_deps_.socket_factory->AddProxyClientSocketDataProvider(&proxy_data);
quic_data_ = std::make_unique<MockQuicData>(); quic_data_ = std::make_unique<MockQuicData>();
quic_data_->AddConnect(SYNCHRONOUS, ERR_INTERNET_DISCONNECTED); quic_data_->AddConnect(SYNCHRONOUS, ERR_INTERNET_DISCONNECTED);
tcp_data_ = std::make_unique<SequencedSocketData>(nullptr, 0, nullptr, 0); tcp_data_ = std::make_unique<SequencedSocketData>(nullptr, 0, nullptr, 0);
...@@ -1960,6 +1968,10 @@ TEST_F(HttpStreamFactoryJobControllerTest, ...@@ -1960,6 +1968,10 @@ TEST_F(HttpStreamFactoryJobControllerTest,
AlternativeProxyServerJobFailsAfterMainJobSucceeds) { AlternativeProxyServerJobFailsAfterMainJobSucceeds) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
session_deps_.socket_factory->UseMockProxyClientSockets();
ProxyClientSocketDataProvider proxy_data(SYNCHRONOUS, OK);
session_deps_.socket_factory->AddProxyClientSocketDataProvider(&proxy_data);
// Use COLD_START to make the alt job pending. // Use COLD_START to make the alt job pending.
crypto_client_stream_factory_.set_handshake_mode( crypto_client_stream_factory_.set_handshake_mode(
MockCryptoClientStream::COLD_START); MockCryptoClientStream::COLD_START);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment