chromium/net/spdy/spdy_http_stream_unittest.cc

// Copyright 2012 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 "net/spdy/spdy_http_stream.h"

#include <stdint.h>

#include <set>
#include <string>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "crypto/ec_private_key.h"
#include "crypto/ec_signature_creator.h"
#include "crypto/signature_creator.h"
#include "net/base/chunked_upload_data_stream.h"
#include "net/base/features.h"
#include "net/base/load_timing_info.h"
#include "net/base/load_timing_info_test_util.h"
#include "net/base/session_usage.h"
#include "net/base/test_completion_callback.h"
#include "net/cert/asn1_util.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/log/net_log_with_source.h"
#include "net/quic/quic_http_utils.h"
#include "net/socket/socket_tag.h"
#include "net/socket/socket_test_util.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/spdy/spdy_test_util_common.h"
#include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/third_party/quiche/src/quiche/common/http/http_header_block.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace net::test {

namespace {

// Tests the load timing of a stream that's connected and is not the first
// request sent on a connection.
void TestLoadTimingReused(const HttpStream& stream) {}

// Tests the load timing of a stream that's connected and using a fresh
// connection.
void TestLoadTimingNotReused(const HttpStream& stream) {}

class ReadErrorUploadDataStream : public UploadDataStream {};

class CancelStreamCallback : public TestCompletionCallbackBase {};

}  // namespace

class SpdyHttpStreamTest : public testing::TestWithParam<bool>,
                           public WithTaskEnvironment {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(SpdyHttpStreamTest, SendRequest) {}

TEST_P(SpdyHttpStreamTest, RequestInfoDestroyedBeforeRead) {}

TEST_P(SpdyHttpStreamTest, LoadTimingTwoRequests) {}

TEST_P(SpdyHttpStreamTest, SendChunkedPost) {}

// This unittest tests the request callback is properly called and handled.
TEST_P(SpdyHttpStreamTest, SendChunkedPostLastEmpty) {}

TEST_P(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) {}

// Test to ensure the SpdyStream state machine does not get confused when a
// chunk becomes available while a write is pending.
TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPost) {}

// Test that the SpdyStream state machine can handle sending a final empty data
// frame when uploading a chunked data stream.
TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) {}

// Test that the SpdyStream state machine handles a chunked upload with no
// payload. Unclear if this is a case worth supporting.
TEST_P(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) {}

// Test case for https://crbug.com/50058.
TEST_P(SpdyHttpStreamTest, SpdyURLTest) {}

// Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be
// made available is handled correctly.
TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) {}

TEST_P(SpdyHttpStreamTest, DataReadErrorSynchronous) {}

TEST_P(SpdyHttpStreamTest, DataReadErrorAsynchronous) {}

// Regression test for https://crbug.com/622447.
TEST_P(SpdyHttpStreamTest, RequestCallbackCancelsStream) {}

// Regression test for https://crbug.com/1082683.
// SendRequest() callback should be called as soon as sending is done,
// even when sending greased frame type is allowed.
TEST_P(SpdyHttpStreamTest, DownloadWithEmptyDataFrame) {}

// TODO(willchan): Write a longer test for SpdyStream that exercises all
// methods.

}  // namespace net::test