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

Side by Side Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 1190823003: Remove dependency on headers stream from QuicSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0616
Patch Set: deleted an include Created 5 years, 6 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
« no previous file with comments | « net/tools/quic/quic_client_session_test.cc ('k') | net/tools/quic/quic_server_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/tools/quic/quic_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 11 matching lines...) Expand all
22 #include "net/tools/quic/quic_time_wait_list_manager.h" 22 #include "net/tools/quic/quic_time_wait_list_manager.h"
23 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" 23 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
24 #include "net/tools/quic/test_tools/quic_test_utils.h" 24 #include "net/tools/quic/test_tools/quic_test_utils.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 using base::StringPiece; 28 using base::StringPiece;
29 using net::EpollServer; 29 using net::EpollServer;
30 using net::test::ConstructEncryptedPacket; 30 using net::test::ConstructEncryptedPacket;
31 using net::test::MockConnection; 31 using net::test::MockConnection;
32 using net::test::MockSession;
33 using net::test::ValueRestore; 32 using net::test::ValueRestore;
34 using std::string; 33 using std::string;
35 using std::vector; 34 using std::vector;
36 using testing::DoAll; 35 using testing::DoAll;
37 using testing::InSequence; 36 using testing::InSequence;
38 using testing::Invoke; 37 using testing::Invoke;
39 using testing::WithoutArgs; 38 using testing::WithoutArgs;
40 using testing::_; 39 using testing::_;
41 40
42 namespace net { 41 namespace net {
43 namespace tools { 42 namespace tools {
44 namespace test { 43 namespace test {
45 namespace { 44 namespace {
46 45
47 class TestServerSession : public QuicServerSession { 46 class TestQuicSpdyServerSession : public QuicServerSession {
48 public: 47 public:
49 TestServerSession(const QuicConfig& config, 48 TestQuicSpdyServerSession(const QuicConfig& config,
50 QuicConnection* connection, 49 QuicConnection* connection,
51 const QuicCryptoServerConfig* crypto_config) 50 const QuicCryptoServerConfig* crypto_config)
52 : QuicServerSession(config, connection, nullptr, crypto_config), 51 : QuicServerSession(config, connection, nullptr, crypto_config),
53 crypto_stream_(QuicServerSession::GetCryptoStream()) {} 52 crypto_stream_(QuicServerSession::GetCryptoStream()) {}
54 ~TestServerSession() override{}; 53 ~TestQuicSpdyServerSession() override{};
55 54
56 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer)); 55 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
57 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); 56 MOCK_METHOD1(CreateIncomingDynamicStream, QuicDataStream*(QuicStreamId id));
58 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); 57 MOCK_METHOD0(CreateOutgoingDynamicStream, QuicDataStream*());
59 58
60 void SetCryptoStream(QuicCryptoServerStream* crypto_stream) { 59 void SetCryptoStream(QuicCryptoServerStream* crypto_stream) {
61 crypto_stream_ = crypto_stream; 60 crypto_stream_ = crypto_stream;
62 } 61 }
63 62
64 QuicCryptoServerStream* GetCryptoStream() override { return crypto_stream_; } 63 QuicCryptoServerStream* GetCryptoStream() override { return crypto_stream_; }
65 64
66 private: 65 private:
67 QuicCryptoServerStream* crypto_stream_; 66 QuicCryptoServerStream* crypto_stream_;
68 67
69 DISALLOW_COPY_AND_ASSIGN(TestServerSession); 68 DISALLOW_COPY_AND_ASSIGN(TestQuicSpdyServerSession);
70 }; 69 };
71 70
72 class TestDispatcher : public QuicDispatcher { 71 class TestDispatcher : public QuicDispatcher {
73 public: 72 public:
74 TestDispatcher(const QuicConfig& config, 73 TestDispatcher(const QuicConfig& config,
75 const QuicCryptoServerConfig* crypto_config, 74 const QuicCryptoServerConfig* crypto_config,
76 EpollServer* eps) 75 EpollServer* eps)
77 : QuicDispatcher(config, 76 : QuicDispatcher(config,
78 crypto_config, 77 crypto_config,
79 QuicSupportedVersions(), 78 QuicSupportedVersions(),
(...skipping 27 matching lines...) Expand all
107 106
108 private: 107 private:
109 QuicDispatcher* dispatcher_; 108 QuicDispatcher* dispatcher_;
110 }; 109 };
111 110
112 QuicServerSession* CreateSession(QuicDispatcher* dispatcher, 111 QuicServerSession* CreateSession(QuicDispatcher* dispatcher,
113 const QuicConfig& config, 112 const QuicConfig& config,
114 QuicConnectionId connection_id, 113 QuicConnectionId connection_id,
115 const IPEndPoint& client_address, 114 const IPEndPoint& client_address,
116 const QuicCryptoServerConfig* crypto_config, 115 const QuicCryptoServerConfig* crypto_config,
117 TestServerSession** session) { 116 TestQuicSpdyServerSession** session) {
118 MockServerConnection* connection = 117 MockServerConnection* connection =
119 new MockServerConnection(connection_id, dispatcher); 118 new MockServerConnection(connection_id, dispatcher);
120 *session = new TestServerSession(config, connection, crypto_config); 119 *session = new TestQuicSpdyServerSession(config, connection, crypto_config);
121 connection->set_visitor(*session); 120 connection->set_visitor(*session);
122 ON_CALL(*connection, SendConnectionClose(_)).WillByDefault( 121 ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
123 WithoutArgs(Invoke( 122 WithoutArgs(Invoke(
124 connection, &MockServerConnection::UnregisterOnConnectionClosed))); 123 connection, &MockServerConnection::UnregisterOnConnectionClosed)));
125 EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()), 124 EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()),
126 ProcessUdpPacket(_, client_address, _)); 125 ProcessUdpPacket(_, client_address, _));
127 126
128 return *session; 127 return *session;
129 } 128 }
130 129
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 time_wait_list_manager_); 195 time_wait_list_manager_);
197 } 196 }
198 197
199 EpollServer eps_; 198 EpollServer eps_;
200 QuicEpollConnectionHelper helper_; 199 QuicEpollConnectionHelper helper_;
201 QuicConfig config_; 200 QuicConfig config_;
202 QuicCryptoServerConfig crypto_config_; 201 QuicCryptoServerConfig crypto_config_;
203 IPEndPoint server_address_; 202 IPEndPoint server_address_;
204 TestDispatcher dispatcher_; 203 TestDispatcher dispatcher_;
205 MockTimeWaitListManager* time_wait_list_manager_; 204 MockTimeWaitListManager* time_wait_list_manager_;
206 TestServerSession* session1_; 205 TestQuicSpdyServerSession* session1_;
207 TestServerSession* session2_; 206 TestQuicSpdyServerSession* session2_;
208 string data_; 207 string data_;
209 }; 208 };
210 209
211 TEST_F(QuicDispatcherTest, ProcessPackets) { 210 TEST_F(QuicDispatcherTest, ProcessPackets) {
212 IPEndPoint client_address(net::test::Loopback4(), 1); 211 IPEndPoint client_address(net::test::Loopback4(), 1);
213 server_address_ = IPEndPoint(net::test::Any4(), 5); 212 server_address_ = IPEndPoint(net::test::Any4(), 5);
214 213
215 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address)) 214 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address))
216 .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1, 215 .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1,
217 client_address, &crypto_config_, 216 client_address, &crypto_config_,
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // And we'll resume where we left off when we get another call. 745 // And we'll resume where we left off when we get another call.
747 EXPECT_CALL(*connection2(), OnCanWrite()); 746 EXPECT_CALL(*connection2(), OnCanWrite());
748 dispatcher_.OnCanWrite(); 747 dispatcher_.OnCanWrite();
749 EXPECT_FALSE(dispatcher_.HasPendingWrites()); 748 EXPECT_FALSE(dispatcher_.HasPendingWrites());
750 } 749 }
751 750
752 } // namespace 751 } // namespace
753 } // namespace test 752 } // namespace test
754 } // namespace tools 753 } // namespace tools
755 } // namespace net 754 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session_test.cc ('k') | net/tools/quic/quic_server_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698