chromium/content/common/service_worker/race_network_request_url_loader_client_unittest.cc

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

#include "content/common/service_worker/race_network_request_url_loader_client.h"

#include "base/containers/span.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/task_environment.h"
#include "content/common/service_worker/race_network_request_write_buffer_manager.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/simple_watcher.h"
#include "net/base/net_errors.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace content {
namespace {
MojoResult CreateDataPipe(mojo::ScopedDataPipeProducerHandle& producer_handle,
                          mojo::ScopedDataPipeConsumerHandle& consumer_handle) {}

std::unique_ptr<network::ResourceRequest> CreateRequest() {}

enum class State {};

}  // namespace

OnCommitResponseCallback;
OnCompletedCallback;

class MockServiceWorkerResourceLoader : public ServiceWorkerResourceLoader {};

// This class acts as end points of data pipe consumers, for both
// RaceNetworkRequest and the fetch handler.
// Watches body data as a data pipe consumer handle from the test response. If
// the data pipe is readable, read the chunk of data which is currently in the
// data pipe, and store it into |chunk_| to confirm if the actual received data
// is expected one.
// This class also manages the data transfer status in |state_|, which indicates
// the current progress during the data transfer process.
class ResponseBodyDataPipeReader {};

class URLLoaderClientForFetchHandler : public network::mojom::URLLoaderClient,
                                       public ResponseBodyDataPipeReader {};

class ServiceWorkerRaceNetworkRequestURLLoaderClientTest
    : public testing::Test,
      public ResponseBodyDataPipeReader {};

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest, Basic) {}

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest,
       LargeDataOverBufferSize) {}

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest,
       LargeDataOverBufferSize_SlowConsuming) {}

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest,
       DataPipeDisconnected) {}

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest,
       DataPipeDisconnected_FetchHandler) {}

TEST_F(ServiceWorkerRaceNetworkRequestURLLoaderClientTest,
       NetworkError_AfterInitialResponse) {}
}  // namespace content