Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: net/udp/udp_socket_unittest.cc

Issue 2235973002: Add a SetDoNotFragment() method to DatagramSocket, and call this for (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/udp/udp_socket_posix.cc ('k') | net/udp/udp_socket_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_socket_unittest.cc
diff --git a/net/udp/udp_socket_unittest.cc b/net/udp/udp_socket_unittest.cc
index 2a4e60f5adcc46ef25b4ed27cb09c72803f8c415..07fe05732c517a37bddf762c218184097391e5c4 100644
--- a/net/udp/udp_socket_unittest.cc
+++ b/net/udp/udp_socket_unittest.cc
@@ -577,6 +577,50 @@ TEST_F(UDPSocketTest, ServerGetPeerAddress) {
EXPECT_EQ(rv, ERR_SOCKET_NOT_CONNECTED);
}
+TEST_F(UDPSocketTest, ClientSetDoNotFragment) {
+ for (std::string ip : {"127.0.0.1", "::1"}) {
+ LOG(INFO) << "ip: " << ip;
+ UDPClientSocket client(DatagramSocket::DEFAULT_BIND, RandIntCallback(),
+ nullptr, NetLog::Source());
+ IPAddress ip_address;
+ EXPECT_TRUE(ip_address.AssignFromIPLiteral(ip));
+ IPEndPoint remote_address(ip_address, 80);
+ int rv = client.Connect(remote_address);
+ // May fail on IPv6 is IPv6 is not configured.
+ if (ip_address.IsIPv6() && rv == ERR_ADDRESS_UNREACHABLE)
+ return;
+ EXPECT_THAT(rv, IsOk());
+
+#if defined(OS_MACOSX)
+ EXPECT_EQ(ERR_NOT_IMPLEMENTED, client.SetDoNotFragment());
+#else
+ rv = client.SetDoNotFragment();
+ EXPECT_THAT(rv, IsOk());
+#endif
+ }
+}
+
+TEST_F(UDPSocketTest, ServerSetDoNotFragment) {
+ for (std::string ip : {"127.0.0.1", "::1"}) {
+ LOG(INFO) << "ip: " << ip;
+ IPEndPoint bind_address;
+ CreateUDPAddress(ip, 0, &bind_address);
+ UDPServerSocket server(nullptr, NetLog::Source());
+ int rv = server.Listen(bind_address);
+ // May fail on IPv6 is IPv6 is not configure
+ if (bind_address.address().IsIPv6() && rv == ERR_ADDRESS_INVALID)
+ return;
+ EXPECT_THAT(rv, IsOk());
+
+#if defined(OS_MACOSX)
+ EXPECT_EQ(ERR_NOT_IMPLEMENTED, server.SetDoNotFragment());
+#else
+ rv = server.SetDoNotFragment();
+ EXPECT_THAT(rv, IsOk());
+#endif
+ }
+}
+
// Close the socket while read is pending.
TEST_F(UDPSocketTest, CloseWithPendingRead) {
IPEndPoint bind_address;
« no previous file with comments | « net/udp/udp_socket_posix.cc ('k') | net/udp/udp_socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698