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

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

Issue 10795012: Modify DeterministicSocketData to verify that the sequence number of reads and writes start at zero… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 5518 matching lines...) Expand 10 before | Expand all | Expand 10 after
5529 5529
5530 scoped_ptr<SpdyFrame> 5530 scoped_ptr<SpdyFrame>
5531 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 5531 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
5532 MockRead reads[] = { 5532 MockRead reads[] = {
5533 CreateMockRead(*stream1_reply, 1), 5533 CreateMockRead(*stream1_reply, 1),
5534 CreateMockRead(*stream2_syn, 2), 5534 CreateMockRead(*stream2_syn, 2),
5535 CreateMockRead(*stream1_body, 3), 5535 CreateMockRead(*stream1_body, 3),
5536 CreateMockRead(*stream2_headers, 4), 5536 CreateMockRead(*stream2_headers, 4),
5537 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 5537 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
5538 arraysize(kPushBodyFrame), 5), 5538 arraysize(kPushBodyFrame), 5),
5539 MockRead(ASYNC, 0, 5), // EOF 5539 MockRead(ASYNC, 0, 6), // EOF
5540 }; 5540 };
5541 5541
5542 HttpResponseInfo response; 5542 HttpResponseInfo response;
5543 HttpResponseInfo response2; 5543 HttpResponseInfo response2;
5544 std::string expected_push_result("pushed"); 5544 std::string expected_push_result("pushed");
5545 scoped_ptr<DeterministicSocketData> data( 5545 scoped_ptr<DeterministicSocketData> data(
5546 new DeterministicSocketData(reads, arraysize(reads), 5546 new DeterministicSocketData(reads, arraysize(reads),
5547 writes, arraysize(writes))); 5547 writes, arraysize(writes)));
5548 5548
5549 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5549 NormalSpdyTransactionHelper helper(CreateGetRequest(),
(...skipping 28 matching lines...) Expand all
5578 data->RunFor(3); 5578 data->RunFor(3);
5579 MessageLoop::current()->RunAllPending(); 5579 MessageLoop::current()->RunAllPending();
5580 5580
5581 // Read the server push body. 5581 // Read the server push body.
5582 std::string result2; 5582 std::string result2;
5583 ReadResult(trans2.get(), data.get(), &result2); 5583 ReadResult(trans2.get(), data.get(), &result2);
5584 // Read the response body. 5584 // Read the response body.
5585 std::string result; 5585 std::string result;
5586 ReadResult(trans, data.get(), &result); 5586 ReadResult(trans, data.get(), &result);
5587 5587
5588 // Verify that we consumed all test data.
5589 EXPECT_TRUE(data->at_read_eof());
5590 EXPECT_TRUE(data->at_write_eof());
5591
5592 // Verify that the received push data is same as the expected push data. 5588 // Verify that the received push data is same as the expected push data.
5593 EXPECT_EQ(result2.compare(expected_push_result), 0) 5589 EXPECT_EQ(result2.compare(expected_push_result), 0)
5594 << "Received data: " 5590 << "Received data: "
5595 << result2 5591 << result2
5596 << "||||| Expected data: " 5592 << "||||| Expected data: "
5597 << expected_push_result; 5593 << expected_push_result;
5598 5594
5599 // Verify the SYN_REPLY. 5595 // Verify the SYN_REPLY.
5600 // Copy the response info, because trans goes away. 5596 // Copy the response info, because trans goes away.
5601 response = *trans->GetResponseInfo(); 5597 response = *trans->GetResponseInfo();
5602 response2 = *trans2->GetResponseInfo(); 5598 response2 = *trans2->GetResponseInfo();
5603 5599
5604 VerifyStreamsClosed(helper); 5600 VerifyStreamsClosed(helper);
5605 5601
5606 // Verify the SYN_REPLY. 5602 // Verify the SYN_REPLY.
5607 EXPECT_TRUE(response.headers != NULL); 5603 EXPECT_TRUE(response.headers != NULL);
5608 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5604 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5609 5605
5610 // Verify the pushed stream. 5606 // Verify the pushed stream.
5611 EXPECT_TRUE(response2.headers != NULL); 5607 EXPECT_TRUE(response2.headers != NULL);
5612 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5608 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5609
5610 // Read the final EOF (which will close the session)
5611 data->RunFor(1);
5612
5613 // Verify that we consumed all test data.
5614 EXPECT_TRUE(data->at_read_eof());
5615 EXPECT_TRUE(data->at_write_eof());
5613 } 5616 }
5614 5617
5615 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushWithTwoHeaderFrames) { 5618 TEST_P(SpdyNetworkTransactionSpdy3Test, ServerPushWithTwoHeaderFrames) {
5616 // We push a stream and attempt to claim it before the headers come down. 5619 // We push a stream and attempt to claim it before the headers come down.
5617 static const unsigned char kPushBodyFrame[] = { 5620 static const unsigned char kPushBodyFrame[] = {
5618 0x00, 0x00, 0x00, 0x02, // header, ID 5621 0x00, 0x00, 0x00, 0x02, // header, ID
5619 0x01, 0x00, 0x00, 0x06, // FIN, length 5622 0x01, 0x00, 0x00, 0x06, // FIN, length
5620 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 5623 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
5621 }; 5624 };
5622 scoped_ptr<SpdyFrame> 5625 scoped_ptr<SpdyFrame>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5679 scoped_ptr<SpdyFrame> 5682 scoped_ptr<SpdyFrame>
5680 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 5683 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
5681 MockRead reads[] = { 5684 MockRead reads[] = {
5682 CreateMockRead(*stream1_reply, 1), 5685 CreateMockRead(*stream1_reply, 1),
5683 CreateMockRead(*stream2_syn, 2), 5686 CreateMockRead(*stream2_syn, 2),
5684 CreateMockRead(*stream1_body, 3), 5687 CreateMockRead(*stream1_body, 3),
5685 CreateMockRead(*stream2_headers1, 4), 5688 CreateMockRead(*stream2_headers1, 4),
5686 CreateMockRead(*stream2_headers2, 5), 5689 CreateMockRead(*stream2_headers2, 5),
5687 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 5690 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
5688 arraysize(kPushBodyFrame), 6), 5691 arraysize(kPushBodyFrame), 6),
5689 MockRead(ASYNC, 0, 6), // EOF 5692 MockRead(ASYNC, 0, 7), // EOF
5690 }; 5693 };
5691 5694
5692 HttpResponseInfo response; 5695 HttpResponseInfo response;
5693 HttpResponseInfo response2; 5696 HttpResponseInfo response2;
5694 std::string expected_push_result("pushed"); 5697 std::string expected_push_result("pushed");
5695 scoped_ptr<DeterministicSocketData> data( 5698 scoped_ptr<DeterministicSocketData> data(
5696 new DeterministicSocketData(reads, arraysize(reads), 5699 new DeterministicSocketData(reads, arraysize(reads),
5697 writes, arraysize(writes))); 5700 writes, arraysize(writes)));
5698 5701
5699 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5702 NormalSpdyTransactionHelper helper(CreateGetRequest(),
(...skipping 28 matching lines...) Expand all
5728 data->RunFor(3); 5731 data->RunFor(3);
5729 MessageLoop::current()->RunAllPending(); 5732 MessageLoop::current()->RunAllPending();
5730 5733
5731 // Read the server push body. 5734 // Read the server push body.
5732 std::string result2; 5735 std::string result2;
5733 ReadResult(trans2.get(), data.get(), &result2); 5736 ReadResult(trans2.get(), data.get(), &result2);
5734 // Read the response body. 5737 // Read the response body.
5735 std::string result; 5738 std::string result;
5736 ReadResult(trans, data.get(), &result); 5739 ReadResult(trans, data.get(), &result);
5737 5740
5738 // Verify that we consumed all test data.
5739 EXPECT_TRUE(data->at_read_eof());
5740 EXPECT_TRUE(data->at_write_eof());
5741
5742 // Verify that the received push data is same as the expected push data. 5741 // Verify that the received push data is same as the expected push data.
5743 EXPECT_EQ(result2.compare(expected_push_result), 0) 5742 EXPECT_EQ(result2.compare(expected_push_result), 0)
5744 << "Received data: " 5743 << "Received data: "
5745 << result2 5744 << result2
5746 << "||||| Expected data: " 5745 << "||||| Expected data: "
5747 << expected_push_result; 5746 << expected_push_result;
5748 5747
5749 // Verify the SYN_REPLY. 5748 // Verify the SYN_REPLY.
5750 // Copy the response info, because trans goes away. 5749 // Copy the response info, because trans goes away.
5751 response = *trans->GetResponseInfo(); 5750 response = *trans->GetResponseInfo();
(...skipping 12 matching lines...) Expand all
5764 // Verify we got all the headers 5763 // Verify we got all the headers
5765 EXPECT_TRUE(response2.headers->HasHeaderValue( 5764 EXPECT_TRUE(response2.headers->HasHeaderValue(
5766 "scheme", "http")); 5765 "scheme", "http"));
5767 EXPECT_TRUE(response2.headers->HasHeaderValue( 5766 EXPECT_TRUE(response2.headers->HasHeaderValue(
5768 "host", "www.google.com")); 5767 "host", "www.google.com"));
5769 EXPECT_TRUE(response2.headers->HasHeaderValue( 5768 EXPECT_TRUE(response2.headers->HasHeaderValue(
5770 "path", "/foo.dat")); 5769 "path", "/foo.dat"));
5771 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5770 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5772 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5771 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5773 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); 5772 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1"));
5773
5774 // Read the final EOF (which will close the session)
5775 data->RunFor(1);
5776
5777 // Verify that we consumed all test data.
5778 EXPECT_TRUE(data->at_read_eof());
5779 EXPECT_TRUE(data->at_write_eof());
5774 } 5780 }
5775 5781
5776 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) { 5782 TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyWithHeaders) {
5777 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5783 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5778 MockWrite writes[] = { CreateMockWrite(*req) }; 5784 MockWrite writes[] = { CreateMockWrite(*req) };
5779 5785
5780 static const char* const kInitialHeaders[] = { 5786 static const char* const kInitialHeaders[] = {
5781 ":status", 5787 ":status",
5782 "200 OK", 5788 "200 OK",
5783 ":version", 5789 ":version",
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
6197 // And now we can allow everything else to run to completion. 6203 // And now we can allow everything else to run to completion.
6198 data->SetStop(10); 6204 data->SetStop(10);
6199 data->Run(); 6205 data->Run();
6200 EXPECT_EQ(OK, callback2.WaitForResult()); 6206 EXPECT_EQ(OK, callback2.WaitForResult());
6201 EXPECT_EQ(OK, callback3.WaitForResult()); 6207 EXPECT_EQ(OK, callback3.WaitForResult());
6202 6208
6203 helper.VerifyDataConsumed(); 6209 helper.VerifyDataConsumed();
6204 } 6210 }
6205 6211
6206 } // namespace net 6212 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698