#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/api/socket/udp_socket.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/test_completion_callback.h"
#include "services/network/network_context.h"
#include "services/network/public/mojom/udp_socket.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
class UDPSocketUnitTest : public extensions::ExtensionServiceTestBase { … };
static void OnConnected(int result) { … }
static void OnCompleted(int bytes_read,
scoped_refptr<net::IOBuffer> io_buffer,
bool socket_destroying,
const std::string& address,
uint16_t port) { … }
static const char kTestMessage[] = …;
static const int kTestMessageLength = …;
net::AddressList CreateAddressList(const char* address_string, int port) { … }
static void OnSendCompleted(int result) { … }
TEST_F(UDPSocketUnitTest, TestUDPSocketRecvFrom) { … }
TEST_F(UDPSocketUnitTest, TestUDPMulticastJoinGroup) { … }
TEST_F(UDPSocketUnitTest, TestUDPMulticastTimeToLive) { … }
TEST_F(UDPSocketUnitTest, TestUDPMulticastLoopbackMode) { … }
static void SendMulticastPacket(base::OnceClosure quit_run_loop,
UDPSocket* src,
int result) { … }
static void OnMulticastReadCompleted(base::OnceClosure quit_run_loop,
bool* packet_received,
int count,
scoped_refptr<net::IOBuffer> io_buffer,
bool socket_destroying,
const std::string& ip,
uint16_t port) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_TestUDPMulticastRecv …
#else
#define MAYBE_TestUDPMulticastRecv …
#endif
TEST_F(UDPSocketUnitTest, MAYBE_TestUDPMulticastRecv) { … }
}