Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: net/http/http_network_transaction_unittest.cc

Issue 1146693003: Fix the use of SocketDataProviders in HttpNetworkTransactionTest.GenerateAuthToken (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction_unittest.cc
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 09919406616830dae1f7790e2fc6f618ca2b169f..fcfba01eae71b75ce542a8f3994059b2529ca9ed 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -10132,35 +10132,49 @@ TEST_P(HttpNetworkTransactionTest, GenerateAuthToken) {
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
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) {
const TestRound& read_write_round = test_config.rounds[round];
// Set up expected reads and writes.
- MockRead reads[2];
- reads[0] = read_write_round.read;
- size_t length_reads = 1;
- if (read_write_round.extra_read) {
- reads[1] = *read_write_round.extra_read;
- length_reads = 2;
+ mock_reads.back().push_back(read_write_round.read);
+ mock_writes.back().push_back(read_write_round.write);
+
+ // kProxyChallenge uses Proxy-Connection: close which means that the
+ // socket is closed and a new one will be created for the next request.
+ 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];
- writes[0] = read_write_round.write;
- size_t length_writes = 1;
+ if (read_write_round.extra_read) {
+ mock_reads.back().push_back(*read_write_round.extra_read);
+ }
if (read_write_round.extra_write) {
- writes[1] = *read_write_round.extra_write;
- length_writes = 2;
+ mock_writes.back().push_back(*read_write_round.extra_write);
}
- StaticSocketDataProvider data_provider(
- reads, length_reads, writes, length_writes);
- session_deps_.socket_factory->AddSocketDataProvider(&data_provider);
// Add an SSL sequence if necessary.
- SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK);
if (round >= test_config.first_ssl_round)
session_deps_.socket_factory->AddSSLSocketDataProvider(
&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.
TestCompletionCallback callback;
int rv;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698