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

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 23 matching lines...) Expand all
34 SPDYNOSSL, 34 SPDYNOSSL,
35 SPDYSSL, 35 SPDYSSL,
36 }; 36 };
37 37
38 class SpdyNetworkTransactionSpdy3Test 38 class SpdyNetworkTransactionSpdy3Test
39 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy3TestTypes> { 39 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy3TestTypes> {
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 merge_chunks_ = UploadDataStream::merge_chunks();
44 google_get_request_initialized_ = false; 45 google_get_request_initialized_ = false;
45 google_post_request_initialized_ = false; 46 google_post_request_initialized_ = false;
46 google_chunked_post_request_initialized_ = false; 47 google_chunked_post_request_initialized_ = false;
47 } 48 }
48 49
49 virtual void TearDown() { 50 virtual void TearDown() {
51 UploadDataStream::set_merge_chunks(merge_chunks_);
50 // Empty the current queue. 52 // Empty the current queue.
51 MessageLoop::current()->RunAllPending(); 53 MessageLoop::current()->RunAllPending();
52 } 54 }
53 55
56 void set_merge_chunks(bool merge) {
57 UploadDataStream::set_merge_chunks(merge);
58 }
59
54 struct TransactionHelperResult { 60 struct TransactionHelperResult {
55 int rv; 61 int rv;
56 std::string status_line; 62 std::string status_line;
57 std::string response_data; 63 std::string response_data;
58 HttpResponseInfo response_info; 64 HttpResponseInfo response_info;
59 }; 65 };
60 66
61 // A helper class that handles all the initial npn/ssl setup. 67 // A helper class that handles all the initial npn/ssl setup.
62 class NormalSpdyTransactionHelper { 68 class NormalSpdyTransactionHelper {
63 public: 69 public:
(...skipping 14 matching lines...) Expand all
78 case SPDYNOSSL: 84 case SPDYNOSSL:
79 case SPDYSSL: 85 case SPDYSSL:
80 port_ = 80; 86 port_ = 80;
81 break; 87 break;
82 case SPDYNPN: 88 case SPDYNPN:
83 port_ = 443; 89 port_ = 443;
84 break; 90 break;
85 default: 91 default:
86 NOTREACHED(); 92 NOTREACHED();
87 } 93 }
88 } 94 }
89
90 95
91 ~NormalSpdyTransactionHelper() { 96 ~NormalSpdyTransactionHelper() {
92 // Any test which doesn't close the socket by sending it an EOF will 97 // 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. 98 // 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 99 // 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 100 // 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 101 // 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. 102 // have closed and we wouldn't be able to check the consistency.
98 103
99 // Forcefully close existing sessions here. 104 // Forcefully close existing sessions here.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 526
522 private: 527 private:
523 bool google_get_request_initialized_; 528 bool google_get_request_initialized_;
524 bool google_post_request_initialized_; 529 bool google_post_request_initialized_;
525 bool google_chunked_post_request_initialized_; 530 bool google_chunked_post_request_initialized_;
526 HttpRequestInfo google_get_request_; 531 HttpRequestInfo google_get_request_;
527 HttpRequestInfo google_post_request_; 532 HttpRequestInfo google_post_request_;
528 HttpRequestInfo google_chunked_post_request_; 533 HttpRequestInfo google_chunked_post_request_;
529 HttpRequestInfo google_get_push_request_; 534 HttpRequestInfo google_get_push_request_;
530 SpdyTestStateHelper spdy_state_; 535 SpdyTestStateHelper spdy_state_;
536 bool merge_chunks_;
531 }; 537 };
532 538
533 //----------------------------------------------------------------------------- 539 //-----------------------------------------------------------------------------
534 // All tests are run with three different connection types: SPDY after NPN 540 // All tests are run with three different connection types: SPDY after NPN
535 // negotiation, SPDY without SSL, and SPDY with SSL. 541 // negotiation, SPDY without SSL, and SPDY with SSL.
536 INSTANTIATE_TEST_CASE_P(Spdy, 542 INSTANTIATE_TEST_CASE_P(Spdy,
537 SpdyNetworkTransactionSpdy3Test, 543 SpdyNetworkTransactionSpdy3Test,
538 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); 544 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN));
539 545
540 546
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 BoundNetLog(), GetParam(), NULL); 1607 BoundNetLog(), GetParam(), NULL);
1602 helper.RunToCompletion(data.get()); 1608 helper.RunToCompletion(data.get());
1603 TransactionHelperResult out = helper.output(); 1609 TransactionHelperResult out = helper.output();
1604 EXPECT_EQ(OK, out.rv); 1610 EXPECT_EQ(OK, out.rv);
1605 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1611 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1606 EXPECT_EQ("hello!", out.response_data); 1612 EXPECT_EQ("hello!", out.response_data);
1607 } 1613 }
1608 1614
1609 // Test that a chunked POST works. 1615 // Test that a chunked POST works.
1610 TEST_P(SpdyNetworkTransactionSpdy3Test, ChunkedPost) { 1616 TEST_P(SpdyNetworkTransactionSpdy3Test, ChunkedPost) {
1611 UploadDataStream::set_merge_chunks(false); 1617 // TODO(satish): Remove this once we have a better way to unit test POST
Ryan Hamilton 2012/07/09 17:52:02 satish?
ramant (doing other things) 2012/07/11 01:36:18 Done.
1618 // requests with chunked uploads.
1619 set_merge_chunks(false);
1612 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 1620 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
1613 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); 1621 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
1614 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); 1622 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
1615 MockWrite writes[] = { 1623 MockWrite writes[] = {
1616 CreateMockWrite(*req), 1624 CreateMockWrite(*req),
1617 CreateMockWrite(*chunk1), 1625 CreateMockWrite(*chunk1),
1618 CreateMockWrite(*chunk2), 1626 CreateMockWrite(*chunk2),
1619 }; 1627 };
1620 1628
1621 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); 1629 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
(...skipping 4602 matching lines...) Expand 10 before | Expand all | Expand 10 after
6224 // And now we can allow everything else to run to completion. 6232 // And now we can allow everything else to run to completion.
6225 data->SetStop(10); 6233 data->SetStop(10);
6226 data->Run(); 6234 data->Run();
6227 EXPECT_EQ(OK, callback2.WaitForResult()); 6235 EXPECT_EQ(OK, callback2.WaitForResult());
6228 EXPECT_EQ(OK, callback3.WaitForResult()); 6236 EXPECT_EQ(OK, callback3.WaitForResult());
6229 6237
6230 helper.VerifyDataConsumed(); 6238 helper.VerifyDataConsumed();
6231 } 6239 }
6232 6240
6233 } // namespace net 6241 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698