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

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

Issue 10689034: SPDY - chunked upload - speech recognition doesn't work with SPDY/3 (Closed) Base URL: svn://chrome-svn/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 29 matching lines...) Expand all
40 protected: 40 protected:
41 41
42 virtual void SetUp() { 42 virtual void SetUp() {
43 SpdySession::set_default_protocol(kProtoSPDY3); 43 SpdySession::set_default_protocol(kProtoSPDY3);
44 google_get_request_initialized_ = false; 44 google_get_request_initialized_ = false;
45 google_post_request_initialized_ = false; 45 google_post_request_initialized_ = false;
46 google_chunked_post_request_initialized_ = false; 46 google_chunked_post_request_initialized_ = false;
47 } 47 }
48 48
49 virtual void TearDown() { 49 virtual void TearDown() {
50 UploadDataStream::ResetMergeChunks();
50 // Empty the current queue. 51 // Empty the current queue.
51 MessageLoop::current()->RunAllPending(); 52 MessageLoop::current()->RunAllPending();
52 } 53 }
53 54
55 void set_merge_chunks(bool merge) {
56 UploadDataStream::set_merge_chunks(merge);
57 }
58
54 struct TransactionHelperResult { 59 struct TransactionHelperResult {
55 int rv; 60 int rv;
56 std::string status_line; 61 std::string status_line;
57 std::string response_data; 62 std::string response_data;
58 HttpResponseInfo response_info; 63 HttpResponseInfo response_info;
59 }; 64 };
60 65
61 // A helper class that handles all the initial npn/ssl setup. 66 // A helper class that handles all the initial npn/ssl setup.
62 class NormalSpdyTransactionHelper { 67 class NormalSpdyTransactionHelper {
63 public: 68 public:
(...skipping 14 matching lines...) Expand all
78 case SPDYNOSSL: 83 case SPDYNOSSL:
79 case SPDYSSL: 84 case SPDYSSL:
80 port_ = 80; 85 port_ = 80;
81 break; 86 break;
82 case SPDYNPN: 87 case SPDYNPN:
83 port_ = 443; 88 port_ = 443;
84 break; 89 break;
85 default: 90 default:
86 NOTREACHED(); 91 NOTREACHED();
87 } 92 }
88 } 93 }
89
90 94
91 ~NormalSpdyTransactionHelper() { 95 ~NormalSpdyTransactionHelper() {
92 // Any test which doesn't close the socket by sending it an EOF will 96 // Any test which doesn't close the socket by sending it an EOF will
93 // have a valid session left open, which leaks the entire session pool. 97 // have a valid session left open, which leaks the entire session pool.
94 // This is just fine - in fact, some of our tests intentionally do this 98 // This is just fine - in fact, some of our tests intentionally do this
95 // so that we can check consistency of the SpdySessionPool as the test 99 // so that we can check consistency of the SpdySessionPool as the test
96 // finishes. If we had put an EOF on the socket, the SpdySession would 100 // finishes. If we had put an EOF on the socket, the SpdySession would
97 // have closed and we wouldn't be able to check the consistency. 101 // have closed and we wouldn't be able to check the consistency.
98 102
99 // Forcefully close existing sessions here. 103 // Forcefully close existing sessions here.
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 BoundNetLog(), GetParam(), NULL); 1592 BoundNetLog(), GetParam(), NULL);
1589 helper.RunToCompletion(data.get()); 1593 helper.RunToCompletion(data.get());
1590 TransactionHelperResult out = helper.output(); 1594 TransactionHelperResult out = helper.output();
1591 EXPECT_EQ(OK, out.rv); 1595 EXPECT_EQ(OK, out.rv);
1592 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1596 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1593 EXPECT_EQ("hello!", out.response_data); 1597 EXPECT_EQ("hello!", out.response_data);
1594 } 1598 }
1595 1599
1596 // Test that a chunked POST works. 1600 // Test that a chunked POST works.
1597 TEST_P(SpdyNetworkTransactionSpdy3Test, ChunkedPost) { 1601 TEST_P(SpdyNetworkTransactionSpdy3Test, ChunkedPost) {
1598 UploadDataStream::set_merge_chunks(false); 1602 // Disable merging of chunks until we have a better way to unit test POST
1603 // requests with chunked uploads.
1604 set_merge_chunks(false);
1605
1599 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 1606 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
1600 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); 1607 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
1601 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); 1608 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
1602 MockWrite writes[] = { 1609 MockWrite writes[] = {
1603 CreateMockWrite(*req), 1610 CreateMockWrite(*req),
1604 CreateMockWrite(*chunk1), 1611 CreateMockWrite(*chunk1),
1605 CreateMockWrite(*chunk2), 1612 CreateMockWrite(*chunk2),
1606 }; 1613 };
1607 1614
1608 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); 1615 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 }; 2062 };
2056 2063
2057 static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow 2064 static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow
2058 scoped_ptr<SpdyFrame> window_update( 2065 scoped_ptr<SpdyFrame> window_update(
2059 ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); 2066 ConstructSpdyWindowUpdate(1, kDeltaWindowSize));
2060 scoped_ptr<SpdyFrame> window_update2( 2067 scoped_ptr<SpdyFrame> window_update2(
2061 ConstructSpdyWindowUpdate(2, kDeltaWindowSize)); 2068 ConstructSpdyWindowUpdate(2, kDeltaWindowSize));
2062 scoped_ptr<SpdyFrame> reply(ConstructSpdyPostSynReply(NULL, 0)); 2069 scoped_ptr<SpdyFrame> reply(ConstructSpdyPostSynReply(NULL, 0));
2063 2070
2064 MockRead reads[] = { 2071 MockRead reads[] = {
2072 CreateMockRead(*reply),
Ryan Hamilton 2012/07/11 17:11:19 Why is this change required? Since the test used
ramant (doing other things) 2012/07/11 19:40:43 As we have discussed, re-implemented this test usi
2073 CreateMockRead(*window_update2),
2065 CreateMockRead(*window_update2), 2074 CreateMockRead(*window_update2),
2066 CreateMockRead(*window_update2), 2075 CreateMockRead(*window_update2),
2067 CreateMockRead(*window_update), 2076 CreateMockRead(*window_update),
2068 CreateMockRead(*window_update), 2077 CreateMockRead(*window_update),
2069 CreateMockRead(*window_update), 2078 CreateMockRead(*window_update),
2070 MockRead(ASYNC, ERR_IO_PENDING, 0), // Wait for the RST to be written. 2079 MockRead(ASYNC, ERR_IO_PENDING, 0), // Wait for the RST to be written.
2071 MockRead(ASYNC, 0, 0) // EOF 2080 MockRead(ASYNC, 0, 0) // EOF
2072 }; 2081 };
2073 2082
2074 scoped_ptr<DelayedSocketData> data( 2083 scoped_ptr<DelayedSocketData> data(
(...skipping 4132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6207 // And now we can allow everything else to run to completion. 6216 // And now we can allow everything else to run to completion.
6208 data->SetStop(10); 6217 data->SetStop(10);
6209 data->Run(); 6218 data->Run();
6210 EXPECT_EQ(OK, callback2.WaitForResult()); 6219 EXPECT_EQ(OK, callback2.WaitForResult());
6211 EXPECT_EQ(OK, callback3.WaitForResult()); 6220 EXPECT_EQ(OK, callback3.WaitForResult());
6212 6221
6213 helper.VerifyDataConsumed(); 6222 helper.VerifyDataConsumed();
6214 } 6223 }
6215 6224
6216 } // namespace net 6225 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698