#include "base/sync_socket.h"
#include <stddef.h>
#include <stdio.h>
#include <memory>
#include <sstream>
#include <string>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/types/fixed_array.h"
#include "build/build_config.h"
#include "ipc/ipc_test_base.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include "base/file_descriptor_posix.h"
#endif
#define IPC_MESSAGE_IMPL
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_start.h"
#define IPC_MESSAGE_START …
#if BUILDFLAG(IS_WIN)
IPC_MESSAGE_CONTROL1(MsgClassSetHandle, base::SyncSocket::Handle)
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
IPC_MESSAGE_CONTROL1(MsgClassSetHandle, base::FileDescriptor)
#endif
IPC_MESSAGE_CONTROL1(MsgClassResponse, std::string)
IPC_MESSAGE_CONTROL0(MsgClassShutdown)
namespace {
const char kHelloString[] = …;
const size_t kHelloStringLength = …;
class SyncSocketServerListener : public IPC::Listener { … };
DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(SyncSocketServerClient) { … }
class SyncSocketClientListener : public IPC::Listener { … };
SyncSocketTest;
TEST_F(SyncSocketTest, SanityTest) { … }
static void BlockingRead(base::SyncSocket* socket,
base::span<uint8_t> buffer,
size_t* received) { … }
TEST_F(SyncSocketTest, DisconnectTest) { … }
TEST_F(SyncSocketTest, BlockingReceiveTest) { … }
TEST_F(SyncSocketTest, NonBlockingWriteTest) { … }
}