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

Side by Side Diff: net/spdy/spdy_network_transaction_spdy2_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: Fix rebase problem. 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
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/spdy/spdy_network_transaction_spdy3_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 "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 4861 matching lines...) Expand 10 before | Expand all | Expand 10 after
4872 4872
4873 scoped_ptr<SpdyFrame> 4873 scoped_ptr<SpdyFrame>
4874 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 4874 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
4875 MockRead reads[] = { 4875 MockRead reads[] = {
4876 CreateMockRead(*stream1_reply, 1), 4876 CreateMockRead(*stream1_reply, 1),
4877 CreateMockRead(*stream2_syn, 2), 4877 CreateMockRead(*stream2_syn, 2),
4878 CreateMockRead(*stream1_body, 3), 4878 CreateMockRead(*stream1_body, 3),
4879 CreateMockRead(*stream2_headers, 4), 4879 CreateMockRead(*stream2_headers, 4),
4880 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 4880 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
4881 arraysize(kPushBodyFrame), 5), 4881 arraysize(kPushBodyFrame), 5),
4882 MockRead(ASYNC, 0, 5), // EOF 4882 MockRead(ASYNC, 0, 6), // EOF
4883 }; 4883 };
4884 4884
4885 HttpResponseInfo response; 4885 HttpResponseInfo response;
4886 HttpResponseInfo response2; 4886 HttpResponseInfo response2;
4887 std::string expected_push_result("pushed"); 4887 std::string expected_push_result("pushed");
4888 DeterministicSocketData data(reads, arraysize(reads), 4888 DeterministicSocketData data(reads, arraysize(reads),
4889 writes, arraysize(writes)); 4889 writes, arraysize(writes));
4890 4890
4891 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4891 NormalSpdyTransactionHelper helper(CreateGetRequest(),
4892 BoundNetLog(), GetParam(), NULL); 4892 BoundNetLog(), GetParam(), NULL);
(...skipping 27 matching lines...) Expand all
4920 data.RunFor(3); 4920 data.RunFor(3);
4921 MessageLoop::current()->RunAllPending(); 4921 MessageLoop::current()->RunAllPending();
4922 4922
4923 // Read the server push body. 4923 // Read the server push body.
4924 std::string result2; 4924 std::string result2;
4925 ReadResult(trans2.get(), &data, &result2); 4925 ReadResult(trans2.get(), &data, &result2);
4926 // Read the response body. 4926 // Read the response body.
4927 std::string result; 4927 std::string result;
4928 ReadResult(trans, &data, &result); 4928 ReadResult(trans, &data, &result);
4929 4929
4930 // Verify that we consumed all test data.
4931 EXPECT_TRUE(data.at_read_eof());
4932 EXPECT_TRUE(data.at_write_eof());
4933
4934 // Verify that the received push data is same as the expected push data. 4930 // Verify that the received push data is same as the expected push data.
4935 EXPECT_EQ(result2.compare(expected_push_result), 0) 4931 EXPECT_EQ(result2.compare(expected_push_result), 0)
4936 << "Received data: " 4932 << "Received data: "
4937 << result2 4933 << result2
4938 << "||||| Expected data: " 4934 << "||||| Expected data: "
4939 << expected_push_result; 4935 << expected_push_result;
4940 4936
4941 // Verify the SYN_REPLY. 4937 // Verify the SYN_REPLY.
4942 // Copy the response info, because trans goes away. 4938 // Copy the response info, because trans goes away.
4943 response = *trans->GetResponseInfo(); 4939 response = *trans->GetResponseInfo();
4944 response2 = *trans2->GetResponseInfo(); 4940 response2 = *trans2->GetResponseInfo();
4945 4941
4946 VerifyStreamsClosed(helper); 4942 VerifyStreamsClosed(helper);
4947 4943
4948 // Verify the SYN_REPLY. 4944 // Verify the SYN_REPLY.
4949 EXPECT_TRUE(response.headers != NULL); 4945 EXPECT_TRUE(response.headers != NULL);
4950 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 4946 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
4951 4947
4952 // Verify the pushed stream. 4948 // Verify the pushed stream.
4953 EXPECT_TRUE(response2.headers != NULL); 4949 EXPECT_TRUE(response2.headers != NULL);
4954 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 4950 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
4951
4952 // Read the final EOF (which will close the session)
4953 data.RunFor(1);
4954
4955 // Verify that we consumed all test data.
4956 EXPECT_TRUE(data.at_read_eof());
4957 EXPECT_TRUE(data.at_write_eof());
4955 } 4958 }
4956 4959
4957 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithTwoHeaderFrames) { 4960 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithTwoHeaderFrames) {
4958 // We push a stream and attempt to claim it before the headers come down. 4961 // We push a stream and attempt to claim it before the headers come down.
4959 static const unsigned char kPushBodyFrame[] = { 4962 static const unsigned char kPushBodyFrame[] = {
4960 0x00, 0x00, 0x00, 0x02, // header, ID 4963 0x00, 0x00, 0x00, 0x02, // header, ID
4961 0x01, 0x00, 0x00, 0x06, // FIN, length 4964 0x01, 0x00, 0x00, 0x06, // FIN, length
4962 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 4965 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
4963 }; 4966 };
4964 scoped_ptr<SpdyFrame> 4967 scoped_ptr<SpdyFrame>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5020 scoped_ptr<SpdyFrame> 5023 scoped_ptr<SpdyFrame>
5021 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 5024 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
5022 MockRead reads[] = { 5025 MockRead reads[] = {
5023 CreateMockRead(*stream1_reply, 1), 5026 CreateMockRead(*stream1_reply, 1),
5024 CreateMockRead(*stream2_syn, 2), 5027 CreateMockRead(*stream2_syn, 2),
5025 CreateMockRead(*stream1_body, 3), 5028 CreateMockRead(*stream1_body, 3),
5026 CreateMockRead(*stream2_headers1, 4), 5029 CreateMockRead(*stream2_headers1, 4),
5027 CreateMockRead(*stream2_headers2, 5), 5030 CreateMockRead(*stream2_headers2, 5),
5028 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 5031 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
5029 arraysize(kPushBodyFrame), 6), 5032 arraysize(kPushBodyFrame), 6),
5030 MockRead(ASYNC, 0, 6), // EOF 5033 MockRead(ASYNC, 0, 7), // EOF
5031 }; 5034 };
5032 5035
5033 HttpResponseInfo response; 5036 HttpResponseInfo response;
5034 HttpResponseInfo response2; 5037 HttpResponseInfo response2;
5035 std::string expected_push_result("pushed"); 5038 std::string expected_push_result("pushed");
5036 DeterministicSocketData data(reads, arraysize(reads), 5039 DeterministicSocketData data(reads, arraysize(reads),
5037 writes, arraysize(writes)); 5040 writes, arraysize(writes));
5038 5041
5039 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5042 NormalSpdyTransactionHelper helper(CreateGetRequest(),
5040 BoundNetLog(), GetParam(), NULL); 5043 BoundNetLog(), GetParam(), NULL);
(...skipping 27 matching lines...) Expand all
5068 data.RunFor(3); 5071 data.RunFor(3);
5069 MessageLoop::current()->RunAllPending(); 5072 MessageLoop::current()->RunAllPending();
5070 5073
5071 // Read the server push body. 5074 // Read the server push body.
5072 std::string result2; 5075 std::string result2;
5073 ReadResult(trans2.get(), &data, &result2); 5076 ReadResult(trans2.get(), &data, &result2);
5074 // Read the response body. 5077 // Read the response body.
5075 std::string result; 5078 std::string result;
5076 ReadResult(trans, &data, &result); 5079 ReadResult(trans, &data, &result);
5077 5080
5078 // Verify that we consumed all test data.
5079 EXPECT_TRUE(data.at_read_eof());
5080 EXPECT_TRUE(data.at_write_eof());
5081
5082 // Verify that the received push data is same as the expected push data. 5081 // Verify that the received push data is same as the expected push data.
5083 EXPECT_EQ(result2.compare(expected_push_result), 0) 5082 EXPECT_EQ(result2.compare(expected_push_result), 0)
5084 << "Received data: " 5083 << "Received data: "
5085 << result2 5084 << result2
5086 << "||||| Expected data: " 5085 << "||||| Expected data: "
5087 << expected_push_result; 5086 << expected_push_result;
5088 5087
5089 // Verify the SYN_REPLY. 5088 // Verify the SYN_REPLY.
5090 // Copy the response info, because trans goes away. 5089 // Copy the response info, because trans goes away.
5091 response = *trans->GetResponseInfo(); 5090 response = *trans->GetResponseInfo();
5092 response2 = *trans2->GetResponseInfo(); 5091 response2 = *trans2->GetResponseInfo();
5093 5092
5094 VerifyStreamsClosed(helper); 5093 VerifyStreamsClosed(helper);
5095 5094
5096 // Verify the SYN_REPLY. 5095 // Verify the SYN_REPLY.
5097 EXPECT_TRUE(response.headers != NULL); 5096 EXPECT_TRUE(response.headers != NULL);
5098 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5097 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5099 5098
5100 // Verify the pushed stream. 5099 // Verify the pushed stream.
5101 EXPECT_TRUE(response2.headers != NULL); 5100 EXPECT_TRUE(response2.headers != NULL);
5102 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5101 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5103 5102
5104 // Verify we got all the headers 5103 // Verify we got all the headers
5105 EXPECT_TRUE(response2.headers->HasHeaderValue( 5104 EXPECT_TRUE(response2.headers->HasHeaderValue(
5106 "url", 5105 "url",
5107 "http://www.google.com/foo.dat")); 5106 "http://www.google.com/foo.dat"));
5108 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5107 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5109 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5108 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5110 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); 5109 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1"));
5110
5111 // Read the final EOF (which will close the session)
5112 data.RunFor(1);
5113
5114 // Verify that we consumed all test data.
5115 EXPECT_TRUE(data.at_read_eof());
5116 EXPECT_TRUE(data.at_write_eof());
5111 } 5117 }
5112 5118
5113 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithHeaders) { 5119 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithHeaders) {
5114 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5120 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5115 MockWrite writes[] = { CreateMockWrite(*req) }; 5121 MockWrite writes[] = { CreateMockWrite(*req) };
5116 5122
5117 static const char* const kInitialHeaders[] = { 5123 static const char* const kInitialHeaders[] = {
5118 "status", 5124 "status",
5119 "200 OK", 5125 "200 OK",
5120 "version", 5126 "version",
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
5526 // And now we can allow everything else to run to completion. 5532 // And now we can allow everything else to run to completion.
5527 data.SetStop(10); 5533 data.SetStop(10);
5528 data.Run(); 5534 data.Run();
5529 EXPECT_EQ(OK, callback2.WaitForResult()); 5535 EXPECT_EQ(OK, callback2.WaitForResult());
5530 EXPECT_EQ(OK, callback3.WaitForResult()); 5536 EXPECT_EQ(OK, callback3.WaitForResult());
5531 5537
5532 helper.VerifyDataConsumed(); 5538 helper.VerifyDataConsumed();
5533 } 5539 }
5534 5540
5535 } // namespace net 5541 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_test_util.cc ('k') | net/spdy/spdy_network_transaction_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698