chromium/third_party/blink/renderer/modules/webtransport/bidirectional_stream_test.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/webtransport/bidirectional_stream.h"

#include <memory>
#include <utility>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/web_transport.mojom-blink.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/webtransport/web_transport_connector.mojom-blink.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/iterable.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_web_transport_bidirectional_stream.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_web_transport_options.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/streams/readable_stream.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_reader.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/webtransport/test_utils.h"
#include "third_party/blink/renderer/modules/webtransport/web_transport.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "v8/include/v8.h"

namespace blink {

namespace {

// These tests only ever create one stream at a time, so use a hardcoded stream
// id.
constexpr uint32_t kDefaultStreamId =;

// BidirectionalStream depends on blink::WebTransport. Rather than virtualise
// blink::WebTransport for these tests, we use a stub implementation of
// network::mojom::blink::WebTransport to get the behaviour we want. This class
// only supports the creation of one BidirectionalStream at a time for
// simplicity.
class StubWebTransport : public network::mojom::blink::WebTransport {};

// This class sets up a connected blink::WebTransport object using a
// StubWebTransport and provides access to both.
class ScopedWebTransport {};

// This test fragment is common to CreateLocallyAndWrite and
// CreateRemotelyAndWrite.
void TestWrite(const V8TestingScope& scope,
               ScopedWebTransport* scoped_web_transport,
               BidirectionalStream* bidirectional_stream) {}

TEST(BidirectionalStreamTest, CreateLocallyAndWrite) {}

TEST(BidirectionalStreamTest, CreateRemotelyAndWrite) {}

// This test fragment is common to CreateLocallyAndRead and
// CreateRemotelyAndRead.
void TestRead(V8TestingScope& scope,
              ScopedWebTransport* scoped_web_transport,
              BidirectionalStream* bidirectional_stream) {}

TEST(BidirectionalStreamTest, CreateLocallyAndRead) {}

TEST(BidirectionalStreamTest, CreateRemotelyAndRead) {}

TEST(BidirectionalStreamTest, IncomingStreamCleanClose) {}

TEST(BidirectionalStreamTest, OutgoingStreamCleanClose) {}

TEST(BidirectionalStreamTest, CloseWebTransport) {}

TEST(BidirectionalStreamTest, RemoteDropWebTransport) {}

TEST(BidirectionalStreamTest, WriteAfterCancellingIncoming) {}

TEST(BidirectionalStreamTest, WriteAfterIncomingClosed) {}

TEST(BidirectionalStreamTest, ReadAfterClosingOutgoing) {}

TEST(BidirectionalStreamTest, ReadAfterAbortingOutgoing) {}

TEST(BidirectionalStreamTest, ReadAfterOutgoingAborted) {}

}  // namespace

}  // namespace blink