#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 { … };
}
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) { … }
TEST_P(TCPSocketUnitTest, SocketMultipleRead) { … }
TEST_P(TCPSocketUnitTest, SocketPartialRead) { … }
TEST_P(TCPSocketUnitTest, ReadError) { … }
TEST_P(TCPSocketUnitTest, Write) { … }
TEST_P(TCPSocketUnitTest, MultipleWrite) { … }
TEST_P(TCPSocketUnitTest, PartialWrite) { … }
TEST_P(TCPSocketUnitTest, WriteError) { … }
namespace {
class ExtensionsMockClientSocket : public net::MockTCPClientSocket { … };
static const net::MockRead kMockReads[] = …;
class TestSocketFactory : public net::ClientSocketFactory { … };
}
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) { … }
}