chromium/third_party/blink/renderer/core/streams/readable_stream_test.cc

// Copyright 2018 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/core/streams/readable_stream.h"

#include <optional>

#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.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/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_readable_stream_get_reader_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_readablestreambyobreader_readablestreamdefaultreader.h"
#include "third_party/blink/renderer/core/messaging/message_channel.h"
#include "third_party/blink/renderer/core/streams/readable_stream_byob_reader.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_controller_with_script_scope.h"
#include "third_party/blink/renderer/core/streams/readable_stream_default_reader.h"
#include "third_party/blink/renderer/core/streams/readable_stream_transferring_optimizer.h"
#include "third_party/blink/renderer/core/streams/test_underlying_source.h"
#include "third_party/blink/renderer/core/streams/test_utils.h"
#include "third_party/blink/renderer/core/streams/underlying_byte_source_base.h"
#include "third_party/blink/renderer/core/streams/underlying_source_base.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/string_resource.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"
#include "v8/include/v8.h"

namespace blink {

namespace {

_;
ByMove;
Mock;
Return;

// Web platform tests test ReadableStream more thoroughly from scripts.
class ReadableStreamTest : public testing::Test {};

// This breaks expectations for general ReadableStreamTransferringOptimizer
// subclasses, but we don't care.
class TestTransferringOptimizer final
    : public ReadableStreamTransferringOptimizer {};

TEST_F(ReadableStreamTest, CreateWithoutArguments) {}

TEST_F(ReadableStreamTest, CreateWithUnderlyingSourceOnly) {}

TEST_F(ReadableStreamTest, CreateWithFullArguments) {}

TEST_F(ReadableStreamTest, CreateWithPathologicalStrategy) {}

// Testing getReader, locked, IsLocked and IsDisturbed.
TEST_F(ReadableStreamTest, GetReader) {}

// Regression test for https://crbug.com/1187774
TEST_F(ReadableStreamTest, TypeStringEquality) {}

// Testing getReader with mode BYOB.
TEST_F(ReadableStreamTest, GetBYOBReader) {}

TEST_F(ReadableStreamTest, Cancel) {}

TEST_F(ReadableStreamTest, CancelWithNull) {}

// TODO(yhirano): Write tests for pipeThrough and pipeTo.

TEST_F(ReadableStreamTest, Tee) {}

TEST_F(ReadableStreamTest, Close) {}

TEST_F(ReadableStreamTest, CloseStream) {}

TEST_F(ReadableStreamTest, Error) {}

TEST_F(ReadableStreamTest, LockAndDisturb) {}

TEST_F(ReadableStreamTest, Serialize) {}

TEST_F(ReadableStreamTest, DeserializeWithNullOptimizer) {}

TEST_F(ReadableStreamTest, DeserializeWithTestOptimizer) {}

TEST_F(ReadableStreamTest, GarbageCollectJavaScriptUnderlyingSource) {}

TEST_F(ReadableStreamTest, GarbageCollectCPlusPlusUnderlyingSource) {}

class ReadableByteStreamTest : public testing::Test {};

// A convenient base class to make tests shorter. Subclasses need not implement
// both Pull() and Cancel(), and can override the void versions to avoid
// the need to create a promise to return. Not appropriate for use in
// production.
class TestUnderlyingByteSource : public UnderlyingByteSourceBase {};

class MockUnderlyingByteSource : public UnderlyingByteSourceBase {};

TEST_F(ReadableByteStreamTest, Construct) {}

TEST_F(ReadableByteStreamTest, PullIsCalled) {}

TEST_F(ReadableByteStreamTest, CancelIsCalled) {}

bool IsTypeError(ScriptState* script_state,
                 ScriptValue value,
                 const String& message) {}

TEST_F(ReadableByteStreamTest, ThrowFromPull) {}

TEST_F(ReadableByteStreamTest, ThrowFromCancel) {}

TEST_F(ReadableByteStreamTest, CloseStream) {}

}  // namespace

}  // namespace blink