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

Side by Side Diff: net/quic/quic_reliable_client_stream_test.cc

Issue 23597045: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged QuicPriority to RequestPriority changes Created 7 years, 3 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/quic/quic_reliable_client_stream.cc ('k') | net/quic/quic_session.h » ('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/quic/quic_reliable_client_stream.h" 5 #include "net/quic/quic_reliable_client_stream.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/base/test_completion_callback.h" 8 #include "net/base/test_completion_callback.h"
9 #include "net/quic/quic_client_session.h" 9 #include "net/quic/quic_client_session.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
(...skipping 10 matching lines...) Expand all
21 21
22 class MockDelegate : public QuicReliableClientStream::Delegate { 22 class MockDelegate : public QuicReliableClientStream::Delegate {
23 public: 23 public:
24 MockDelegate() {} 24 MockDelegate() {}
25 25
26 MOCK_METHOD0(OnSendData, int()); 26 MOCK_METHOD0(OnSendData, int());
27 MOCK_METHOD2(OnSendDataComplete, int(int, bool*)); 27 MOCK_METHOD2(OnSendDataComplete, int(int, bool*));
28 MOCK_METHOD2(OnDataReceived, int(const char*, int)); 28 MOCK_METHOD2(OnDataReceived, int(const char*, int));
29 MOCK_METHOD1(OnClose, void(QuicErrorCode)); 29 MOCK_METHOD1(OnClose, void(QuicErrorCode));
30 MOCK_METHOD1(OnError, void(int)); 30 MOCK_METHOD1(OnError, void(int));
31 MOCK_METHOD0(HasSendHeadersComplete, bool());
31 32
32 private: 33 private:
33 DISALLOW_COPY_AND_ASSIGN(MockDelegate); 34 DISALLOW_COPY_AND_ASSIGN(MockDelegate);
34 }; 35 };
35 36
36 class QuicReliableClientStreamTest : public ::testing::Test { 37 class QuicReliableClientStreamTest : public ::testing::Test {
37 public: 38 public:
38 QuicReliableClientStreamTest() 39 QuicReliableClientStreamTest()
39 : session_(new MockConnection(1, IPEndPoint(), false), false), 40 : session_(new MockConnection(1, IPEndPoint(), false), false),
40 stream_(1, &session_, BoundNetLog()) { 41 stream_(1, &session_, BoundNetLog()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 EXPECT_FALSE(stream_.GetDelegate()); 80 EXPECT_FALSE(stream_.GetDelegate());
80 } 81 }
81 82
82 TEST_F(QuicReliableClientStreamTest, WriteStreamData) { 83 TEST_F(QuicReliableClientStreamTest, WriteStreamData) {
83 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)); 84 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
84 85
85 const char kData1[] = "hello world"; 86 const char kData1[] = "hello world";
86 const size_t kDataLen = arraysize(kData1); 87 const size_t kDataLen = arraysize(kData1);
87 88
88 // All data written. 89 // All data written.
89 EXPECT_CALL(session_, WriteData(stream_.id(), _, _, _)).WillOnce( 90 EXPECT_CALL(session_, WritevData(stream_.id(), _, _, _, _)).WillOnce(
90 Return(QuicConsumedData(kDataLen, true))); 91 Return(QuicConsumedData(kDataLen, true)));
91 TestCompletionCallback callback; 92 TestCompletionCallback callback;
92 EXPECT_EQ(OK, stream_.WriteStreamData(base::StringPiece(kData1, kDataLen), 93 EXPECT_EQ(OK, stream_.WriteStreamData(base::StringPiece(kData1, kDataLen),
93 true, callback.callback())); 94 true, callback.callback()));
94 } 95 }
95 96
96 TEST_F(QuicReliableClientStreamTest, WriteStreamDataAsync) { 97 TEST_F(QuicReliableClientStreamTest, WriteStreamDataAsync) {
98 EXPECT_CALL(delegate_, HasSendHeadersComplete());
97 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)); 99 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
98 100
99 const char kData1[] = "hello world"; 101 const char kData1[] = "hello world";
100 const size_t kDataLen = arraysize(kData1); 102 const size_t kDataLen = arraysize(kData1);
101 103
102 // No data written. 104 // No data written.
103 EXPECT_CALL(session_, WriteData(stream_.id(), _, _, _)).WillOnce( 105 EXPECT_CALL(session_, WritevData(stream_.id(), _, _, _, _)).WillOnce(
104 Return(QuicConsumedData(0, false))); 106 Return(QuicConsumedData(0, false)));
105 TestCompletionCallback callback; 107 TestCompletionCallback callback;
106 EXPECT_EQ(ERR_IO_PENDING, 108 EXPECT_EQ(ERR_IO_PENDING,
107 stream_.WriteStreamData(base::StringPiece(kData1, kDataLen), 109 stream_.WriteStreamData(base::StringPiece(kData1, kDataLen),
108 true, callback.callback())); 110 true, callback.callback()));
109 ASSERT_FALSE(callback.have_result()); 111 ASSERT_FALSE(callback.have_result());
110 112
111 // All data written. 113 // All data written.
112 EXPECT_CALL(session_, WriteData(stream_.id(), _, _, _)).WillOnce( 114 EXPECT_CALL(session_, WritevData(stream_.id(), _, _, _, _)).WillOnce(
113 Return(QuicConsumedData(kDataLen, true))); 115 Return(QuicConsumedData(kDataLen, true)));
114 stream_.OnCanWrite(); 116 stream_.OnCanWrite();
115 ASSERT_TRUE(callback.have_result()); 117 ASSERT_TRUE(callback.have_result());
116 EXPECT_EQ(OK, callback.WaitForResult()); 118 EXPECT_EQ(OK, callback.WaitForResult());
117 } 119 }
118 120
119 } // namespace 121 } // namespace
120 } // namespace test 122 } // namespace test
121 } // namespace net 123 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_reliable_client_stream.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698