OLD | NEW |
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_epoll_connection_helper.h" | 5 #include "net/tools/quic/quic_epoll_connection_helper.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
8 #include "net/quic/crypto/quic_decrypter.h" | 8 #include "net/quic/crypto/quic_decrypter.h" |
9 #include "net/quic/crypto/quic_encrypter.h" | 9 #include "net/quic/crypto/quic_encrypter.h" |
10 #include "net/quic/crypto/quic_random.h" | 10 #include "net/quic/crypto/quic_random.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const bool kFromPeer = true; | 32 const bool kFromPeer = true; |
33 | 33 |
34 class TestConnectionHelper : public QuicEpollConnectionHelper { | 34 class TestConnectionHelper : public QuicEpollConnectionHelper { |
35 public: | 35 public: |
36 TestConnectionHelper(int fd, EpollServer* eps) | 36 TestConnectionHelper(int fd, EpollServer* eps) |
37 : QuicEpollConnectionHelper(fd, eps) { | 37 : QuicEpollConnectionHelper(fd, eps) { |
38 } | 38 } |
39 | 39 |
40 virtual int WritePacketToWire(const QuicEncryptedPacket& packet, | 40 virtual int WritePacketToWire(const QuicEncryptedPacket& packet, |
41 int* error) OVERRIDE { | 41 int* error) OVERRIDE { |
42 QuicFramer framer(kQuicVersion1, QuicTime::Zero(), true); | 42 QuicFramer framer(QuicVersionMax(), QuicTime::Zero(), true); |
43 FramerVisitorCapturingFrames visitor; | 43 FramerVisitorCapturingFrames visitor; |
44 framer.set_visitor(&visitor); | 44 framer.set_visitor(&visitor); |
45 EXPECT_TRUE(framer.ProcessPacket(packet)); | 45 EXPECT_TRUE(framer.ProcessPacket(packet)); |
46 header_ = *visitor.header(); | 46 header_ = *visitor.header(); |
47 *error = 0; | 47 *error = 0; |
48 return packet.length(); | 48 return packet.length(); |
49 } | 49 } |
50 | 50 |
51 QuicPacketHeader* header() { return &header_; } | 51 QuicPacketHeader* header() { return &header_; } |
52 | 52 |
53 private: | 53 private: |
54 QuicPacketHeader header_; | 54 QuicPacketHeader header_; |
55 }; | 55 }; |
56 | 56 |
57 class TestConnection : public QuicConnection { | 57 class TestConnection : public QuicConnection { |
58 public: | 58 public: |
59 TestConnection(QuicGuid guid, | 59 TestConnection(QuicGuid guid, |
60 IPEndPoint address, | 60 IPEndPoint address, |
61 TestConnectionHelper* helper) | 61 TestConnectionHelper* helper) |
62 : QuicConnection(guid, address, helper, false) { | 62 : QuicConnection(guid, address, helper, false, QuicVersionMax()) { |
63 } | 63 } |
64 | 64 |
65 void SendAck() { | 65 void SendAck() { |
66 QuicConnectionPeer::SendAck(this); | 66 QuicConnectionPeer::SendAck(this); |
67 } | 67 } |
68 | 68 |
69 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 69 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
70 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 70 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
71 } | 71 } |
72 | 72 |
73 using QuicConnection::SendOrQueuePacket; | 73 using QuicConnection::SendOrQueuePacket; |
74 }; | 74 }; |
75 | 75 |
76 class QuicConnectionHelperTest : public ::testing::Test { | 76 class QuicConnectionHelperTest : public ::testing::Test { |
77 protected: | 77 protected: |
78 QuicConnectionHelperTest() | 78 QuicConnectionHelperTest() |
79 : guid_(42), | 79 : guid_(42), |
80 framer_(kQuicVersion1, QuicTime::Zero(), false), | 80 framer_(QuicVersionMax(), QuicTime::Zero(), false), |
81 send_algorithm_(new testing::StrictMock<MockSendAlgorithm>), | 81 send_algorithm_(new testing::StrictMock<MockSendAlgorithm>), |
82 helper_(new TestConnectionHelper(0, &epoll_server_)), | 82 helper_(new TestConnectionHelper(0, &epoll_server_)), |
83 connection_(guid_, IPEndPoint(), helper_), | 83 connection_(guid_, IPEndPoint(), helper_), |
84 frame1_(1, false, 0, data1) { | 84 frame1_(1, false, 0, data1) { |
85 connection_.set_visitor(&visitor_); | 85 connection_.set_visitor(&visitor_); |
86 connection_.SetSendAlgorithm(send_algorithm_); | 86 connection_.SetSendAlgorithm(send_algorithm_); |
87 epoll_server_.set_timeout_in_us(-1); | 87 epoll_server_.set_timeout_in_us(-1); |
88 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( | 88 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( |
89 QuicTime::Delta::Zero())); | 89 QuicTime::Delta::Zero())); |
90 } | 90 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 testing::Return(QuicTime::Delta::Zero())); | 194 testing::Return(QuicTime::Delta::Zero())); |
195 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); | 195 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); |
196 epoll_server_.AdvanceByAndCallCallbacks(1); | 196 epoll_server_.AdvanceByAndCallCallbacks(1); |
197 EXPECT_EQ(0u, connection_.NumQueuedPackets()); | 197 EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
198 } | 198 } |
199 | 199 |
200 } // namespace | 200 } // namespace |
201 } // namespace test | 201 } // namespace test |
202 } // namespace tools | 202 } // namespace tools |
203 } // namespace net | 203 } // namespace net |
OLD | NEW |