chromium/components/grpc_support/bidirectional_stream_unittest.cc

// Copyright 2016 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/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <stdint.h>

#include <list>
#include <map>
#include <memory>
#include <string>

#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "base/synchronization/waitable_event.h"
#include "build/build_config.h"
#include "components/grpc_support/include/bidirectional_stream_c.h"
#include "components/grpc_support/test/get_stream_engine.h"
#include "net/base/net_errors.h"
#include "net/test/quic_simple_test_server.h"
#include "net/test/test_data_directory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace {

bidirectional_stream_header kTestHeaders[] =;
const bidirectional_stream_header_array kTestHeadersArray =;
}  // namespace

namespace grpc_support {

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

class TestBidirectionalStreamCallback {};

TestBidirectionalStreamCallback::WriteData::WriteData(std::string_view data,
                                                      bool flush_after)
    :{}

TestBidirectionalStreamCallback::WriteData::~WriteData() {}

// Regression test for b/144733928. Test that coalesced headers will be split by
// cronet by '\0' separator.
TEST_P(BidirectionalStreamTest, CoalescedHeadersAreSplit) {}

TEST_P(BidirectionalStreamTest, StartExampleBidiStream) {}

TEST_P(BidirectionalStreamTest, SimplePutWithEmptyWriteDataAtTheEnd) {}

TEST_P(BidirectionalStreamTest, SimpleGetWithFlush) {}

TEST_P(BidirectionalStreamTest, SimplePostWithFlush) {}

TEST_P(BidirectionalStreamTest, SimplePostWithFlushTwice) {}

TEST_P(BidirectionalStreamTest, SimplePostWithFlushAfterOneWrite) {}

TEST_P(BidirectionalStreamTest, TestDelayedFlush) {}

TEST_P(BidirectionalStreamTest, CancelOnRead) {}

TEST_P(BidirectionalStreamTest, CancelOnResponse) {}

TEST_P(BidirectionalStreamTest, CancelOnSucceeded) {}

TEST_P(BidirectionalStreamTest, ReadFailsBeforeRequestStarted) {}

// TODO(crbug.com/345248264): deflake this test. The issue is likely that
// CustomTestBidirectionalStreamCallback owns the memory for a read buffer
// passed to the BidirectionalStream, and the task posted to tear down the
// BidirectionalStream on the network thread races with destroying the
// CustomTestBidirectionalStreamCallback on the main thread.
TEST_P(BidirectionalStreamTest,
       DISABLED_StreamFailBeforeReadIsExecutedOnNetworkThread) {}

TEST_P(BidirectionalStreamTest, WriteFailsBeforeRequestStarted) {}

TEST_P(BidirectionalStreamTest, StreamFailAfterStreamReadyCallback) {}

// TODO(crbug.com/345248264): deflake this test.
TEST_P(BidirectionalStreamTest,
       DISABLED_StreamFailBeforeWriteIsExecutedOnNetworkThread) {}

TEST_P(BidirectionalStreamTest, FailedResolution) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace grpc_support