Commit cb68dc60 authored by rch's avatar rch Committed by Commit bot

Fix the use of SocketDataProviders in HttpNetworkTransactionTest.GenerateAuthToken

BUG=489701

Review URL: https://codereview.chromium.org/1146693003

Cr-Commit-Position: refs/heads/master@{#330898}
parent fd499084
...@@ -10132,35 +10132,49 @@ TEST_P(HttpNetworkTransactionTest, GenerateAuthToken) { ...@@ -10132,35 +10132,49 @@ TEST_P(HttpNetworkTransactionTest, GenerateAuthToken) {
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK);
std::vector<std::vector<MockRead>> mock_reads(1);
std::vector<std::vector<MockWrite>> mock_writes(1);
for (int round = 0; round < test_config.num_auth_rounds; ++round) { for (int round = 0; round < test_config.num_auth_rounds; ++round) {
const TestRound& read_write_round = test_config.rounds[round]; const TestRound& read_write_round = test_config.rounds[round];
// Set up expected reads and writes. // Set up expected reads and writes.
MockRead reads[2]; mock_reads.back().push_back(read_write_round.read);
reads[0] = read_write_round.read; mock_writes.back().push_back(read_write_round.write);
size_t length_reads = 1;
if (read_write_round.extra_read) { // kProxyChallenge uses Proxy-Connection: close which means that the
reads[1] = *read_write_round.extra_read; // socket is closed and a new one will be created for the next request.
length_reads = 2; if (read_write_round.read.data == kProxyChallenge.data &&
read_write_round.write.data != kConnect.data) {
mock_reads.push_back(std::vector<MockRead>());
mock_writes.push_back(std::vector<MockWrite>());
} }
MockWrite writes[2]; if (read_write_round.extra_read) {
writes[0] = read_write_round.write; mock_reads.back().push_back(*read_write_round.extra_read);
size_t length_writes = 1; }
if (read_write_round.extra_write) { if (read_write_round.extra_write) {
writes[1] = *read_write_round.extra_write; mock_writes.back().push_back(*read_write_round.extra_write);
length_writes = 2;
} }
StaticSocketDataProvider data_provider(
reads, length_reads, writes, length_writes);
session_deps_.socket_factory->AddSocketDataProvider(&data_provider);
// Add an SSL sequence if necessary. // Add an SSL sequence if necessary.
SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK);
if (round >= test_config.first_ssl_round) if (round >= test_config.first_ssl_round)
session_deps_.socket_factory->AddSSLSocketDataProvider( session_deps_.socket_factory->AddSSLSocketDataProvider(
&ssl_socket_data_provider); &ssl_socket_data_provider);
}
ScopedVector<StaticSocketDataProvider> data_providers;
for (size_t i = 0; i < mock_reads.size(); ++i) {
data_providers.push_back(new StaticSocketDataProvider(
vector_as_array(&mock_reads[i]), mock_reads[i].size(),
vector_as_array(&mock_writes[i]), mock_writes[i].size()));
session_deps_.socket_factory->AddSocketDataProvider(
data_providers.back());
}
for (int round = 0; round < test_config.num_auth_rounds; ++round) {
const TestRound& read_write_round = test_config.rounds[round];
// Start or restart the transaction. // Start or restart the transaction.
TestCompletionCallback callback; TestCompletionCallback callback;
int rv; int rv;
......
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