| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // Create a socket with random binding policy and connect. | 391 // Create a socket with random binding policy and connect. |
| 392 std::unique_ptr<UDPClientSocket> test_socket(new UDPClientSocket( | 392 std::unique_ptr<UDPClientSocket> test_socket(new UDPClientSocket( |
| 393 DatagramSocket::RANDOM_BIND, rand_int_cb, NULL, NetLog::Source())); | 393 DatagramSocket::RANDOM_BIND, rand_int_cb, NULL, NetLog::Source())); |
| 394 EXPECT_THAT(test_socket->Connect(peer_address), IsOk()); | 394 EXPECT_THAT(test_socket->Connect(peer_address), IsOk()); |
| 395 | 395 |
| 396 // Make sure that the last port number in the |used_ports| was used. | 396 // Make sure that the last port number in the |used_ports| was used. |
| 397 IPEndPoint client_address; | 397 IPEndPoint client_address; |
| 398 EXPECT_THAT(test_socket->GetLocalAddress(&client_address), IsOk()); | 398 EXPECT_THAT(test_socket->GetLocalAddress(&client_address), IsOk()); |
| 399 EXPECT_EQ(used_ports.back(), client_address.port()); | 399 EXPECT_EQ(used_ports.back(), client_address.port()); |
| 400 | 400 |
| 401 STLDeleteElements(&sockets); | 401 base::STLDeleteElements(&sockets); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // Return a privileged port (under 1024) so binding will fail. | 404 // Return a privileged port (under 1024) so binding will fail. |
| 405 int PrivilegedRand(int min, int max) { | 405 int PrivilegedRand(int min, int max) { |
| 406 // Chosen by fair dice roll. Guaranteed to be random. | 406 // Chosen by fair dice roll. Guaranteed to be random. |
| 407 return 4; | 407 return 4; |
| 408 } | 408 } |
| 409 | 409 |
| 410 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR | 410 #if defined(OS_IOS) && !TARGET_IPHONE_SIMULATOR |
| 411 // TODO(droger): On iOS this test fails on device (but passes on simulator). | 411 // TODO(droger): On iOS this test fails on device (but passes on simulator). |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; | 859 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; |
| 860 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_NO_CHANGE), IsOk()); | 860 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_NO_CHANGE), IsOk()); |
| 861 g_expected_dscp = DSCP_DEFAULT; | 861 g_expected_dscp = DSCP_DEFAULT; |
| 862 g_expected_traffic_type = QOSTrafficTypeBestEffort; | 862 g_expected_traffic_type = QOSTrafficTypeBestEffort; |
| 863 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_DEFAULT), IsOk()); | 863 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_DEFAULT), IsOk()); |
| 864 client.Close(); | 864 client.Close(); |
| 865 } | 865 } |
| 866 #endif | 866 #endif |
| 867 | 867 |
| 868 } // namespace net | 868 } // namespace net |
| OLD | NEW |