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

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

Issue 1433433003: Rename MockHelper to the more descriptive (and more consistent with other Mock classes) MockConnect… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@106414015
Patch Set: Created 5 years, 1 month 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_test.cc » ('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 13 matching lines...) Expand all
24 #include "net/tools/quic/test_tools/mock_quic_time_wait_list_manager.h" 24 #include "net/tools/quic/test_tools/mock_quic_time_wait_list_manager.h"
25 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" 25 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
26 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 using base::StringPiece; 29 using base::StringPiece;
30 using net::EpollServer; 30 using net::EpollServer;
31 using net::test::ConstructEncryptedPacket; 31 using net::test::ConstructEncryptedPacket;
32 using net::test::CryptoTestUtils; 32 using net::test::CryptoTestUtils;
33 using net::test::MockConnection; 33 using net::test::MockConnection;
34 using net::test::MockHelper; 34 using net::test::MockConnectionHelper;
35 using net::test::ValueRestore; 35 using net::test::ValueRestore;
36 using net::test::TestWriterFactory; 36 using net::test::TestWriterFactory;
37 using std::string; 37 using std::string;
38 using std::vector; 38 using std::vector;
39 using testing::DoAll; 39 using testing::DoAll;
40 using testing::InSequence; 40 using testing::InSequence;
41 using testing::Invoke; 41 using testing::Invoke;
42 using testing::WithoutArgs; 42 using testing::WithoutArgs;
43 using testing::_; 43 using testing::_;
44 44
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 using QuicDispatcher::current_client_address; 91 using QuicDispatcher::current_client_address;
92 }; 92 };
93 93
94 // A Connection class which unregisters the session from the dispatcher when 94 // A Connection class which unregisters the session from the dispatcher when
95 // sending connection close. 95 // sending connection close.
96 // It'd be slightly more realistic to do this from the Session but it would 96 // It'd be slightly more realistic to do this from the Session but it would
97 // involve a lot more mocking. 97 // involve a lot more mocking.
98 class MockServerConnection : public MockConnection { 98 class MockServerConnection : public MockConnection {
99 public: 99 public:
100 MockServerConnection(QuicConnectionId connection_id, 100 MockServerConnection(QuicConnectionId connection_id,
101 MockHelper* helper, 101 MockConnectionHelper* helper,
102 QuicDispatcher* dispatcher) 102 QuicDispatcher* dispatcher)
103 : MockConnection(connection_id, helper, Perspective::IS_SERVER), 103 : MockConnection(connection_id, helper, Perspective::IS_SERVER),
104 dispatcher_(dispatcher) {} 104 dispatcher_(dispatcher) {}
105 105
106 void UnregisterOnConnectionClosed() { 106 void UnregisterOnConnectionClosed() {
107 LOG(ERROR) << "Unregistering " << connection_id(); 107 LOG(ERROR) << "Unregistering " << connection_id();
108 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR); 108 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR);
109 } 109 }
110 110
111 private: 111 private:
112 QuicDispatcher* dispatcher_; 112 QuicDispatcher* dispatcher_;
113 }; 113 };
114 114
115 QuicServerSession* CreateSession(QuicDispatcher* dispatcher, 115 QuicServerSession* CreateSession(QuicDispatcher* dispatcher,
116 const QuicConfig& config, 116 const QuicConfig& config,
117 QuicConnectionId connection_id, 117 QuicConnectionId connection_id,
118 const IPEndPoint& client_address, 118 const IPEndPoint& client_address,
119 MockHelper* helper, 119 MockConnectionHelper* helper,
120 const QuicCryptoServerConfig* crypto_config, 120 const QuicCryptoServerConfig* crypto_config,
121 TestQuicSpdyServerSession** session) { 121 TestQuicSpdyServerSession** session) {
122 MockServerConnection* connection = 122 MockServerConnection* connection =
123 new MockServerConnection(connection_id, helper, dispatcher); 123 new MockServerConnection(connection_id, helper, dispatcher);
124 *session = new TestQuicSpdyServerSession(config, connection, crypto_config); 124 *session = new TestQuicSpdyServerSession(config, connection, crypto_config);
125 connection->set_visitor(*session); 125 connection->set_visitor(*session);
126 ON_CALL(*connection, SendConnectionClose(_)).WillByDefault( 126 ON_CALL(*connection, SendConnectionClose(_)).WillByDefault(
127 WithoutArgs(Invoke( 127 WithoutArgs(Invoke(
128 connection, &MockServerConnection::UnregisterOnConnectionClosed))); 128 connection, &MockServerConnection::UnregisterOnConnectionClosed)));
129 EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()), 129 EXPECT_CALL(*reinterpret_cast<MockConnection*>((*session)->connection()),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void CreateTimeWaitListManager() { 196 void CreateTimeWaitListManager() {
197 time_wait_list_manager_ = new MockTimeWaitListManager( 197 time_wait_list_manager_ = new MockTimeWaitListManager(
198 QuicDispatcherPeer::GetWriter(&dispatcher_), &dispatcher_, &helper_); 198 QuicDispatcherPeer::GetWriter(&dispatcher_), &dispatcher_, &helper_);
199 // dispatcher_ takes the ownership of time_wait_list_manager_. 199 // dispatcher_ takes the ownership of time_wait_list_manager_.
200 QuicDispatcherPeer::SetTimeWaitListManager(&dispatcher_, 200 QuicDispatcherPeer::SetTimeWaitListManager(&dispatcher_,
201 time_wait_list_manager_); 201 time_wait_list_manager_);
202 } 202 }
203 203
204 EpollServer eps_; 204 EpollServer eps_;
205 QuicEpollConnectionHelper helper_; 205 QuicEpollConnectionHelper helper_;
206 MockHelper mock_helper_; 206 MockConnectionHelper mock_helper_;
207 QuicConfig config_; 207 QuicConfig config_;
208 QuicCryptoServerConfig crypto_config_; 208 QuicCryptoServerConfig crypto_config_;
209 IPEndPoint server_address_; 209 IPEndPoint server_address_;
210 TestDispatcher dispatcher_; 210 TestDispatcher dispatcher_;
211 MockTimeWaitListManager* time_wait_list_manager_; 211 MockTimeWaitListManager* time_wait_list_manager_;
212 TestQuicSpdyServerSession* session1_; 212 TestQuicSpdyServerSession* session1_;
213 TestQuicSpdyServerSession* session2_; 213 TestQuicSpdyServerSession* session2_;
214 string data_; 214 string data_;
215 }; 215 };
216 216
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 void SetBlocked() { 617 void SetBlocked() {
618 writer_->write_blocked_ = true; 618 writer_->write_blocked_ = true;
619 } 619 }
620 620
621 void BlockConnection2() { 621 void BlockConnection2() {
622 writer_->write_blocked_ = true; 622 writer_->write_blocked_ = true;
623 dispatcher_.OnWriteBlocked(connection2()); 623 dispatcher_.OnWriteBlocked(connection2());
624 } 624 }
625 625
626 protected: 626 protected:
627 MockHelper helper_; 627 MockConnectionHelper helper_;
628 BlockingWriter* writer_; 628 BlockingWriter* writer_;
629 QuicDispatcher::WriteBlockedList* blocked_list_; 629 QuicDispatcher::WriteBlockedList* blocked_list_;
630 }; 630 };
631 631
632 TEST_F(QuicDispatcherWriteBlockedListTest, BasicOnCanWrite) { 632 TEST_F(QuicDispatcherWriteBlockedListTest, BasicOnCanWrite) {
633 // No OnCanWrite calls because no connections are blocked. 633 // No OnCanWrite calls because no connections are blocked.
634 dispatcher_.OnCanWrite(); 634 dispatcher_.OnCanWrite();
635 635
636 // Register connection 1 for events, and make sure it's notified. 636 // Register connection 1 for events, and make sure it's notified.
637 SetBlocked(); 637 SetBlocked();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 // And we'll resume where we left off when we get another call. 756 // And we'll resume where we left off when we get another call.
757 EXPECT_CALL(*connection2(), OnCanWrite()); 757 EXPECT_CALL(*connection2(), OnCanWrite());
758 dispatcher_.OnCanWrite(); 758 dispatcher_.OnCanWrite();
759 EXPECT_FALSE(dispatcher_.HasPendingWrites()); 759 EXPECT_FALSE(dispatcher_.HasPendingWrites());
760 } 760 }
761 761
762 } // namespace 762 } // namespace
763 } // namespace test 763 } // namespace test
764 } // namespace tools 764 } // namespace tools
765 } // namespace net 765 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session_test.cc ('k') | net/tools/quic/quic_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698