| Index: net/tools/quic/quic_dispatcher_test.cc
|
| diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
|
| index d404b5a4b24b95dfaa8ed7c7e61e213d3b63d49c..fe6e2ab41aae37ca1e96054883ee218531a87ed1 100644
|
| --- a/net/tools/quic/quic_dispatcher_test.cc
|
| +++ b/net/tools/quic/quic_dispatcher_test.cc
|
| @@ -41,6 +41,20 @@ namespace tools {
|
| namespace test {
|
| namespace {
|
|
|
| +class TestServerSession : public QuicServerSession {
|
| + public:
|
| + TestServerSession(const QuicConfig& config, QuicConnection* connection)
|
| + : QuicServerSession(config, connection, nullptr) {}
|
| + ~TestServerSession() override{};
|
| +
|
| + MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
|
| + MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id));
|
| + MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*());
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(TestServerSession);
|
| +};
|
| +
|
| class TestDispatcher : public QuicDispatcher {
|
| public:
|
| explicit TestDispatcher(const QuicConfig& config,
|
| @@ -53,10 +67,10 @@ class TestDispatcher : public QuicDispatcher {
|
| eps) {
|
| }
|
|
|
| - MOCK_METHOD3(CreateQuicSession, QuicSession*(
|
| - QuicConnectionId connection_id,
|
| - const IPEndPoint& server_address,
|
| - const IPEndPoint& client_address));
|
| + MOCK_METHOD3(CreateQuicSession,
|
| + QuicServerSession*(QuicConnectionId connection_id,
|
| + const IPEndPoint& server_address,
|
| + const IPEndPoint& client_address));
|
|
|
| using QuicDispatcher::current_server_address;
|
| using QuicDispatcher::current_client_address;
|
| @@ -77,17 +91,20 @@ class MockServerConnection : public MockConnection {
|
| LOG(ERROR) << "Unregistering " << connection_id();
|
| dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR);
|
| }
|
| +
|
| private:
|
| QuicDispatcher* dispatcher_;
|
| };
|
|
|
| -QuicSession* CreateSession(QuicDispatcher* dispatcher,
|
| - QuicConnectionId connection_id,
|
| - const IPEndPoint& client_address,
|
| - MockSession** session) {
|
| +QuicServerSession* CreateSession(QuicDispatcher* dispatcher,
|
| + const QuicConfig& config,
|
| + QuicConnectionId connection_id,
|
| + const IPEndPoint& client_address,
|
| + TestServerSession** session) {
|
| MockServerConnection* connection =
|
| new MockServerConnection(connection_id, dispatcher);
|
| - *session = new MockSession(connection);
|
| + *session = new TestServerSession(config, connection);
|
| + connection->set_visitor(*session);
|
| ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
|
| WithoutArgs(Invoke(
|
| connection, &MockServerConnection::UnregisterOnConnectionClosed)));
|
| @@ -159,8 +176,8 @@ class QuicDispatcherTest : public ::testing::Test {
|
| IPEndPoint server_address_;
|
| TestDispatcher dispatcher_;
|
| MockTimeWaitListManager* time_wait_list_manager_;
|
| - MockSession* session1_;
|
| - MockSession* session2_;
|
| + TestServerSession* session1_;
|
| + TestServerSession* session2_;
|
| string data_;
|
| };
|
|
|
| @@ -171,15 +188,15 @@ TEST_F(QuicDispatcherTest, ProcessPackets) {
|
| server_address_ = IPEndPoint(any4, 5);
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address))
|
| - .WillOnce(testing::Return(CreateSession(
|
| - &dispatcher_, 1, client_address, &session1_)));
|
| + .WillOnce(testing::Return(
|
| + CreateSession(&dispatcher_, config_, 1, client_address, &session1_)));
|
| ProcessPacket(client_address, 1, true, "foo");
|
| EXPECT_EQ(client_address, dispatcher_.current_client_address());
|
| EXPECT_EQ(server_address_, dispatcher_.current_server_address());
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(2, _, client_address))
|
| .WillOnce(testing::Return(
|
| - CreateSession(&dispatcher_, 2, client_address, &session2_)));
|
| + CreateSession(&dispatcher_, config_, 2, client_address, &session2_)));
|
| ProcessPacket(client_address, 2, true, "bar");
|
|
|
| EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()),
|
| @@ -194,7 +211,7 @@ TEST_F(QuicDispatcherTest, Shutdown) {
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address))
|
| .WillOnce(testing::Return(
|
| - CreateSession(&dispatcher_, 1, client_address, &session1_)));
|
| + CreateSession(&dispatcher_, config_, 1, client_address, &session1_)));
|
|
|
| ProcessPacket(client_address, 1, true, "foo");
|
|
|
| @@ -211,8 +228,8 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
|
| IPEndPoint client_address(net::test::Loopback4(), 1);
|
| QuicConnectionId connection_id = 1;
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(connection_id, _, client_address))
|
| - .WillOnce(testing::Return(CreateSession(&dispatcher_, connection_id,
|
| - client_address, &session1_)));
|
| + .WillOnce(testing::Return(CreateSession(
|
| + &dispatcher_, config_, connection_id, client_address, &session1_)));
|
| ProcessPacket(client_address, connection_id, true, "foo");
|
|
|
| // Close the connection by sending public reset packet.
|
| @@ -310,13 +327,13 @@ class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest {
|
| IPEndPoint client_address(net::test::Loopback4(), 1);
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address))
|
| - .WillOnce(testing::Return(
|
| - CreateSession(&dispatcher_, 1, client_address, &session1_)));
|
| + .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1,
|
| + client_address, &session1_)));
|
| ProcessPacket(client_address, 1, true, "foo");
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, client_address))
|
| - .WillOnce(testing::Return(
|
| - CreateSession(&dispatcher_, 2, client_address, &session2_)));
|
| + .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 2,
|
| + client_address, &session2_)));
|
| ProcessPacket(client_address, 2, true, "bar");
|
|
|
| blocked_list_ = QuicDispatcherPeer::GetWriteBlockedList(&dispatcher_);
|
|
|