Permalink
Browse files

Merge pull request #1904 from elfprince13/fixNetTests

Fix net tests
  • Loading branch information...
Lopuska committed Jan 7, 2017
2 parents 1c9bc20 + 9773f18 commit 5344d89a6f1154381fb31e0dfd7465848453d565
@@ -491,11 +491,10 @@ template<class T> T ReservedSocketList<T>::resolve(NetSocket socketToResolve)
EntryType &entry = mSocketList[socketToResolve.getHandle()];
return entry.used ? entry.value : -1;
}
static ConnectionNotifyEvent* smConnectionNotify = NULL;
static ConnectionAcceptedEvent* smConnectionAccept = NULL;
static ConnectionReceiveEvent* smConnectionReceive = NULL;
static PacketReceiveEvent* smPacketReceive = NULL;
ConnectionNotifyEvent* Net::smConnectionNotify = NULL;
ConnectionAcceptedEvent* Net::smConnectionAccept = NULL;
ConnectionReceiveEvent* Net::smConnectionReceive = NULL;
PacketReceiveEvent* Net::smPacketReceive = NULL;
ConnectionNotifyEvent& Net::getConnectionNotifyEvent()
{
@@ -78,8 +78,8 @@ struct NetAddress
bool isSameAddress(const NetAddress &other) const
{
if (type != other.type)
return false;
if (type != other.type)
return false;
switch (type)
{
@@ -102,32 +102,32 @@ struct NetAddress
bool isSameAddressAndPort(const NetAddress &other) const
{
if (type != other.type)
return false;
switch (type)
{
case NetAddress::IPAddress:
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0) && other.port == port;
break;
case NetAddress::IPV6Address:
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0) && other.port == port;
break;
case NetAddress::IPBroadcastAddress:
return true;
break;
case NetAddress::IPV6MulticastAddress:
return true;
break;
}
return false;
if (type != other.type)
return false;
switch (type)
{
case NetAddress::IPAddress:
return (dMemcmp(other.address.ipv4.netNum, address.ipv4.netNum, 4) == 0) && other.port == port;
break;
case NetAddress::IPV6Address:
return (dMemcmp(other.address.ipv6.netNum, address.ipv6.netNum, 16) == 0) && other.port == port;
break;
case NetAddress::IPBroadcastAddress:
return true;
break;
case NetAddress::IPV6MulticastAddress:
return true;
break;
}
return false;
}
bool isEqual(const NetAddress &other) const
{
if (type != other.type)
return false;
if (type != other.type)
return false;
switch (type)
{
@@ -193,7 +193,7 @@ struct Net
WouldBlock,
NotASocket,
UnknownError,
NeedHostLookup
NeedHostLookup
};
enum ConnectionState {
@@ -214,6 +214,12 @@ struct Net
static bool smMulticastEnabled;
static bool smIpv4Enabled;
static bool smIpv6Enabled;
static ConnectionNotifyEvent* smConnectionNotify;
static ConnectionAcceptedEvent* smConnectionAccept;
static ConnectionReceiveEvent* smConnectionReceive;
static PacketReceiveEvent* smPacketReceive;
static bool init();
static void shutdown();
@@ -76,17 +76,17 @@ TEST(Net, TCPRequest)
handler.mDataReceived = 0;
// Hook into the signals.
Net::smConnectionNotify .notify(&handler, &TcpHandle::notify);
Net::smConnectionReceive.notify(&handler, &TcpHandle::receive);
Net::smConnectionNotify ->notify(&handler, &TcpHandle::notify);
Net::smConnectionReceive->notify(&handler, &TcpHandle::receive);
// Open a TCP connection to garagegames.com
handler.mSocket = Net::openConnectTo("72.246.107.193:80");
const U32 limit = Platform::getRealMilliseconds() + (5*1000);
while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) ) {}
// Unhook from the signals.
Net::smConnectionNotify .remove(&handler, &TcpHandle::notify);
Net::smConnectionReceive.remove(&handler, &TcpHandle::receive);
Net::smConnectionNotify ->remove(&handler, &TcpHandle::notify);
Net::smConnectionReceive->remove(&handler, &TcpHandle::receive);
EXPECT_GT(handler.mDataReceived, 0)
<< "Didn't get any data back!";
@@ -139,8 +139,8 @@ struct JournalHandle
mDataReceived = 0;
// Hook into the signals.
Net::smConnectionNotify .notify(this, &JournalHandle::notify);
Net::smConnectionReceive.notify(this, &JournalHandle::receive);
Net::smConnectionNotify ->notify(this, &JournalHandle::notify);
Net::smConnectionReceive->notify(this, &JournalHandle::receive);
// Open a TCP connection to garagegames.com
mSocket = Net::openConnectTo("72.246.107.193:80");
@@ -149,8 +149,8 @@ struct JournalHandle
while(Process::processEvents()) {}
// Unhook from the signals.
Net::smConnectionNotify .remove(this, &JournalHandle::notify);
Net::smConnectionReceive.remove(this, &JournalHandle::receive);
Net::smConnectionNotify ->remove(this, &JournalHandle::notify);
Net::smConnectionReceive->remove(this, &JournalHandle::receive);
EXPECT_GT(mDataReceived, 0)
<< "Didn't get any data back!";

0 comments on commit 5344d89

Please sign in to comment.