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/quic/quic_connection_helper.h" | 5 #include "net/quic/quic_connection_helper.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/quic/crypto/quic_decrypter.h" | 10 #include "net/quic/crypto/quic_decrypter.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace test { | 23 namespace test { |
24 | 24 |
25 const char kData[] = "foo"; | 25 const char kData[] = "foo"; |
26 const bool kFromPeer = true; | 26 const bool kFromPeer = true; |
27 | 27 |
28 class TestConnection : public QuicConnection { | 28 class TestConnection : public QuicConnection { |
29 public: | 29 public: |
30 TestConnection(QuicGuid guid, | 30 TestConnection(QuicGuid guid, |
31 IPEndPoint address, | 31 IPEndPoint address, |
32 QuicConnectionHelper* helper) | 32 QuicConnectionHelper* helper) |
33 : QuicConnection(guid, address, helper, false) { | 33 : QuicConnection(guid, address, helper, false, QuicVersionMax()) { |
34 } | 34 } |
35 | 35 |
36 void SendAck() { | 36 void SendAck() { |
37 QuicConnectionPeer::SendAck(this); | 37 QuicConnectionPeer::SendAck(this); |
38 } | 38 } |
39 | 39 |
40 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { | 40 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { |
41 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); | 41 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); |
42 } | 42 } |
43 | 43 |
44 using QuicConnection::SendOrQueuePacket; | 44 using QuicConnection::SendOrQueuePacket; |
45 }; | 45 }; |
46 | 46 |
47 class QuicConnectionHelperTest : public ::testing::Test { | 47 class QuicConnectionHelperTest : public ::testing::Test { |
48 protected: | 48 protected: |
49 // Holds a packet to be written to the wire, and the IO mode that should | 49 // Holds a packet to be written to the wire, and the IO mode that should |
50 // be used by the mock socket when performing the write. | 50 // be used by the mock socket when performing the write. |
51 struct PacketToWrite { | 51 struct PacketToWrite { |
52 PacketToWrite(IoMode mode, QuicEncryptedPacket* packet) | 52 PacketToWrite(IoMode mode, QuicEncryptedPacket* packet) |
53 : mode(mode), | 53 : mode(mode), |
54 packet(packet) { | 54 packet(packet) { |
55 } | 55 } |
56 IoMode mode; | 56 IoMode mode; |
57 QuicEncryptedPacket* packet; | 57 QuicEncryptedPacket* packet; |
58 }; | 58 }; |
59 | 59 |
60 QuicConnectionHelperTest() | 60 QuicConnectionHelperTest() |
61 : guid_(2), | 61 : guid_(2), |
62 framer_(kQuicVersion1, QuicTime::Zero(), false), | 62 framer_(QuicVersionMax(), QuicTime::Zero(), false), |
63 net_log_(BoundNetLog()), | 63 net_log_(BoundNetLog()), |
64 frame_(1, false, 0, kData) { | 64 frame_(1, false, 0, kData) { |
65 Initialize(); | 65 Initialize(); |
66 } | 66 } |
67 | 67 |
68 ~QuicConnectionHelperTest() { | 68 ~QuicConnectionHelperTest() { |
69 for (size_t i = 0; i < writes_.size(); i++) { | 69 for (size_t i = 0; i < writes_.size(); i++) { |
70 delete writes_[i].packet; | 70 delete writes_[i].packet; |
71 } | 71 } |
72 } | 72 } |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 *send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly( | 458 *send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly( |
459 testing::Return(QuicTime::Delta::Zero())); | 459 testing::Return(QuicTime::Delta::Zero())); |
460 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); | 460 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); |
461 runner_->RunNextTask(); | 461 runner_->RunNextTask(); |
462 EXPECT_EQ(0u, connection_->NumQueuedPackets()); | 462 EXPECT_EQ(0u, connection_->NumQueuedPackets()); |
463 EXPECT_TRUE(AtEof()); | 463 EXPECT_TRUE(AtEof()); |
464 } | 464 } |
465 | 465 |
466 } // namespace test | 466 } // namespace test |
467 } // namespace net | 467 } // namespace net |
OLD | NEW |