X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6cecf398fb4e00704cd527a7890fd81899c29e20..fbfe2d4e7caa118e1b609151bc72e7e5c7ac0f32:/tests/streams/socketstream.cpp diff --git a/tests/streams/socketstream.cpp b/tests/streams/socketstream.cpp index 7a4002163a..2db421704d 100644 --- a/tests/streams/socketstream.cpp +++ b/tests/streams/socketstream.cpp @@ -20,7 +20,6 @@ #include "wx/log.h" #endif -#include "wx/gsocket.h" #include "wx/socket.h" #include "wx/sckstrm.h" #include "wx/thread.h" @@ -82,7 +81,10 @@ protected: wxSocketBase *socket = srv.Accept(); if ( socket ) + { (*m_accept)(*socket); + delete socket; + } return NULL; } @@ -104,26 +106,29 @@ public: virtual void setUp(); virtual void tearDown(); + // repeat all socket tests several times with different socket flags, so we + // define this macro which is used several times in the test suite + // + // there must be some more elegant way to do this but I didn't find it... +#define ALL_SOCKET_TESTS() \ + CPPUNIT_TEST(Input_GetC); \ + CPPUNIT_TEST(Input_Eof); \ + CPPUNIT_TEST(Input_Read); \ + CPPUNIT_TEST(Input_LastRead); \ + CPPUNIT_TEST(Input_CanRead); \ + CPPUNIT_TEST(Input_Peek); \ + CPPUNIT_TEST(Input_Ungetch); \ + \ + CPPUNIT_TEST(Output_PutC); \ + CPPUNIT_TEST(Output_Write); \ + CPPUNIT_TEST(Output_LastWrite) + CPPUNIT_TEST_SUITE(socketStream); - // Base class stream tests the socketStream supports. - CPPUNIT_TEST(Input_GetC); - - // This one fails because wxSocketInputStream::Eof() is not implemented - // correctly - //CPPUNIT_TEST(Input_Read); - - // The other ones untested yet -#if 0 - CPPUNIT_TEST(Input_Eof); - CPPUNIT_TEST(Input_LastRead); - CPPUNIT_TEST(Input_CanRead); - CPPUNIT_TEST(Input_Peek); - CPPUNIT_TEST(Input_Ungetch); - - CPPUNIT_TEST(Output_PutC); - CPPUNIT_TEST(Output_Write); - CPPUNIT_TEST(Output_LastWrite); -#endif + ALL_SOCKET_TESTS(); + CPPUNIT_TEST( PseudoTest_SetNoWait ); + ALL_SOCKET_TESTS(); + CPPUNIT_TEST( PseudoTest_SetWaitAll ); + ALL_SOCKET_TESTS(); CPPUNIT_TEST_SUITE_END(); private: @@ -144,10 +149,15 @@ private: ; } + void PseudoTest_SetNoWait() { m_flags = wxSOCKET_NOWAIT; } + void PseudoTest_SetWaitAll() { m_flags = wxSOCKET_WAITALL; } + wxSocketClient *m_readSocket, *m_writeSocket; wxThread *m_writeThread, *m_readThread; + + wxSocketFlags m_flags; }; socketStream::socketStream() @@ -158,12 +168,14 @@ socketStream::socketStream() m_writeThread = m_readThread = NULL; - GSocket_Init(); + m_flags = wxSOCKET_NONE; + + wxSocketBase::Initialize(); } socketStream::~socketStream() { - GSocket_Cleanup(); + wxSocketBase::Shutdown(); } void socketStream::setUp() @@ -182,12 +194,10 @@ void socketStream::setUp() CPPUNIT_ASSERT_EQUAL( wxCOND_NO_ERROR, gs_cond.Wait() ); } - m_readSocket = new wxSocketClient; - m_readSocket->SetTimeout(3); + m_readSocket = new wxSocketClient(m_flags); CPPUNIT_ASSERT( m_readSocket->Connect(LocalAddress(TEST_PORT_READ)) ); - m_writeSocket = new wxSocketClient; - m_writeSocket->SetTimeout(3); + m_writeSocket = new wxSocketClient(m_flags); CPPUNIT_ASSERT( m_writeSocket->Connect(LocalAddress(TEST_PORT_WRITE)) ); }