| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_server.h" | 5 #include "net/tools/quic/quic_server.h" |
| 6 | 6 |
| 7 #include "net/quic/core/crypto/quic_random.h" | 7 #include "net/quic/core/crypto/quic_random.h" |
| 8 #include "net/quic/core/quic_utils.h" | 8 #include "net/quic/core/quic_utils.h" |
| 9 #include "net/quic/platform/api/quic_flags.h" | 9 #include "net/quic/platform/api/quic_flags.h" |
| 10 #include "net/quic/platform/api/quic_logging.h" | 10 #include "net/quic/platform/api/quic_logging.h" |
| 11 #include "net/quic/platform/api/quic_socket_address.h" | 11 #include "net/quic/platform/api/quic_socket_address.h" |
| 12 #include "net/quic/platform/api/quic_test.h" | 12 #include "net/quic/platform/api/quic_test.h" |
| 13 #include "net/quic/platform/api/quic_test_loopback.h" |
| 13 #include "net/quic/test_tools/crypto_test_utils.h" | 14 #include "net/quic/test_tools/crypto_test_utils.h" |
| 14 #include "net/quic/test_tools/mock_quic_dispatcher.h" | 15 #include "net/quic/test_tools/mock_quic_dispatcher.h" |
| 15 #include "net/tools/quic/quic_epoll_alarm_factory.h" | 16 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
| 16 #include "net/tools/quic/quic_epoll_connection_helper.h" | 17 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 17 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h" | 18 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h" |
| 18 #include "net/tools/quic/test_tools/quic_server_peer.h" | 19 #include "net/tools/quic/test_tools/quic_server_peer.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 EXPECT_CALL(*dispatcher_, ProcessBufferedChlos(_)).Times(2); | 118 EXPECT_CALL(*dispatcher_, ProcessBufferedChlos(_)).Times(2); |
| 118 EXPECT_CALL(*dispatcher_, HasPendingWrites()).Times(testing::AnyNumber()); | 119 EXPECT_CALL(*dispatcher_, HasPendingWrites()).Times(testing::AnyNumber()); |
| 119 // Expect there are still CHLOs buffered after 1st event. But not any more | 120 // Expect there are still CHLOs buffered after 1st event. But not any more |
| 120 // after 2nd event. | 121 // after 2nd event. |
| 121 EXPECT_CALL(*dispatcher_, HasChlosBuffered()) | 122 EXPECT_CALL(*dispatcher_, HasChlosBuffered()) |
| 122 .WillOnce(testing::Return(true)) | 123 .WillOnce(testing::Return(true)) |
| 123 .WillOnce( | 124 .WillOnce( |
| 124 DoAll(testing::Assign(&more_chlos, false), testing::Return(false))); | 125 DoAll(testing::Assign(&more_chlos, false), testing::Return(false))); |
| 125 | 126 |
| 126 // Send a packet to trigger epoll event. | 127 // Send a packet to trigger epoll event. |
| 127 int fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); | 128 int fd = socket( |
| 129 AddressFamilyUnderTest() == IpAddressFamily::IP_V4 ? AF_INET : AF_INET6, |
| 130 SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); |
| 128 ASSERT_LT(0, fd); | 131 ASSERT_LT(0, fd); |
| 129 | 132 |
| 130 char buf[1024]; | 133 char buf[1024]; |
| 131 memset(buf, 0, arraysize(buf)); | 134 memset(buf, 0, arraysize(buf)); |
| 132 sockaddr_storage storage = server_address_.generic_address(); | 135 sockaddr_storage storage = server_address_.generic_address(); |
| 133 int rc = sendto(fd, buf, arraysize(buf), 0, | 136 int rc = sendto(fd, buf, arraysize(buf), 0, |
| 134 reinterpret_cast<sockaddr*>(&storage), sizeof(storage)); | 137 reinterpret_cast<sockaddr*>(&storage), sizeof(storage)); |
| 135 if (rc < 0) { | 138 if (rc < 0) { |
| 136 QUIC_DLOG(INFO) << errno << " " << strerror(errno); | 139 QUIC_DLOG(INFO) << errno << " " << strerror(errno); |
| 137 } | 140 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet), | 200 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet), |
| 198 QuicTime::Zero(), false); | 201 QuicTime::Zero(), false); |
| 199 | 202 |
| 200 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); | 203 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); |
| 201 DispatchPacket(encrypted_valid_packet); | 204 DispatchPacket(encrypted_valid_packet); |
| 202 } | 205 } |
| 203 | 206 |
| 204 } // namespace | 207 } // namespace |
| 205 } // namespace test | 208 } // namespace test |
| 206 } // namespace net | 209 } // namespace net |
| OLD | NEW |