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

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..518d07cb770e4b5667fa7714aa79a3d501aac757 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -10132,35 +10132,47 @@ 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);
+
+ if (read_write_round.read.data == kProxyChallenge.data &&
cbentzel 2015/05/21 00:10:25 This isn't immediately obvious to me what is going
cbentzel 2015/05/21 00:22:04 Ah - I'm guessing this is due to Proxy-Connection:
Ryan Hamilton 2015/05/21 02:31:24 You got it. Added a comment. (Good idea)
Ryan Hamilton 2015/05/21 02:31:24 So kProxyChallenge has Proxy-Connection: close whi
cbentzel 2015/05/21 10:10:05 I don't know why off the top of my head. This is w
+ 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) {
cbentzel 2015/05/21 00:22:04 It doesn't look like there is ever a case where a
Ryan Hamilton 2015/05/21 02:31:24 I *think* it's correct as is, because if there was
cbentzel 2015/05/21 10:10:05 This seems reasonable.
+ 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);
cbentzel 2015/05/21 00:10:25 Wow, I'm really surprised this worked. Here's wh
Ryan Hamilton 2015/05/21 02:31:24 Yeah, you got it exactly right! I don't think we
// 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);
+ }
+
+ std::vector<StaticSocketDataProvider*> data_providers;
cbentzel 2015/05/21 00:10:25 Would ScopedVector<StaticSocketDataProvider> work
Ryan Hamilton 2015/05/21 02:31:24 Ooo! nice!
+ 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;
@@ -10186,6 +10198,7 @@ TEST_P(HttpNetworkTransactionTest, GenerateAuthToken) {
EXPECT_TRUE(response->auth_challenge.get() == NULL);
}
}
+ STLDeleteElements(&data_providers);
}
}
« 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