chromium/net/socket/sequenced_socket_data_unittest.cc

// Copyright 2015 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/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include <memory>
#include <string>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "net/base/completion_once_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/test_completion_callback.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/socket_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-spi.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"

IsError;
IsOk;

//-----------------------------------------------------------------------------

namespace net {

namespace {

const char kMsg1[] =;
const int kLen1 =;
const char kMsg2[] =;
const int kLen2 =;
const char kMsg3[] =;
const int kLen3 =;
const char kMsg4[] =;
const int kLen4 =;

// Helper class for starting the next operation operation reentrantly after the
// previous operation completed asynchronously. When OnIOComplete is called,
// it will first verify that the previous operation behaved as expected. This is
// specified by either SetExpectedRead or SetExpectedWrite. It will then invoke
// a read or write operation specified by SetInvokeRead or SetInvokeWrite.
class ReentrantHelper {};

class SequencedSocketDataTest : public TestWithTaskEnvironment {};

SequencedSocketDataTest::SequencedSocketDataTest() = default;

SequencedSocketDataTest::~SequencedSocketDataTest() {}

void SequencedSocketDataTest::Initialize(base::span<const MockRead> reads,
                                         base::span<const MockWrite> writes) {}

void SequencedSocketDataTest::AssertSyncReadEquals(const char* data, int len) {}

void SequencedSocketDataTest::AssertAsyncReadEquals(const char* data, int len) {}

void SequencedSocketDataTest::AssertReadReturns(int len, int rv) {}

void SequencedSocketDataTest::AssertReadBufferEquals(const char* data,
                                                     int len) {}

void SequencedSocketDataTest::AssertSyncWriteEquals(const char* data, int len) {}

void SequencedSocketDataTest::AssertAsyncWriteEquals(const char* data,
                                                     int len) {}

bool SequencedSocketDataTest::IsPaused() const {}

void SequencedSocketDataTest::Resume() {}

void SequencedSocketDataTest::RunUntilPaused() {}

void SequencedSocketDataTest::AssertWriteReturns(const char* data,
                                                 int len,
                                                 int rv) {}

void SequencedSocketDataTest::ReentrantReadCallback(const char* data,
                                                    int len1,
                                                    int len2,
                                                    int expected_rv2,
                                                    int rv) {}

void SequencedSocketDataTest::ReentrantAsyncReadCallback(int expected_rv,
                                                         int len,
                                                         int rv) {}

void SequencedSocketDataTest::ReentrantWriteCallback(int expected_rv1,
                                                     const char* data,
                                                     int len,
                                                     int expected_rv2,
                                                     int rv) {}

void SequencedSocketDataTest::ReentrantAsyncWriteCallback(
    const char* data,
    int len,
    CompletionOnceCallback callback,
    int expected_rv,
    int rv) {}

void SequencedSocketDataTest::FailingCompletionCallback(int rv) {}

// ----------- Read

TEST_F(SequencedSocketDataTest, SingleSyncRead) {}

TEST_F(SequencedSocketDataTest, MultipleSyncReads) {}

TEST_F(SequencedSocketDataTest, SingleAsyncRead) {}

TEST_F(SequencedSocketDataTest, MultipleAsyncReads) {}

TEST_F(SequencedSocketDataTest, MixedReads) {}

TEST_F(SequencedSocketDataTest, SyncReadFromCompletionCallback) {}

TEST_F(SequencedSocketDataTest, ManyReentrantReads) {}

TEST_F(SequencedSocketDataTest, AsyncReadFromCompletionCallback) {}

TEST_F(SequencedSocketDataTest, SingleSyncReadTooEarly) {}

TEST_F(SequencedSocketDataTest, SingleSyncReadSmallBuffer) {}

TEST_F(SequencedSocketDataTest, SingleSyncReadLargeBuffer) {}

TEST_F(SequencedSocketDataTest, SingleAsyncReadLargeBuffer) {}

TEST_F(SequencedSocketDataTest, HangingRead) {}

// ----------- Write

TEST_F(SequencedSocketDataTest, SingleSyncWriteTooEarly) {}

TEST_F(SequencedSocketDataTest, SingleSyncWriteTooSmall) {}

TEST_F(SequencedSocketDataTest, SingleSyncPartialWrite) {}

TEST_F(SequencedSocketDataTest, SingleSyncWrite) {}

TEST_F(SequencedSocketDataTest, MultipleSyncWrites) {}

TEST_F(SequencedSocketDataTest, SingleAsyncWrite) {}

TEST_F(SequencedSocketDataTest, MultipleAsyncWrites) {}

TEST_F(SequencedSocketDataTest, MixedWrites) {}

TEST_F(SequencedSocketDataTest, SyncWriteFromCompletionCallback) {}

TEST_F(SequencedSocketDataTest, AsyncWriteFromCompletionCallback) {}

TEST_F(SequencedSocketDataTest, ManyReentrantWrites) {}

// ----------- Mixed Reads and Writes

TEST_F(SequencedSocketDataTest, MixedSyncOperations) {}

TEST_F(SequencedSocketDataTest, MixedAsyncOperations) {}

TEST_F(SequencedSocketDataTest, InterleavedAsyncOperations) {}

TEST_F(SequencedSocketDataTest, InterleavedMixedOperations) {}

TEST_F(SequencedSocketDataTest, AsyncReadFromWriteCompletionCallback) {}

TEST_F(SequencedSocketDataTest, AsyncWriteFromReadCompletionCallback) {}

TEST_F(SequencedSocketDataTest, MixedReentrantOperations) {}

TEST_F(SequencedSocketDataTest, MixedReentrantOperationsThenSynchronousRead) {}

TEST_F(SequencedSocketDataTest, MixedReentrantOperationsThenSynchronousWrite) {}

// Test the basic case where a read is paused.
TEST_F(SequencedSocketDataTest, PauseAndResume_PauseRead) {}

// Test the case where a read that will be paused is started before write that
// completes before the pause.
TEST_F(SequencedSocketDataTest, PauseAndResume_WritePauseRead) {}

// Test the basic case where a write is paused.
TEST_F(SequencedSocketDataTest, PauseAndResume_PauseWrite) {}

// Test the case where a write that will be paused is started before read that
// completes before the pause.
TEST_F(SequencedSocketDataTest, PauseAndResume_ReadPauseWrite) {}

}  // namespace

}  // namespace net