| 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/platform/impl/quic_socket_utils.h" | 5 #include "net/tools/quic/platform/impl/quic_socket_utils.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include <array> | 9 #include <array> |
| 10 | 10 |
| 11 #include "net/quic/platform/api/quic_logging.h" | 11 #include "net/quic/platform/api/quic_logging.h" |
| 12 #include "net/quic/platform/api/quic_socket_address.h" | 12 #include "net/quic/platform/api/quic_socket_address.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "net/quic/platform/api/quic_test.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 namespace test { | 16 namespace test { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // A test fixture is used to ensure that all sockets are closed down gracefully | 19 // A test fixture is used to ensure that all sockets are closed down gracefully |
| 20 // upon test completion. Also provides a convenient API to Bind not presently | 20 // upon test completion. Also provides a convenient API to Bind not presently |
| 21 // available in QuicSocketUtils. | 21 // available in QuicSocketUtils. |
| 22 class QuicSocketUtilsTest : public ::testing::Test { | 22 class QuicSocketUtilsTest : public QuicTest { |
| 23 protected: | 23 protected: |
| 24 ~QuicSocketUtilsTest() override { | 24 ~QuicSocketUtilsTest() override { |
| 25 for (int fd : open_sockets_) { | 25 for (int fd : open_sockets_) { |
| 26 close(fd); | 26 close(fd); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 int CreateUDPSocket(const QuicSocketAddress& address) { | 30 int CreateUDPSocket(const QuicSocketAddress& address) { |
| 31 bool overflow_supported = false; | 31 bool overflow_supported = false; |
| 32 int fd = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported); | 32 int fd = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 EXPECT_EQ(512, bytes_read); | 164 EXPECT_EQ(512, bytes_read); |
| 165 for (int i = 0; i < bytes_read; i++) { | 165 for (int i = 0; i < bytes_read; i++) { |
| 166 EXPECT_EQ(static_cast<char>(i), read_buffer[i]); | 166 EXPECT_EQ(static_cast<char>(i), read_buffer[i]); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| 172 } // namespace test | 172 } // namespace test |
| 173 } // namespace net | 173 } // namespace net |
| OLD | NEW |