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

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 1123393005: Remove redundant at_read_eof and at_write_eof methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // the results into a single string. 620 // the results into a single string.
621 621
622 // Read the server push body. 622 // Read the server push body.
623 std::string result2; 623 std::string result2;
624 ReadResult(trans2.get(), data, &result2); 624 ReadResult(trans2.get(), data, &result2);
625 // Read the response body. 625 // Read the response body.
626 std::string result; 626 std::string result;
627 ReadResult(trans, data, &result); 627 ReadResult(trans, data, &result);
628 628
629 // Verify that we consumed all test data. 629 // Verify that we consumed all test data.
630 EXPECT_TRUE(data->at_read_eof()); 630 EXPECT_TRUE(data->AllReadDataConsumed());
631 EXPECT_TRUE(data->at_write_eof()); 631 EXPECT_TRUE(data->AllWriteDataConsumed());
632 632
633 // Verify that the received push data is same as the expected push data. 633 // Verify that the received push data is same as the expected push data.
634 EXPECT_EQ(result2.compare(expected), 0) << "Received data: " 634 EXPECT_EQ(result2.compare(expected), 0) << "Received data: "
635 << result2 635 << result2
636 << "||||| Expected data: " 636 << "||||| Expected data: "
637 << expected; 637 << expected;
638 638
639 // Verify the SYN_REPLY. 639 // Verify the SYN_REPLY.
640 // Copy the response info, because trans goes away. 640 // Copy the response info, because trans goes away.
641 *response = *trans->GetResponseInfo(); 641 *response = *trans->GetResponseInfo();
(...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 EXPECT_EQ(1, d.received_redirect_count()); 2433 EXPECT_EQ(1, d.received_redirect_count());
2434 2434
2435 r->FollowDeferredRedirect(); 2435 r->FollowDeferredRedirect();
2436 base::RunLoop().Run(); 2436 base::RunLoop().Run();
2437 EXPECT_EQ(1, d.response_started_count()); 2437 EXPECT_EQ(1, d.response_started_count());
2438 EXPECT_FALSE(d.received_data_before_response()); 2438 EXPECT_FALSE(d.received_data_before_response());
2439 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status()); 2439 EXPECT_EQ(URLRequestStatus::SUCCESS, r->status().status());
2440 std::string contents("hello!"); 2440 std::string contents("hello!");
2441 EXPECT_EQ(contents, d.data_received()); 2441 EXPECT_EQ(contents, d.data_received());
2442 } 2442 }
2443 EXPECT_TRUE(data.at_read_eof()); 2443 EXPECT_TRUE(data.AllReadDataConsumed());
2444 EXPECT_TRUE(data.at_write_eof()); 2444 EXPECT_TRUE(data.AllWriteDataConsumed());
2445 EXPECT_TRUE(data2.at_read_eof()); 2445 EXPECT_TRUE(data2.AllReadDataConsumed());
2446 EXPECT_TRUE(data2.at_write_eof()); 2446 EXPECT_TRUE(data2.AllWriteDataConsumed());
2447 } 2447 }
2448 2448
2449 // Send a spdy request to www.example.org. Get a pushed stream that redirects to 2449 // Send a spdy request to www.example.org. Get a pushed stream that redirects to
2450 // www.foo.com. 2450 // www.foo.com.
2451 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) { 2451 TEST_P(SpdyNetworkTransactionTest, DISABLED_RedirectServerPush) {
2452 scoped_ptr<SpdyHeaderBlock> headers( 2452 scoped_ptr<SpdyHeaderBlock> headers(
2453 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl())); 2453 spdy_util_.ConstructGetHeaderBlock(GetDefaultUrl()));
2454 (*headers)["user-agent"] = ""; 2454 (*headers)["user-agent"] = "";
2455 (*headers)["accept-encoding"] = "gzip, deflate"; 2455 (*headers)["accept-encoding"] = "gzip, deflate";
2456 2456
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 writes, arraysize(writes)); 3473 writes, arraysize(writes));
3474 3474
3475 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, 3475 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
3476 BoundNetLog(), GetParam(), NULL); 3476 BoundNetLog(), GetParam(), NULL);
3477 helper.SetDeterministic(); 3477 helper.SetDeterministic();
3478 helper.RunPreTestSetup(); 3478 helper.RunPreTestSetup();
3479 helper.AddDeterministicData(&data); 3479 helper.AddDeterministicData(&data);
3480 EXPECT_TRUE(helper.StartDefaultTest()); 3480 EXPECT_TRUE(helper.StartDefaultTest());
3481 data.RunFor(2); 3481 data.RunFor(2);
3482 helper.FinishDefaultTest(); 3482 helper.FinishDefaultTest();
3483 EXPECT_TRUE(data.at_write_eof()); 3483 EXPECT_TRUE(data.AllWriteDataConsumed());
3484 EXPECT_TRUE(!data.at_read_eof()); 3484 EXPECT_TRUE(!data.AllReadDataConsumed());
3485 TransactionHelperResult out = helper.output(); 3485 TransactionHelperResult out = helper.output();
3486 EXPECT_EQ(ERR_FAILED, out.rv); 3486 EXPECT_EQ(ERR_FAILED, out.rv);
3487 } 3487 }
3488 3488
3489 // Test that partial writes work. 3489 // Test that partial writes work.
3490 TEST_P(SpdyNetworkTransactionTest, PartialWrite) { 3490 TEST_P(SpdyNetworkTransactionTest, PartialWrite) {
3491 // Chop the SYN_STREAM frame into 5 chunks. 3491 // Chop the SYN_STREAM frame into 5 chunks.
3492 scoped_ptr<SpdyFrame> req( 3492 scoped_ptr<SpdyFrame> req(
3493 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 3493 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
3494 const int kChunks = 5; 3494 const int kChunks = 5;
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5168 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5169 5169
5170 // Verify the pushed stream. 5170 // Verify the pushed stream.
5171 EXPECT_TRUE(response2.headers.get() != NULL); 5171 EXPECT_TRUE(response2.headers.get() != NULL);
5172 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5172 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5173 5173
5174 // Read the final EOF (which will close the session) 5174 // Read the final EOF (which will close the session)
5175 data.RunFor(1); 5175 data.RunFor(1);
5176 5176
5177 // Verify that we consumed all test data. 5177 // Verify that we consumed all test data.
5178 EXPECT_TRUE(data.at_read_eof()); 5178 EXPECT_TRUE(data.AllReadDataConsumed());
5179 EXPECT_TRUE(data.at_write_eof()); 5179 EXPECT_TRUE(data.AllWriteDataConsumed());
5180 } 5180 }
5181 5181
5182 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames 5182 // TODO(baranovich): HTTP 2 does not allow multiple HEADERS frames
5183 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) { 5183 TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
5184 // We push a stream and attempt to claim it before the headers come down. 5184 // We push a stream and attempt to claim it before the headers come down.
5185 scoped_ptr<SpdyFrame> stream1_syn( 5185 scoped_ptr<SpdyFrame> stream1_syn(
5186 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5186 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5187 scoped_ptr<SpdyFrame> stream1_body( 5187 scoped_ptr<SpdyFrame> stream1_body(
5188 spdy_util_.ConstructSpdyBodyFrame(1, true)); 5188 spdy_util_.ConstructSpdyBodyFrame(1, true));
5189 MockWrite writes[] = { 5189 MockWrite writes[] = {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
5308 // Verify we got all the headers from all header blocks. 5308 // Verify we got all the headers from all header blocks.
5309 if (spdy_util_.spdy_version() < SPDY4) 5309 if (spdy_util_.spdy_version() < SPDY4)
5310 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta")); 5310 EXPECT_TRUE(response2.headers->HasHeaderValue("alpha", "beta"));
5311 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5311 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5312 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5312 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5313 5313
5314 // Read the final EOF (which will close the session) 5314 // Read the final EOF (which will close the session)
5315 data.RunFor(1); 5315 data.RunFor(1);
5316 5316
5317 // Verify that we consumed all test data. 5317 // Verify that we consumed all test data.
5318 EXPECT_TRUE(data.at_read_eof()); 5318 EXPECT_TRUE(data.AllReadDataConsumed());
5319 EXPECT_TRUE(data.at_write_eof()); 5319 EXPECT_TRUE(data.AllWriteDataConsumed());
5320 } 5320 }
5321 5321
5322 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) { 5322 TEST_P(SpdyNetworkTransactionTest, ServerPushWithNoStatusHeaderFrames) {
5323 // We push a stream and attempt to claim it before the headers come down. 5323 // We push a stream and attempt to claim it before the headers come down.
5324 scoped_ptr<SpdyFrame> stream1_syn( 5324 scoped_ptr<SpdyFrame> stream1_syn(
5325 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5325 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5326 scoped_ptr<SpdyFrame> stream1_body( 5326 scoped_ptr<SpdyFrame> stream1_body(
5327 spdy_util_.ConstructSpdyBodyFrame(1, true)); 5327 spdy_util_.ConstructSpdyBodyFrame(1, true));
5328 MockWrite writes[] = { 5328 MockWrite writes[] = {
5329 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS), 5329 CreateMockWrite(*stream1_syn, 0, SYNCHRONOUS),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5414 VerifyStreamsClosed(helper); 5414 VerifyStreamsClosed(helper);
5415 5415
5416 // Verify the SYN_REPLY. 5416 // Verify the SYN_REPLY.
5417 EXPECT_TRUE(response.headers.get() != NULL); 5417 EXPECT_TRUE(response.headers.get() != NULL);
5418 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5418 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5419 5419
5420 // Read the final EOF (which will close the session). 5420 // Read the final EOF (which will close the session).
5421 data.RunFor(1); 5421 data.RunFor(1);
5422 5422
5423 // Verify that we consumed all test data. 5423 // Verify that we consumed all test data.
5424 EXPECT_TRUE(data.at_read_eof()); 5424 EXPECT_TRUE(data.AllReadDataConsumed());
5425 EXPECT_TRUE(data.at_write_eof()); 5425 EXPECT_TRUE(data.AllWriteDataConsumed());
5426 } 5426 }
5427 5427
5428 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) { 5428 TEST_P(SpdyNetworkTransactionTest, SynReplyWithHeaders) {
5429 scoped_ptr<SpdyFrame> req( 5429 scoped_ptr<SpdyFrame> req(
5430 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 5430 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
5431 scoped_ptr<SpdyFrame> rst( 5431 scoped_ptr<SpdyFrame> rst(
5432 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); 5432 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR));
5433 MockWrite writes[] = { 5433 MockWrite writes[] = {
5434 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4), 5434 CreateMockWrite(*req, 0), CreateMockWrite(*rst, 4),
5435 }; 5435 };
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5599 5599
5600 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 5600 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
5601 EXPECT_EQ(ERR_IO_PENDING, rv); 5601 EXPECT_EQ(ERR_IO_PENDING, rv);
5602 rv = callback.WaitForResult(); 5602 rv = callback.WaitForResult();
5603 5603
5604 // Read the response body. 5604 // Read the response body.
5605 std::string result; 5605 std::string result;
5606 ReadResult(trans, &data, &result); 5606 ReadResult(trans, &data, &result);
5607 5607
5608 // Verify that we consumed all test data. 5608 // Verify that we consumed all test data.
5609 EXPECT_TRUE(data.at_read_eof()); 5609 EXPECT_TRUE(data.AllReadDataConsumed());
5610 EXPECT_TRUE(data.at_write_eof()); 5610 EXPECT_TRUE(data.AllWriteDataConsumed());
5611 5611
5612 // Verify the SYN_REPLY. 5612 // Verify the SYN_REPLY.
5613 // Copy the response info, because trans goes away. 5613 // Copy the response info, because trans goes away.
5614 response = *trans->GetResponseInfo(); 5614 response = *trans->GetResponseInfo();
5615 5615
5616 VerifyStreamsClosed(helper); 5616 VerifyStreamsClosed(helper);
5617 5617
5618 // Verify the SYN_REPLY. 5618 // Verify the SYN_REPLY.
5619 EXPECT_TRUE(response.headers.get() != NULL); 5619 EXPECT_TRUE(response.headers.get() != NULL);
5620 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5620 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
6586 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6586 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6587 scoped_ptr<SSLSocketDataProvider> ssl_provider( 6587 scoped_ptr<SSLSocketDataProvider> ssl_provider(
6588 new SSLSocketDataProvider(ASYNC, OK)); 6588 new SSLSocketDataProvider(ASYNC, OK));
6589 // Set to TLS_RSA_WITH_NULL_MD5 6589 // Set to TLS_RSA_WITH_NULL_MD5
6590 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6590 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6591 6591
6592 RunTLSUsageCheckTest(ssl_provider.Pass()); 6592 RunTLSUsageCheckTest(ssl_provider.Pass());
6593 } 6593 }
6594 6594
6595 } // namespace net 6595 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698