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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 CreateUDPAddress("127.0.0.1", 0, &bind_address); | 574 CreateUDPAddress("127.0.0.1", 0, &bind_address); |
575 UDPServerSocket server(NULL, NetLog::Source()); | 575 UDPServerSocket server(NULL, NetLog::Source()); |
576 int rv = server.Listen(bind_address); | 576 int rv = server.Listen(bind_address); |
577 EXPECT_THAT(rv, IsOk()); | 577 EXPECT_THAT(rv, IsOk()); |
578 | 578 |
579 IPEndPoint peer_address; | 579 IPEndPoint peer_address; |
580 rv = server.GetPeerAddress(&peer_address); | 580 rv = server.GetPeerAddress(&peer_address); |
581 EXPECT_EQ(rv, ERR_SOCKET_NOT_CONNECTED); | 581 EXPECT_EQ(rv, ERR_SOCKET_NOT_CONNECTED); |
582 } | 582 } |
583 | 583 |
584 TEST_F(UDPSocketTest, ClientSetDoNotFragment) { | |
585 UDPClientSocket client(DatagramSocket::DEFAULT_BIND, RandIntCallback(), NULL, | |
586 NetLog::Source()); | |
587 IPAddress ip_address; | |
588 EXPECT_TRUE(ip_address.AssignFromIPLiteral("127.0.0.1")); | |
mmenke
2016/08/12 21:55:49
Should we do it with IPv6, too? The IPv6 path is
Ryan Hamilton
2016/08/12 22:15:26
Sure. Done.
| |
589 IPEndPoint remote_address(ip_address, 80); | |
590 int rv = client.Connect(remote_address); | |
591 EXPECT_THAT(rv, IsOk()); | |
592 | |
593 #if defined(OS_MACOSX) | |
594 EXPECT_EQ(ERR_NOT_IMPLEMENTED, client.SetDoNotFragment()); | |
595 #else | |
596 EXPECT_EQ(OK, client.SetDoNotFragment()); | |
597 #endif | |
598 } | |
599 | |
600 TEST_F(UDPSocketTest, ServerSetDoNotFragment) { | |
601 IPEndPoint bind_address; | |
602 CreateUDPAddress("127.0.0.1", 0, &bind_address); | |
603 UDPServerSocket server(NULL, NetLog::Source()); | |
604 int rv = server.Listen(bind_address); | |
605 EXPECT_THAT(rv, IsOk()); | |
606 | |
607 #if defined(OS_MACOSX) | |
608 EXPECT_EQ(ERR_NOT_IMPLEMENTED, server.SetDoNotFragment()); | |
609 #else | |
610 EXPECT_EQ(OK, server.SetDoNotFragment()); | |
611 #endif | |
612 } | |
613 | |
584 // Close the socket while read is pending. | 614 // Close the socket while read is pending. |
585 TEST_F(UDPSocketTest, CloseWithPendingRead) { | 615 TEST_F(UDPSocketTest, CloseWithPendingRead) { |
586 IPEndPoint bind_address; | 616 IPEndPoint bind_address; |
587 CreateUDPAddress("127.0.0.1", 0, &bind_address); | 617 CreateUDPAddress("127.0.0.1", 0, &bind_address); |
588 UDPServerSocket server(NULL, NetLog::Source()); | 618 UDPServerSocket server(NULL, NetLog::Source()); |
589 int rv = server.Listen(bind_address); | 619 int rv = server.Listen(bind_address); |
590 EXPECT_THAT(rv, IsOk()); | 620 EXPECT_THAT(rv, IsOk()); |
591 | 621 |
592 TestCompletionCallback callback; | 622 TestCompletionCallback callback; |
593 IPEndPoint from; | 623 IPEndPoint from; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
859 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; | 889 g_expected_traffic_type = QOSTrafficTypeExcellentEffort; |
860 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_NO_CHANGE), IsOk()); | 890 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_NO_CHANGE), IsOk()); |
861 g_expected_dscp = DSCP_DEFAULT; | 891 g_expected_dscp = DSCP_DEFAULT; |
862 g_expected_traffic_type = QOSTrafficTypeBestEffort; | 892 g_expected_traffic_type = QOSTrafficTypeBestEffort; |
863 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_DEFAULT), IsOk()); | 893 EXPECT_THAT(client.SetDiffServCodePoint(DSCP_DEFAULT), IsOk()); |
864 client.Close(); | 894 client.Close(); |
865 } | 895 } |
866 #endif | 896 #endif |
867 | 897 |
868 } // namespace net | 898 } // namespace net |
OLD | NEW |