| 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/udp/udp_socket.h" | 5 #include "net/udp/udp_socket.h" |
| 6 | 6 |
| 7 #include "net/udp/udp_client_socket.h" | 7 #include "net/udp/udp_client_socket.h" |
| 8 #include "net/udp/udp_server_socket.h" | 8 #include "net/udp/udp_server_socket.h" |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 18 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
| 22 #include "net/log/captured_net_log_entry.h" |
| 22 #include "net/log/net_log_unittest.h" | 23 #include "net/log/net_log_unittest.h" |
| 24 #include "net/log/test_net_log.h" |
| 23 #include "net/test/net_test_suite.h" | 25 #include "net/test/net_test_suite.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "testing/platform_test.h" | 27 #include "testing/platform_test.h" |
| 26 | 28 |
| 27 namespace net { | 29 namespace net { |
| 28 | 30 |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 class UDPSocketTest : public PlatformTest { | 33 class UDPSocketTest : public PlatformTest { |
| 32 public: | 34 public: |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 base::Unretained(this), client.get(), simple_message)); | 208 base::Unretained(this), client.get(), simple_message)); |
| 207 run_loop.Run(); | 209 run_loop.Run(); |
| 208 EXPECT_EQ(simple_message.length(), static_cast<size_t>(read_result)); | 210 EXPECT_EQ(simple_message.length(), static_cast<size_t>(read_result)); |
| 209 EXPECT_EQ(simple_message, std::string(buffer_->data(), read_result)); | 211 EXPECT_EQ(simple_message, std::string(buffer_->data(), read_result)); |
| 210 | 212 |
| 211 // Delete sockets so they log their final events. | 213 // Delete sockets so they log their final events. |
| 212 server.reset(); | 214 server.reset(); |
| 213 client.reset(); | 215 client.reset(); |
| 214 | 216 |
| 215 // Check the server's log. | 217 // Check the server's log. |
| 216 TestNetLog::CapturedEntryList server_entries; | 218 CapturedNetLogEntry::List server_entries; |
| 217 server_log.GetEntries(&server_entries); | 219 server_log.GetEntries(&server_entries); |
| 218 EXPECT_EQ(5u, server_entries.size()); | 220 EXPECT_EQ(5u, server_entries.size()); |
| 219 EXPECT_TRUE( | 221 EXPECT_TRUE( |
| 220 LogContainsBeginEvent(server_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); | 222 LogContainsBeginEvent(server_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); |
| 221 EXPECT_TRUE(LogContainsEvent( | 223 EXPECT_TRUE(LogContainsEvent( |
| 222 server_entries, 1, NetLog::TYPE_UDP_BYTES_RECEIVED, NetLog::PHASE_NONE)); | 224 server_entries, 1, NetLog::TYPE_UDP_BYTES_RECEIVED, NetLog::PHASE_NONE)); |
| 223 EXPECT_TRUE(LogContainsEvent(server_entries, 2, NetLog::TYPE_UDP_BYTES_SENT, | 225 EXPECT_TRUE(LogContainsEvent(server_entries, 2, NetLog::TYPE_UDP_BYTES_SENT, |
| 224 NetLog::PHASE_NONE)); | 226 NetLog::PHASE_NONE)); |
| 225 EXPECT_TRUE(LogContainsEvent( | 227 EXPECT_TRUE(LogContainsEvent( |
| 226 server_entries, 3, NetLog::TYPE_UDP_BYTES_RECEIVED, NetLog::PHASE_NONE)); | 228 server_entries, 3, NetLog::TYPE_UDP_BYTES_RECEIVED, NetLog::PHASE_NONE)); |
| 227 EXPECT_TRUE( | 229 EXPECT_TRUE( |
| 228 LogContainsEndEvent(server_entries, 4, NetLog::TYPE_SOCKET_ALIVE)); | 230 LogContainsEndEvent(server_entries, 4, NetLog::TYPE_SOCKET_ALIVE)); |
| 229 | 231 |
| 230 // Check the client's log. | 232 // Check the client's log. |
| 231 TestNetLog::CapturedEntryList client_entries; | 233 CapturedNetLogEntry::List client_entries; |
| 232 client_log.GetEntries(&client_entries); | 234 client_log.GetEntries(&client_entries); |
| 233 EXPECT_EQ(7u, client_entries.size()); | 235 EXPECT_EQ(7u, client_entries.size()); |
| 234 EXPECT_TRUE( | 236 EXPECT_TRUE( |
| 235 LogContainsBeginEvent(client_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); | 237 LogContainsBeginEvent(client_entries, 0, NetLog::TYPE_SOCKET_ALIVE)); |
| 236 EXPECT_TRUE( | 238 EXPECT_TRUE( |
| 237 LogContainsBeginEvent(client_entries, 1, NetLog::TYPE_UDP_CONNECT)); | 239 LogContainsBeginEvent(client_entries, 1, NetLog::TYPE_UDP_CONNECT)); |
| 238 EXPECT_TRUE(LogContainsEndEvent(client_entries, 2, NetLog::TYPE_UDP_CONNECT)); | 240 EXPECT_TRUE(LogContainsEndEvent(client_entries, 2, NetLog::TYPE_UDP_CONNECT)); |
| 239 EXPECT_TRUE(LogContainsEvent(client_entries, 3, NetLog::TYPE_UDP_BYTES_SENT, | 241 EXPECT_TRUE(LogContainsEvent(client_entries, 3, NetLog::TYPE_UDP_BYTES_SENT, |
| 240 NetLog::PHASE_NONE)); | 242 NetLog::PHASE_NONE)); |
| 241 EXPECT_TRUE(LogContainsEvent( | 243 EXPECT_TRUE(LogContainsEvent( |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; | 798 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; |
| 797 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_NO_CHANGE)); | 799 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_NO_CHANGE)); |
| 798 g_expected_dscp = DSCP_DEFAULT; | 800 g_expected_dscp = DSCP_DEFAULT; |
| 799 g_expected_traffic_type = QOSTrafficTypeBestEffort; | 801 g_expected_traffic_type = QOSTrafficTypeBestEffort; |
| 800 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_DEFAULT)); | 802 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_DEFAULT)); |
| 801 client.Close(); | 803 client.Close(); |
| 802 } | 804 } |
| 803 #endif | 805 #endif |
| 804 | 806 |
| 805 } // namespace net | 807 } // namespace net |
| OLD | NEW |