chromium/net/test/embedded_test_server/embedded_test_server_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.

#include "net/test/embedded_test_server/embedded_test_server.h"

#include <memory>
#include <tuple>
#include <utility>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/atomic_flag.h"
#include "base/synchronization/lock.h"
#include "base/task/single_thread_task_executor.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/threading/thread.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/test_completion_callback.h"
#include "net/base/upload_bytes_element_reader.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/log/net_log_source.h"
#include "net/socket/client_socket_factory.h"
#include "net/socket/stream_socket.h"
#include "net/test/embedded_test_server/embedded_test_server_connection_listener.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

IsOk;

namespace net::test_server {

// Gets notified by the EmbeddedTestServer on incoming connections being
// accepted, read from, or closed.
class TestConnectionListener
    : public net::test_server::EmbeddedTestServerConnectionListener {};

struct EmbeddedTestServerConfig {};

std::vector<EmbeddedTestServerConfig> EmbeddedTestServerConfigs() {}

class EmbeddedTestServerTest
    : public testing::TestWithParam<EmbeddedTestServerConfig>,
      public WithTaskEnvironment {};

TEST_P(EmbeddedTestServerTest, GetBaseURL) {}

TEST_P(EmbeddedTestServerTest, GetURL) {}

TEST_P(EmbeddedTestServerTest, GetURLWithHostname) {}

TEST_P(EmbeddedTestServerTest, RegisterRequestHandler) {}

TEST_P(EmbeddedTestServerTest, ServeFilesFromDirectory) {}

TEST_P(EmbeddedTestServerTest, MockHeadersWithoutCRLF) {}

TEST_P(EmbeddedTestServerTest, DefaultNotFoundResponse) {}

TEST_P(EmbeddedTestServerTest, ConnectionListenerAccept) {}

TEST_P(EmbeddedTestServerTest, ConnectionListenerRead) {}

TEST_P(EmbeddedTestServerTest,
       UpgradeRequestHandlerEvalContinuesOnKNotHandled) {}

TEST_P(EmbeddedTestServerTest, UpgradeRequestHandlerTransfersSocket) {}

TEST_P(EmbeddedTestServerTest, UpgradeRequestHandlerEvalStopsOnErrorResponse) {}

// TODO(http://crbug.com/1166868): Flaky on ChromeOS.
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_ConnectionListenerComplete
#else
#define MAYBE_ConnectionListenerComplete
#endif
TEST_P(EmbeddedTestServerTest, MAYBE_ConnectionListenerComplete) {}

TEST_P(EmbeddedTestServerTest, ConcurrentFetches) {}

namespace {

class CancelRequestDelegate : public TestDelegate {};

class InfiniteResponse : public BasicHttpResponse {};

std::unique_ptr<HttpResponse> HandleInfiniteRequest(
    const HttpRequest& request) {}

}  // anonymous namespace

// Tests the case the connection is closed while the server is sending a
// response.  May non-deterministically end up at one of three paths
// (Discover the close event synchronously, asynchronously, or server
// shutting down before it is discovered).
TEST_P(EmbeddedTestServerTest, CloseDuringWrite) {}

const struct CertificateValuesEntry {} kCertificateValuesEntry[] =;

TEST_P(EmbeddedTestServerTest, GetCertificate) {}

TEST_P(EmbeddedTestServerTest, AcceptCHFrame) {}

TEST_P(EmbeddedTestServerTest, AcceptCHFrameDifferentOrigins) {}

TEST_P(EmbeddedTestServerTest, LargePost) {}

INSTANTIATE_TEST_SUITE_P();
// Below test exercises EmbeddedTestServer's ability to cope with the situation
// where there is no MessageLoop available on the thread at EmbeddedTestServer
// initialization and/or destruction.

ThreadingTestParams;

class EmbeddedTestServerThreadingTest
    : public testing::TestWithParam<ThreadingTestParams>,
      public WithTaskEnvironment {};

class EmbeddedTestServerThreadingTestDelegate
    : public base::PlatformThread::Delegate {};

TEST_P(EmbeddedTestServerThreadingTest, RunTest) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace net::test_server