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

Side by Side Diff: net/spdy/spdy_network_transaction_spdy2_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 16 matching lines...) Expand all
27 27
28 //----------------------------------------------------------------------------- 28 //-----------------------------------------------------------------------------
29 29
30 namespace net { 30 namespace net {
31 31
32 enum SpdyNetworkTransactionSpdy2TestTypes { 32 enum SpdyNetworkTransactionSpdy2TestTypes {
33 SPDYNPN, 33 SPDYNPN,
34 SPDYNOSSL, 34 SPDYNOSSL,
35 SPDYSSL, 35 SPDYSSL,
36 }; 36 };
37
37 class SpdyNetworkTransactionSpdy2Test 38 class SpdyNetworkTransactionSpdy2Test
38 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> { 39 : public ::testing::TestWithParam<SpdyNetworkTransactionSpdy2TestTypes> {
39 protected: 40 protected:
40 41
41 virtual void SetUp() { 42 virtual void SetUp() {
42 SpdySession::set_default_protocol(kProtoSPDY2); 43 SpdySession::set_default_protocol(kProtoSPDY2);
44 merge_chunks_ = UploadDataStream::merge_chunks();
43 google_get_request_initialized_ = false; 45 google_get_request_initialized_ = false;
44 google_post_request_initialized_ = false; 46 google_post_request_initialized_ = false;
45 google_chunked_post_request_initialized_ = false; 47 google_chunked_post_request_initialized_ = false;
46 } 48 }
47 49
48 virtual void TearDown() { 50 virtual void TearDown() {
51 UploadDataStream::set_merge_chunks(merge_chunks_);
49 // Empty the current queue. 52 // Empty the current queue.
50 MessageLoop::current()->RunAllPending(); 53 MessageLoop::current()->RunAllPending();
51 } 54 }
52 55
56 void set_merge_chunks(bool merge) {
57 UploadDataStream::set_merge_chunks(merge);
58 }
59
53 struct TransactionHelperResult { 60 struct TransactionHelperResult {
54 int rv; 61 int rv;
55 std::string status_line; 62 std::string status_line;
56 std::string response_data; 63 std::string response_data;
57 HttpResponseInfo response_info; 64 HttpResponseInfo response_info;
58 }; 65 };
59 66
60 // A helper class that handles all the initial npn/ssl setup. 67 // A helper class that handles all the initial npn/ssl setup.
61 class NormalSpdyTransactionHelper { 68 class NormalSpdyTransactionHelper {
62 public: 69 public:
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 525
519 private: 526 private:
520 bool google_get_request_initialized_; 527 bool google_get_request_initialized_;
521 bool google_post_request_initialized_; 528 bool google_post_request_initialized_;
522 bool google_chunked_post_request_initialized_; 529 bool google_chunked_post_request_initialized_;
523 HttpRequestInfo google_get_request_; 530 HttpRequestInfo google_get_request_;
524 HttpRequestInfo google_post_request_; 531 HttpRequestInfo google_post_request_;
525 HttpRequestInfo google_chunked_post_request_; 532 HttpRequestInfo google_chunked_post_request_;
526 HttpRequestInfo google_get_push_request_; 533 HttpRequestInfo google_get_push_request_;
527 SpdyTestStateHelper spdy_state_; 534 SpdyTestStateHelper spdy_state_;
535 bool merge_chunks_;
528 }; 536 };
529 537
530 //----------------------------------------------------------------------------- 538 //-----------------------------------------------------------------------------
531 // All tests are run with three different connection types: SPDY after NPN 539 // All tests are run with three different connection types: SPDY after NPN
532 // negotiation, SPDY without SSL, and SPDY with SSL. 540 // negotiation, SPDY without SSL, and SPDY with SSL.
533 INSTANTIATE_TEST_CASE_P(Spdy, 541 INSTANTIATE_TEST_CASE_P(Spdy,
534 SpdyNetworkTransactionSpdy2Test, 542 SpdyNetworkTransactionSpdy2Test,
535 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN)); 543 ::testing::Values(SPDYNOSSL, SPDYSSL, SPDYNPN));
536 544
537 545
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 BoundNetLog(), GetParam(), NULL); 1600 BoundNetLog(), GetParam(), NULL);
1593 helper.RunToCompletion(data.get()); 1601 helper.RunToCompletion(data.get());
1594 TransactionHelperResult out = helper.output(); 1602 TransactionHelperResult out = helper.output();
1595 EXPECT_EQ(OK, out.rv); 1603 EXPECT_EQ(OK, out.rv);
1596 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 1604 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
1597 EXPECT_EQ("hello!", out.response_data); 1605 EXPECT_EQ("hello!", out.response_data);
1598 } 1606 }
1599 1607
1600 // Test that a chunked POST works. 1608 // Test that a chunked POST works.
1601 TEST_P(SpdyNetworkTransactionSpdy2Test, ChunkedPost) { 1609 TEST_P(SpdyNetworkTransactionSpdy2Test, ChunkedPost) {
1602 UploadDataStream::set_merge_chunks(false); 1610 // 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.
1611 // requests with chunked uploads.
1612 set_merge_chunks(false);
1603 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); 1613 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0));
1604 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); 1614 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false));
1605 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); 1615 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true));
1606 MockWrite writes[] = { 1616 MockWrite writes[] = {
1607 CreateMockWrite(*req), 1617 CreateMockWrite(*req),
1608 CreateMockWrite(*chunk1), 1618 CreateMockWrite(*chunk1),
1609 CreateMockWrite(*chunk2), 1619 CreateMockWrite(*chunk2),
1610 }; 1620 };
1611 1621
1612 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); 1622 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0));
(...skipping 4028 matching lines...) Expand 10 before | Expand all | Expand 10 after
5641 // And now we can allow everything else to run to completion. 5651 // And now we can allow everything else to run to completion.
5642 data->SetStop(10); 5652 data->SetStop(10);
5643 data->Run(); 5653 data->Run();
5644 EXPECT_EQ(OK, callback2.WaitForResult()); 5654 EXPECT_EQ(OK, callback2.WaitForResult());
5645 EXPECT_EQ(OK, callback3.WaitForResult()); 5655 EXPECT_EQ(OK, callback3.WaitForResult());
5646 5656
5647 helper.VerifyDataConsumed(); 5657 helper.VerifyDataConsumed();
5648 } 5658 }
5649 5659
5650 } // namespace net 5660 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698