chromium/third_party/blink/renderer/modules/direct_sockets/tcp_writable_stream_wrapper_unittest.cc

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

#include "third_party/blink/renderer/modules/direct_sockets/tcp_writable_stream_wrapper.h"

#include "base/containers/span.h"
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "base/test/mock_callback.h"
#include "net/base/net_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/core/streams/writable_stream.h"
#include "third_party/blink/renderer/core/streams/writable_stream_default_writer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
#include "third_party/blink/renderer/modules/direct_sockets/stream_wrapper.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {

namespace {

ElementsAre;
StrictMock;

// The purpose of this class is to ensure that the data pipe is reset before the
// V8TestingScope is destroyed, so that the TCPWritableStreamWrapper object
// doesn't try to create a DOMException after the ScriptState has gone away.
class StreamCreator : public GarbageCollected<StreamCreator> {};

class ScopedStreamCreator {};

TEST(TCPWritableStreamWrapperTest, Create) {}

TEST(TCPWritableStreamWrapperTest, WriteArrayBuffer) {}

TEST(TCPWritableStreamWrapperTest, WriteArrayBufferView) {}

bool IsAllNulls(base::span<const uint8_t> data) {}

TEST(TCPWritableStreamWrapperTest, AsyncWrite) {}

// Writing immediately followed by closing should not lose data.
TEST(TCPWritableStreamWrapperTest, WriteThenClose) {}

TEST(TCPWritableStreamWrapperTest, DISABLED_TriggerHasAborted) {}

class TCPWritableStreamWrapperCloseTestWithMaybePendingWrite
    : public testing::TestWithParam<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(TCPWritableStreamWrapperCloseTestWithMaybePendingWrite, TriggerClose) {}

TEST_P(TCPWritableStreamWrapperCloseTestWithMaybePendingWrite,
       TriggerCloseInReverseOrder) {}

}  // namespace

}  // namespace blink