| 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.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1020 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1021 | 1021 |
| 1022 EXPECT_EQ(Perspective::IS_CLIENT, connection_.perspective()); | 1022 EXPECT_EQ(Perspective::IS_CLIENT, connection_.perspective()); |
| 1023 EXPECT_TRUE(connection_.connected()); | 1023 EXPECT_TRUE(connection_.connected()); |
| 1024 | 1024 |
| 1025 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 1025 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 1026 EXPECT_CALL(visitor_, OnStreamFrame(_)); | 1026 EXPECT_CALL(visitor_, OnStreamFrame(_)); |
| 1027 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), kSelfAddress, | 1027 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), kSelfAddress, |
| 1028 kPeerAddress); | 1028 kPeerAddress); |
| 1029 // Cause change in self_address. | 1029 // Cause change in self_address. |
| 1030 IPAddress address; | 1030 IPEndPoint self_address(IPAddress(1, 1, 1, 1), 123); |
| 1031 ASSERT_TRUE(address.AssignFromIPLiteral("1.1.1.1")); | |
| 1032 IPEndPoint self_address(address, 123); | |
| 1033 EXPECT_CALL(visitor_, OnStreamFrame(_)); | 1031 EXPECT_CALL(visitor_, OnStreamFrame(_)); |
| 1034 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), self_address, | 1032 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), self_address, |
| 1035 kPeerAddress); | 1033 kPeerAddress); |
| 1036 EXPECT_TRUE(connection_.connected()); | 1034 EXPECT_TRUE(connection_.connected()); |
| 1037 } | 1035 } |
| 1038 | 1036 |
| 1039 TEST_P(QuicConnectionTest, SelfAddressChangeAtServer) { | 1037 TEST_P(QuicConnectionTest, SelfAddressChangeAtServer) { |
| 1040 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1038 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1041 | 1039 |
| 1042 connection_.set_perspective(Perspective::IS_SERVER); | 1040 connection_.set_perspective(Perspective::IS_SERVER); |
| 1043 QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); | 1041 QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); |
| 1044 | 1042 |
| 1045 EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); | 1043 EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); |
| 1046 EXPECT_TRUE(connection_.connected()); | 1044 EXPECT_TRUE(connection_.connected()); |
| 1047 | 1045 |
| 1048 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); | 1046 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); |
| 1049 EXPECT_CALL(visitor_, OnStreamFrame(_)); | 1047 EXPECT_CALL(visitor_, OnStreamFrame(_)); |
| 1050 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), kSelfAddress, | 1048 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), kSelfAddress, |
| 1051 kPeerAddress); | 1049 kPeerAddress); |
| 1052 // Cause change in self_address. | 1050 // Cause change in self_address. |
| 1053 IPAddress address; | 1051 IPEndPoint self_address(IPAddress(1, 1, 1, 1), 123); |
| 1054 ASSERT_TRUE(address.AssignFromIPLiteral("1.1.1.1")); | |
| 1055 IPEndPoint self_address(address, 123); | |
| 1056 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_ERROR_MIGRATING_ADDRESS, _)); | 1052 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_ERROR_MIGRATING_ADDRESS, _)); |
| 1057 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), self_address, | 1053 ProcessFramePacketWithAddresses(QuicFrame(&stream_frame), self_address, |
| 1058 kPeerAddress); | 1054 kPeerAddress); |
| 1059 EXPECT_FALSE(connection_.connected()); | 1055 EXPECT_FALSE(connection_.connected()); |
| 1060 } | 1056 } |
| 1061 | 1057 |
| 1062 TEST_P(QuicConnectionTest, MaxPacketSize) { | 1058 TEST_P(QuicConnectionTest, MaxPacketSize) { |
| 1063 EXPECT_EQ(Perspective::IS_CLIENT, connection_.perspective()); | 1059 EXPECT_EQ(Perspective::IS_CLIENT, connection_.perspective()); |
| 1064 EXPECT_EQ(1350u, connection_.max_packet_length()); | 1060 EXPECT_EQ(1350u, connection_.max_packet_length()); |
| 1065 } | 1061 } |
| (...skipping 3573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4639 // result in multiple attempts to close the connection - it will be marked as | 4635 // result in multiple attempts to close the connection - it will be marked as |
| 4640 // disconnected after the first call. | 4636 // disconnected after the first call. |
| 4641 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); | 4637 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); |
| 4642 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 4638 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
| 4643 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); | 4639 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); |
| 4644 } | 4640 } |
| 4645 | 4641 |
| 4646 } // namespace | 4642 } // namespace |
| 4647 } // namespace test | 4643 } // namespace test |
| 4648 } // namespace net | 4644 } // namespace net |
| OLD | NEW |