| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 EXPECT_LE(ERR_IO_PENDING, rv); | 533 EXPECT_LE(ERR_IO_PENDING, rv); |
| 534 | 534 |
| 535 IPEndPoint fetched_local_address; | 535 IPEndPoint fetched_local_address; |
| 536 rv = client.GetLocalAddress(&fetched_local_address); | 536 rv = client.GetLocalAddress(&fetched_local_address); |
| 537 EXPECT_EQ(OK, rv); | 537 EXPECT_EQ(OK, rv); |
| 538 | 538 |
| 539 // TODO(mbelshe): figure out how to verify the IP and port. | 539 // TODO(mbelshe): figure out how to verify the IP and port. |
| 540 // The port is dynamically generated by the udp stack. | 540 // The port is dynamically generated by the udp stack. |
| 541 // The IP is the real IP of the client, not necessarily | 541 // The IP is the real IP of the client, not necessarily |
| 542 // loopback. | 542 // loopback. |
| 543 //EXPECT_EQ(local_address.address(), fetched_local_address.address()); | 543 // EXPECT_EQ(local_address.address_number(), |
| 544 // fetched_local_address.address_number()); |
| 544 | 545 |
| 545 IPEndPoint fetched_remote_address; | 546 IPEndPoint fetched_remote_address; |
| 546 rv = client.GetPeerAddress(&fetched_remote_address); | 547 rv = client.GetPeerAddress(&fetched_remote_address); |
| 547 EXPECT_EQ(OK, rv); | 548 EXPECT_EQ(OK, rv); |
| 548 | 549 |
| 549 EXPECT_EQ(remote_address, fetched_remote_address); | 550 EXPECT_EQ(remote_address, fetched_remote_address); |
| 550 } | 551 } |
| 551 } | 552 } |
| 552 | 553 |
| 553 TEST_F(UDPSocketTest, ServerGetLocalAddress) { | 554 TEST_F(UDPSocketTest, ServerGetLocalAddress) { |
| 554 IPEndPoint bind_address; | 555 IPEndPoint bind_address; |
| 555 CreateUDPAddress("127.0.0.1", 0, &bind_address); | 556 CreateUDPAddress("127.0.0.1", 0, &bind_address); |
| 556 UDPServerSocket server(NULL, NetLog::Source()); | 557 UDPServerSocket server(NULL, NetLog::Source()); |
| 557 int rv = server.Listen(bind_address); | 558 int rv = server.Listen(bind_address); |
| 558 EXPECT_EQ(OK, rv); | 559 EXPECT_EQ(OK, rv); |
| 559 | 560 |
| 560 IPEndPoint local_address; | 561 IPEndPoint local_address; |
| 561 rv = server.GetLocalAddress(&local_address); | 562 rv = server.GetLocalAddress(&local_address); |
| 562 EXPECT_EQ(rv, 0); | 563 EXPECT_EQ(rv, 0); |
| 563 | 564 |
| 564 // Verify that port was allocated. | 565 // Verify that port was allocated. |
| 565 EXPECT_GT(local_address.port(), 0); | 566 EXPECT_GT(local_address.port(), 0); |
| 566 EXPECT_EQ(local_address.address(), bind_address.address()); | 567 EXPECT_EQ(local_address.address_number(), bind_address.address_number()); |
| 567 } | 568 } |
| 568 | 569 |
| 569 TEST_F(UDPSocketTest, ServerGetPeerAddress) { | 570 TEST_F(UDPSocketTest, ServerGetPeerAddress) { |
| 570 IPEndPoint bind_address; | 571 IPEndPoint bind_address; |
| 571 CreateUDPAddress("127.0.0.1", 0, &bind_address); | 572 CreateUDPAddress("127.0.0.1", 0, &bind_address); |
| 572 UDPServerSocket server(NULL, NetLog::Source()); | 573 UDPServerSocket server(NULL, NetLog::Source()); |
| 573 int rv = server.Listen(bind_address); | 574 int rv = server.Listen(bind_address); |
| 574 EXPECT_EQ(OK, rv); | 575 EXPECT_EQ(OK, rv); |
| 575 | 576 |
| 576 IPEndPoint peer_address; | 577 IPEndPoint peer_address; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; | 810 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; |
| 810 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_NO_CHANGE)); | 811 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_NO_CHANGE)); |
| 811 g_expected_dscp = DSCP_DEFAULT; | 812 g_expected_dscp = DSCP_DEFAULT; |
| 812 g_expected_traffic_type = QOSTrafficTypeBestEffort; | 813 g_expected_traffic_type = QOSTrafficTypeBestEffort; |
| 813 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_DEFAULT)); | 814 EXPECT_EQ(OK, client.SetDiffServCodePoint(DSCP_DEFAULT)); |
| 814 client.Close(); | 815 client.Close(); |
| 815 } | 816 } |
| 816 #endif | 817 #endif |
| 817 | 818 |
| 818 } // namespace net | 819 } // namespace net |
| OLD | NEW |