#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/core/ipcz_driver/transport.h"
#include <cstring>
#include <queue>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "mojo/core/ipcz_driver/driver.h"
#include "mojo/core/ipcz_driver/shared_buffer.h"
#include "mojo/core/ipcz_driver/transmissible_platform_handle.h"
#include "mojo/core/ipcz_driver/wrapped_platform_handle.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/public/c/system/platform_handle.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/platform/platform_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace mojo::core::ipcz_driver {
namespace {
struct TestMessage { … };
class MojoIpczTransportTest : public test::MojoTestBase { … };
class TransportListener { … };
constexpr std::string_view kMessage1 = …;
constexpr std::string_view kMessage2 = …;
constexpr std::string_view kMessage3 = …;
constexpr std::string_view kMessage4 = …;
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(BasicTransmitClient,
MojoIpczTransportTest,
h) { … }
TEST_F(MojoIpczTransportTest, BasicTransmit) { … }
#if !BUILDFLAG(IS_WIN)
IpczDriverHandle MakeHandleFromEndpoint(PlatformChannelEndpoint endpoint) { … }
scoped_refptr<Transport> MakeTransportFromMessage(const TestMessage& message) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(TransmitHandleClient,
MojoIpczTransportTest,
h) { … }
TEST_F(MojoIpczTransportTest, TransmitHandle) { … }
#endif
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(TransmitSerializedTransportClient,
MojoIpczTransportTest,
h) { … }
TEST_F(MojoIpczTransportTest, TransmitSerializedTransport) { … }
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(TransmitFileClient,
MojoIpczTransportTest,
h) { … }
class MojoIpczTransportSecurityTest
: public MojoIpczTransportTest,
public ::testing::WithParamInterface<
std::tuple<bool,
bool>> { … };
TEST_P(MojoIpczTransportSecurityTest, TransmitFile) { … }
INSTANTIATE_TEST_SUITE_P(…);
constexpr std::string_view kMemoryMessage = …;
DEFINE_TEST_CLIENT_TEST_WITH_PIPE(TransmitMemoryClient,
MojoIpczTransportTest,
h) { … }
TEST_F(MojoIpczTransportTest, TransmitMemory) { … }
}
}