X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6799c5e2838d7a61a3aa7564a5ab91b24b7fa5f1..f155075229d771430f0793700f5048ad4be00e9d:/tests/net/socket.cpp diff --git a/tests/net/socket.cpp b/tests/net/socket.cpp index 69b1b4daa9..3532618f8c 100644 --- a/tests/net/socket.cpp +++ b/tests/net/socket.cpp @@ -4,7 +4,7 @@ // Author: Vadim Zeitlin // RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin -// Licence: wxWidgets licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// /* @@ -50,13 +50,13 @@ private: CPPUNIT_TEST( ReadNormal ); \ CPPUNIT_TEST( ReadBlock ); \ CPPUNIT_TEST( ReadNowait ); \ - CPPUNIT_TEST( ReadWaitall ) + CPPUNIT_TEST( ReadWaitall ); \ + CPPUNIT_TEST( UrlTest ) CPPUNIT_TEST_SUITE( SocketTestCase ); ALL_SOCKET_TESTS(); CPPUNIT_TEST( PseudoTest_SetUseEventLoop ); ALL_SOCKET_TESTS(); - CPPUNIT_TEST( UrlTest ); CPPUNIT_TEST_SUITE_END(); // helper event loop class which sets itself as active only if we pass it @@ -68,17 +68,23 @@ private: { m_useLoop = useLoop; if ( useLoop ) + { + m_evtLoopOld = wxEventLoopBase::GetActive(); SetActive(this); + } } virtual ~SocketTestEventLoop() { if ( m_useLoop ) - SetActive(NULL); + { + wxEventLoopBase::SetActive(m_evtLoopOld); + } } private: bool m_useLoop; + wxEventLoopBase *m_evtLoopOld; }; // get the address to connect to, if NULL is returned it means that the @@ -179,7 +185,8 @@ void SocketTestCase::ReadNormal() sock->Read(bufSmall, WXSIZEOF(bufSmall)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastReadCount() ); char bufBig[102400]; @@ -187,6 +194,7 @@ void SocketTestCase::ReadNormal() CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() ); + CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() ); } void SocketTestCase::ReadBlock() @@ -199,7 +207,8 @@ void SocketTestCase::ReadBlock() sock->Read(bufSmall, WXSIZEOF(bufSmall)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(bufSmall), (size_t)sock->LastReadCount() ); char bufBig[102400]; @@ -207,6 +216,7 @@ void SocketTestCase::ReadBlock() CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() ); + CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() ); } void SocketTestCase::ReadNowait() @@ -235,7 +245,8 @@ void SocketTestCase::ReadWaitall() sock->Read(buf, WXSIZEOF(buf)); CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() ); - CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), (size_t)sock->LastCount() ); + CPPUNIT_ASSERT_EQUAL( WXSIZEOF(buf), (size_t)sock->LastReadCount() ); } void SocketTestCase::UrlTest() @@ -246,8 +257,9 @@ void SocketTestCase::UrlTest() SocketTestEventLoop loop(ms_useLoop); wxURL url("http://" + gs_serverHost); - wxInputStream * const in = url.GetInputStream(); - CPPUNIT_ASSERT( in ); + + const std::auto_ptr in(url.GetInputStream()); + CPPUNIT_ASSERT( in.get() ); wxStringOutputStream out; CPPUNIT_ASSERT_EQUAL( wxSTREAM_EOF, in->Read(out).GetLastError() );