147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org/* 247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * Copyright 2009 The WebRTC Project Authors. All rights reserved. 347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * 447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * Use of this source code is governed by a BSD-style license 547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * that can be found in the LICENSE file in the root of the source 647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * tree. An additional intellectual property rights grant can be found 747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * in the file PATENTS. All contributing project authors may 847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org * be found in the AUTHORS file in the root of the source tree. 947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org */ 1047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 1147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org#ifndef WEBRTC_BASE_SOCKET_UNITTEST_H_ 1247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org#define WEBRTC_BASE_SOCKET_UNITTEST_H_ 1347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 1447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org#include "webrtc/base/gunit.h" 1547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org#include "webrtc/base/thread.h" 1647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 1747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.orgnamespace rtc { 1847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 1947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org// Generic socket tests, to be used when testing individual socketservers. 2047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org// Derive your specific test class from SocketTest, install your 2147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org// socketserver, and call the SocketTest test methods. 2247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.orgclass SocketTest : public testing::Test { 2347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org protected: 2447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org SocketTest() : ss_(NULL), kIPv4Loopback(INADDR_LOOPBACK), 2547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org kIPv6Loopback(in6addr_loopback) {} 2647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org virtual void SetUp() { ss_ = Thread::Current()->socketserver(); } 2747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectIPv4(); 2847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectIPv6(); 2947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithDnsLookupIPv4(); 3047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithDnsLookupIPv6(); 3147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectFailIPv4(); 3247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectFailIPv6(); 3347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithDnsLookupFailIPv4(); 3447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithDnsLookupFailIPv6(); 3547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithClosedSocketIPv4(); 3647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWithClosedSocketIPv6(); 3747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWhileNotClosedIPv4(); 3847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestConnectWhileNotClosedIPv6(); 3947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestServerCloseDuringConnectIPv4(); 4047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestServerCloseDuringConnectIPv6(); 4147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestClientCloseDuringConnectIPv4(); 4247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestClientCloseDuringConnectIPv6(); 4347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestServerCloseIPv4(); 4447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestServerCloseIPv6(); 4547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestCloseInClosedCallbackIPv4(); 4647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestCloseInClosedCallbackIPv6(); 4747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestSocketServerWaitIPv4(); 4847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestSocketServerWaitIPv6(); 4947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestTcpIPv4(); 5047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestTcpIPv6(); 5147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestSingleFlowControlCallbackIPv4(); 5247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestSingleFlowControlCallbackIPv6(); 5347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestUdpIPv4(); 5447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestUdpIPv6(); 5547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestUdpReadyToSendIPv4(); 5647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestUdpReadyToSendIPv6(); 5747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestGetSetOptionsIPv4(); 5847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TestGetSetOptionsIPv6(); 5947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 6047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org private: 6147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectInternal(const IPAddress& loopback); 6247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectWithDnsLookupInternal(const IPAddress& loopback, 6347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org const std::string& host); 6447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectFailInternal(const IPAddress& loopback); 6547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 6647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectWithDnsLookupFailInternal(const IPAddress& loopback); 6747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectWithClosedSocketInternal(const IPAddress& loopback); 6847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ConnectWhileNotClosedInternal(const IPAddress& loopback); 6947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ServerCloseDuringConnectInternal(const IPAddress& loopback); 7047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ClientCloseDuringConnectInternal(const IPAddress& loopback); 7147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void ServerCloseInternal(const IPAddress& loopback); 7247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void CloseInClosedCallbackInternal(const IPAddress& loopback); 7347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void SocketServerWaitInternal(const IPAddress& loopback); 7447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void TcpInternal(const IPAddress& loopback); 7547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void SingleFlowControlCallbackInternal(const IPAddress& loopback); 7647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void UdpInternal(const IPAddress& loopback); 7747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void UdpReadyToSend(const IPAddress& loopback); 7847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org void GetSetOptionsInternal(const IPAddress& loopback); 7947be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 8047be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org static const int kTimeout = 5000; // ms 8147be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org SocketServer* ss_; 8247be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org const IPAddress kIPv4Loopback; 8347be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org const IPAddress kIPv6Loopback; 8447be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org}; 8547be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 8647be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org} // namespace rtc 8747be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org 8847be73b8629244d6bb63a28198f97f040ce53d21henrike@webrtc.org#endif // WEBRTC_BASE_SOCKET_UNITTEST_H_ 89