chromium/chrome/test/chromedriver/net/pipe_connection_unittest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <cmath>
#include <string>

#include "base/files/file_util.h"
#include "base/files/platform_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/json/json_reader.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/test/chromedriver/net/pipe_connection.h"
#include "chrome/test/chromedriver/net/sync_websocket.h"
#include "chrome/test/chromedriver/net/timeout.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace {

#if BUILDFLAG(IS_POSIX)
int ReadFromPipeNoBestEffort(base::PlatformFile file_in,
                             char* buffer,
                             int size) {}
#elif BUILDFLAG(IS_WIN)
int ReadFromPipeNoBestEffort(base::PlatformFile file_in,
                             char* buffer,
                             int size) {
  unsigned long received = 0;
  if (!::ReadFile(file_in, buffer, size, &received, nullptr)) {
    return (GetLastError() == ERROR_BROKEN_PIPE) ? 0 : -1;
  }
  return static_cast<int>(received);
}
#endif

#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_WIN)
int ReadFromPipe(base::PlatformFile file_out, char* buffer, int size) {}
#endif

#if BUILDFLAG(IS_POSIX)
int WriteToPipeNoBestEffort(base::PlatformFile file_out,
                            const char* buffer,
                            int size) {}
#elif BUILDFLAG(IS_WIN)
int WriteToPipeNoBestEffort(base::PlatformFile file_out,
                            const char* buffer,
                            int size) {
  unsigned long written = 0;
  if (!::WriteFile(file_out, buffer, size, &written, nullptr)) {
    return -1;
  }
  return static_cast<int>(written);
}
#endif

#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_WIN)
int WriteToPipe(base::PlatformFile file_out, const char* buffer, int size) {}
#endif

class PipeConnectionTest : public testing::Test {};

}  // namespace

TEST_F(PipeConnectionTest, Ctor) {}

TEST_F(PipeConnectionTest, WriteToNotStarted) {}

TEST_F(PipeConnectionTest, ReadFromNotStarted) {}

TEST_F(PipeConnectionTest, Start) {}

TEST_F(PipeConnectionTest, Send) {}

TEST_F(PipeConnectionTest, Receive) {}

TEST_F(PipeConnectionTest, NotificationArrives) {}

TEST_F(PipeConnectionTest, DetermineRecipient) {}

TEST_F(PipeConnectionTest, SendReceiveTimeout) {}

TEST_F(PipeConnectionTest, SendReceiveLarge) {}

TEST_F(PipeConnectionTest, SendMany) {}

TEST_F(PipeConnectionTest, ReceiveMany) {}

TEST_F(PipeConnectionTest, CloseBeforeReceive) {}

TEST_F(PipeConnectionTest, CloseOnReceive) {}

TEST_F(PipeConnectionTest, CloseAfterResponse) {}

TEST_F(PipeConnectionTest, CloseRemoteReadOnSend) {}

TEST_F(PipeConnectionTest, CloseRemoteWriteOnSend) {}

TEST_F(PipeConnectionTest, CloseRemoteWriteCausesShutdown) {}