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

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: 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 4957 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 4968
4969 scoped_ptr<SpdyFrame> 4969 scoped_ptr<SpdyFrame>
4970 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 4970 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
4971 MockRead reads[] = { 4971 MockRead reads[] = {
4972 CreateMockRead(*stream1_reply, 1), 4972 CreateMockRead(*stream1_reply, 1),
4973 CreateMockRead(*stream2_syn, 2), 4973 CreateMockRead(*stream2_syn, 2),
4974 CreateMockRead(*stream1_body, 3), 4974 CreateMockRead(*stream1_body, 3),
4975 CreateMockRead(*stream2_headers, 4), 4975 CreateMockRead(*stream2_headers, 4),
4976 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 4976 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
4977 arraysize(kPushBodyFrame), 5), 4977 arraysize(kPushBodyFrame), 5),
4978 MockRead(ASYNC, 0, 5), // EOF 4978 MockRead(ASYNC, 0, 6), // EOF
4979 }; 4979 };
4980 4980
4981 HttpResponseInfo response; 4981 HttpResponseInfo response;
4982 HttpResponseInfo response2; 4982 HttpResponseInfo response2;
4983 std::string expected_push_result("pushed"); 4983 std::string expected_push_result("pushed");
4984 scoped_ptr<DeterministicSocketData> data( 4984 scoped_ptr<DeterministicSocketData> data(
4985 new DeterministicSocketData(reads, arraysize(reads), 4985 new DeterministicSocketData(reads, arraysize(reads),
4986 writes, arraysize(writes))); 4986 writes, arraysize(writes)));
4987 4987
4988 NormalSpdyTransactionHelper helper(CreateGetRequest(), 4988 NormalSpdyTransactionHelper helper(CreateGetRequest(),
(...skipping 28 matching lines...) Expand all
5017 data->RunFor(3); 5017 data->RunFor(3);
5018 MessageLoop::current()->RunAllPending(); 5018 MessageLoop::current()->RunAllPending();
5019 5019
5020 // Read the server push body. 5020 // Read the server push body.
5021 std::string result2; 5021 std::string result2;
5022 ReadResult(trans2.get(), data.get(), &result2); 5022 ReadResult(trans2.get(), data.get(), &result2);
5023 // Read the response body. 5023 // Read the response body.
5024 std::string result; 5024 std::string result;
5025 ReadResult(trans, data.get(), &result); 5025 ReadResult(trans, data.get(), &result);
5026 5026
5027 // Verify that we consumed all test data.
5028 EXPECT_TRUE(data->at_read_eof());
5029 EXPECT_TRUE(data->at_write_eof());
5030
5031 // Verify that the received push data is same as the expected push data. 5027 // Verify that the received push data is same as the expected push data.
5032 EXPECT_EQ(result2.compare(expected_push_result), 0) 5028 EXPECT_EQ(result2.compare(expected_push_result), 0)
5033 << "Received data: " 5029 << "Received data: "
5034 << result2 5030 << result2
5035 << "||||| Expected data: " 5031 << "||||| Expected data: "
5036 << expected_push_result; 5032 << expected_push_result;
5037 5033
5038 // Verify the SYN_REPLY. 5034 // Verify the SYN_REPLY.
5039 // Copy the response info, because trans goes away. 5035 // Copy the response info, because trans goes away.
5040 response = *trans->GetResponseInfo(); 5036 response = *trans->GetResponseInfo();
5041 response2 = *trans2->GetResponseInfo(); 5037 response2 = *trans2->GetResponseInfo();
5042 5038
5039 LOG(INFO) << "Here";
5043 VerifyStreamsClosed(helper); 5040 VerifyStreamsClosed(helper);
5041 LOG(INFO) << "Here";
Ryan Sleevi 2012/07/18 18:02:13 unnecessary?
Ryan Hamilton 2012/07/18 18:45:06 Done.
5044 5042
5045 // Verify the SYN_REPLY. 5043 // Verify the SYN_REPLY.
5046 EXPECT_TRUE(response.headers != NULL); 5044 EXPECT_TRUE(response.headers != NULL);
5047 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5045 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5048 5046
5049 // Verify the pushed stream. 5047 // Verify the pushed stream.
5050 EXPECT_TRUE(response2.headers != NULL); 5048 EXPECT_TRUE(response2.headers != NULL);
5051 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5049 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5050
5051 // Read the final EOF (which will close the session)
5052 data->RunFor(1);
5053
5054 // Verify that we consumed all test data.
5055 EXPECT_TRUE(data->at_read_eof());
5056 EXPECT_TRUE(data->at_write_eof());
5052 } 5057 }
5053 5058
5054 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithTwoHeaderFrames) { 5059 TEST_P(SpdyNetworkTransactionSpdy2Test, ServerPushWithTwoHeaderFrames) {
5055 // We push a stream and attempt to claim it before the headers come down. 5060 // We push a stream and attempt to claim it before the headers come down.
5056 static const unsigned char kPushBodyFrame[] = { 5061 static const unsigned char kPushBodyFrame[] = {
5057 0x00, 0x00, 0x00, 0x02, // header, ID 5062 0x00, 0x00, 0x00, 0x02, // header, ID
5058 0x01, 0x00, 0x00, 0x06, // FIN, length 5063 0x01, 0x00, 0x00, 0x06, // FIN, length
5059 'p', 'u', 's', 'h', 'e', 'd' // "pushed" 5064 'p', 'u', 's', 'h', 'e', 'd' // "pushed"
5060 }; 5065 };
5061 scoped_ptr<SpdyFrame> 5066 scoped_ptr<SpdyFrame>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5117 scoped_ptr<SpdyFrame> 5122 scoped_ptr<SpdyFrame>
5118 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1)); 5123 stream1_reply(ConstructSpdyGetSynReply(NULL, 0, 1));
5119 MockRead reads[] = { 5124 MockRead reads[] = {
5120 CreateMockRead(*stream1_reply, 1), 5125 CreateMockRead(*stream1_reply, 1),
5121 CreateMockRead(*stream2_syn, 2), 5126 CreateMockRead(*stream2_syn, 2),
5122 CreateMockRead(*stream1_body, 3), 5127 CreateMockRead(*stream1_body, 3),
5123 CreateMockRead(*stream2_headers1, 4), 5128 CreateMockRead(*stream2_headers1, 4),
5124 CreateMockRead(*stream2_headers2, 5), 5129 CreateMockRead(*stream2_headers2, 5),
5125 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), 5130 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame),
5126 arraysize(kPushBodyFrame), 6), 5131 arraysize(kPushBodyFrame), 6),
5127 MockRead(ASYNC, 0, 6), // EOF 5132 MockRead(ASYNC, 0, 7), // EOF
5128 }; 5133 };
5129 5134
5130 HttpResponseInfo response; 5135 HttpResponseInfo response;
5131 HttpResponseInfo response2; 5136 HttpResponseInfo response2;
5132 std::string expected_push_result("pushed"); 5137 std::string expected_push_result("pushed");
5133 scoped_ptr<DeterministicSocketData> data( 5138 scoped_ptr<DeterministicSocketData> data(
5134 new DeterministicSocketData(reads, arraysize(reads), 5139 new DeterministicSocketData(reads, arraysize(reads),
5135 writes, arraysize(writes))); 5140 writes, arraysize(writes)));
5136 5141
5137 NormalSpdyTransactionHelper helper(CreateGetRequest(), 5142 NormalSpdyTransactionHelper helper(CreateGetRequest(),
(...skipping 28 matching lines...) Expand all
5166 data->RunFor(3); 5171 data->RunFor(3);
5167 MessageLoop::current()->RunAllPending(); 5172 MessageLoop::current()->RunAllPending();
5168 5173
5169 // Read the server push body. 5174 // Read the server push body.
5170 std::string result2; 5175 std::string result2;
5171 ReadResult(trans2.get(), data.get(), &result2); 5176 ReadResult(trans2.get(), data.get(), &result2);
5172 // Read the response body. 5177 // Read the response body.
5173 std::string result; 5178 std::string result;
5174 ReadResult(trans, data.get(), &result); 5179 ReadResult(trans, data.get(), &result);
5175 5180
5176 // Verify that we consumed all test data.
5177 EXPECT_TRUE(data->at_read_eof());
5178 EXPECT_TRUE(data->at_write_eof());
5179
5180 // Verify that the received push data is same as the expected push data. 5181 // Verify that the received push data is same as the expected push data.
5181 EXPECT_EQ(result2.compare(expected_push_result), 0) 5182 EXPECT_EQ(result2.compare(expected_push_result), 0)
5182 << "Received data: " 5183 << "Received data: "
5183 << result2 5184 << result2
5184 << "||||| Expected data: " 5185 << "||||| Expected data: "
5185 << expected_push_result; 5186 << expected_push_result;
5186 5187
5187 // Verify the SYN_REPLY. 5188 // Verify the SYN_REPLY.
5188 // Copy the response info, because trans goes away. 5189 // Copy the response info, because trans goes away.
5189 response = *trans->GetResponseInfo(); 5190 response = *trans->GetResponseInfo();
5190 response2 = *trans2->GetResponseInfo(); 5191 response2 = *trans2->GetResponseInfo();
5191 5192
5192 VerifyStreamsClosed(helper); 5193 VerifyStreamsClosed(helper);
5193 5194
5194 // Verify the SYN_REPLY. 5195 // Verify the SYN_REPLY.
5195 EXPECT_TRUE(response.headers != NULL); 5196 EXPECT_TRUE(response.headers != NULL);
5196 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine()); 5197 EXPECT_EQ("HTTP/1.1 200 OK", response.headers->GetStatusLine());
5197 5198
5198 // Verify the pushed stream. 5199 // Verify the pushed stream.
5199 EXPECT_TRUE(response2.headers != NULL); 5200 EXPECT_TRUE(response2.headers != NULL);
5200 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); 5201 EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine());
5201 5202
5202 // Verify we got all the headers 5203 // Verify we got all the headers
5203 EXPECT_TRUE(response2.headers->HasHeaderValue( 5204 EXPECT_TRUE(response2.headers->HasHeaderValue(
5204 "url", 5205 "url",
5205 "http://www.google.com/foo.dat")); 5206 "http://www.google.com/foo.dat"));
5206 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye")); 5207 EXPECT_TRUE(response2.headers->HasHeaderValue("hello", "bye"));
5207 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200")); 5208 EXPECT_TRUE(response2.headers->HasHeaderValue("status", "200"));
5208 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1")); 5209 EXPECT_TRUE(response2.headers->HasHeaderValue("version", "HTTP/1.1"));
5210
5211 // Read the final EOF (which will close the session)
5212 data->RunFor(1);
5213
5214 // Verify that we consumed all test data.
5215 EXPECT_TRUE(data->at_read_eof());
5216 EXPECT_TRUE(data->at_write_eof());
5209 } 5217 }
5210 5218
5211 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithHeaders) { 5219 TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyWithHeaders) {
5212 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); 5220 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST));
5213 MockWrite writes[] = { CreateMockWrite(*req) }; 5221 MockWrite writes[] = { CreateMockWrite(*req) };
5214 5222
5215 static const char* const kInitialHeaders[] = { 5223 static const char* const kInitialHeaders[] = {
5216 "status", 5224 "status",
5217 "200 OK", 5225 "200 OK",
5218 "version", 5226 "version",
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
5632 // And now we can allow everything else to run to completion. 5640 // And now we can allow everything else to run to completion.
5633 data->SetStop(10); 5641 data->SetStop(10);
5634 data->Run(); 5642 data->Run();
5635 EXPECT_EQ(OK, callback2.WaitForResult()); 5643 EXPECT_EQ(OK, callback2.WaitForResult());
5636 EXPECT_EQ(OK, callback3.WaitForResult()); 5644 EXPECT_EQ(OK, callback3.WaitForResult());
5637 5645
5638 helper.VerifyDataConsumed(); 5646 helper.VerifyDataConsumed();
5639 } 5647 }
5640 5648
5641 } // namespace net 5649 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698