chromium/chrome/browser/extensions/api/socket/tcp_socket_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 <memory>

#include "base/memory/scoped_refptr.h"
#include "base/test/bind.h"
#include "base/test/test_future.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/test/test_storage_partition.h"
#include "extensions/browser/api/socket/tcp_socket.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/address_list.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/socket/socket_test_util.h"
#include "net/traffic_annotation/network_traffic_annotation.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 "services/network/network_context.h"
#include "services/network/public/mojom/network_context.mojom.h"

namespace extensions {

namespace {

const char kTestMsg[] =;
const int kTestMsgLength =;

const char FAKE_ID[] =;

AcceptFuture;

BoolFuture;

ConnectFuture;

ListenFuture;

ReadFuture;

WriteFuture;

class TCPSocketUnitTestBase : public extensions::ExtensionServiceTestBase {};

}  // namespace

class TCPSocketUnitTest : public TCPSocketUnitTestBase,
                          public ::testing::WithParamInterface<net::IoMode> {};

INSTANTIATE_TEST_SUITE_P();

TEST_F(TCPSocketUnitTest, SocketConnectError) {}

TEST_P(TCPSocketUnitTest, SocketConnectAfterDisconnect) {}

TEST_F(TCPSocketUnitTest, SocketConnectDisconnectRace) {}

TEST_F(TCPSocketUnitTest, DestroyWhileReadPending) {}

TEST_P(TCPSocketUnitTest, Read) {}

// Tests the case where a message is split over two separate socket reads.
TEST_P(TCPSocketUnitTest, SocketMultipleRead) {}

// Tests the case where read size is smaller than the actual message.
TEST_P(TCPSocketUnitTest, SocketPartialRead) {}

TEST_P(TCPSocketUnitTest, ReadError) {}

TEST_P(TCPSocketUnitTest, Write) {}

// Tests the case where a message is split over two separate socket writes.
TEST_P(TCPSocketUnitTest, MultipleWrite) {}

TEST_P(TCPSocketUnitTest, PartialWrite) {}

TEST_P(TCPSocketUnitTest, WriteError) {}

namespace {

class ExtensionsMockClientSocket : public net::MockTCPClientSocket {};

static const net::MockRead kMockReads[] =;

// A ClientSocketFactory to create sockets that simulate SetNoDelay and
// SetKeepAlive success and failures.
class TestSocketFactory : public net::ClientSocketFactory {};

}  // namespace

class TCPSocketSettingsTest : public TCPSocketUnitTestBase,
                              public ::testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(TCPSocketSettingsTest, SetNoDelay) {}

TEST_P(TCPSocketSettingsTest, SetKeepAlive) {}

class TCPSocketServerTest : public TCPSocketUnitTestBase {};

TEST_F(TCPSocketServerTest, ListenAccept) {}

TEST_F(TCPSocketServerTest, ListenDisconnectRace) {}

TEST_F(TCPSocketServerTest, ReadAndWrite) {}

}  // namespace extensions