#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/network/p2p/socket_udp.h"
#include <stdint.h>
#include <optional>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/circular_deque.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/completion_once_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/datagram_server_socket.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/p2p/socket_test_utils.h"
#include "services/network/p2p/socket_throttler.h"
#include "services/network/public/cpp/p2p_socket_type.h"
#include "services/network/throttling/network_conditions.h"
#include "services/network/throttling/throttling_controller.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/rtc_base/time_utils.h"
_;
DeleteArg;
DoAll;
ElementsAre;
Field;
InSequence;
Return;
namespace {
class ScopedFakeClock : public rtc::ClockInterface { … };
class FakeDatagramServerSocket : public net::DatagramServerSocket { … };
std::unique_ptr<net::DatagramServerSocket> CreateFakeDatagramServerSocket(
base::circular_deque<FakeDatagramServerSocket::UDPPacket>* sent_packets,
std::vector<uint16_t>* used_ports,
ScopedFakeClock* fake_clock,
net::NetLog* net_log) { … }
}
namespace network {
class P2PSocketUdpTest : public testing::Test { … };
TEST_F(P2PSocketUdpTest, SendStunNoAuth) { … }
TEST_F(P2PSocketUdpTest, SendDataNoAuth) { … }
TEST_F(P2PSocketUdpTest, SendAfterStunRequest) { … }
TEST_F(P2PSocketUdpTest, SendAfterStunResponse) { … }
TEST_F(P2PSocketUdpTest, SendAfterStunResponseDifferentHost) { … }
TEST_F(P2PSocketUdpTest, BatchesSendAfterSendingAllowed) { … }
TEST_F(P2PSocketUdpTest, ThrottleAfterLimit) { … }
TEST_F(P2PSocketUdpTest, ThrottleAfterLimitAfterReceive) { … }
TEST_F(P2PSocketUdpTest, ThrottlingStopsAtExpectedTimes) { … }
TEST_F(P2PSocketUdpTest, PortRangeImplicitPort) { … }
TEST_F(P2PSocketUdpTest, PortRangeExplictValidPort) { … }
TEST_F(P2PSocketUdpTest, PortRangeExplictInvalidPort) { … }
TEST_F(P2PSocketUdpTest, ReceiveDiscontinuousPackets) { … }
TEST_F(P2PSocketUdpTest, ReceiveBurstPacketsBasic) { … }
TEST_F(P2PSocketUdpTest, ReceiveBurstPacketsExceedingMaxBatchingSize) { … }
TEST_F(P2PSocketUdpTest, ReceiveBurstPacketsExceedingMaxBatchingBuffering) { … }
class P2PSocketUdpWithInterceptorTest : public P2PSocketUdpTest { … };
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacket) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacketOffline) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacketDelayed) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacketAndRemoveThrottling) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacketDropsLongQueue) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, SendPacketWithPacketDrop) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, ReceivePackets) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, ReceivePacketsWithEcn) { … }
TEST_F(P2PSocketUdpWithInterceptorTest, ReceivePacketDelayed) { … }
}