]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/net/socket.cpp
Use wxFindWindowAtPoint() for hit testing in wxPopupTransientWindow.
[wxWidgets.git] / tests / net / socket.cpp
index a34993bc7bb2ce0a3eb7bb16faa782e6606f240f..acd91aee6a044f8f09997f730ca543830c1bfa81 100644 (file)
@@ -2,9 +2,8 @@
 // Name:        tests/net/socket.cpp
 // Purpose:     wxSocket unit tests
 // Author:      Vadim Zeitlin
 // Name:        tests/net/socket.cpp
 // Purpose:     wxSocket unit tests
 // Author:      Vadim Zeitlin
-// RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vadim Zeitlin
 // Copyright:   (c) 2008 Vadim Zeitlin
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 /*
 ///////////////////////////////////////////////////////////////////////////////
 
 /*
@@ -68,17 +67,23 @@ private:
         {
             m_useLoop = useLoop;
             if ( useLoop )
         {
             m_useLoop = useLoop;
             if ( useLoop )
+            {
+                m_evtLoopOld = wxEventLoopBase::GetActive();
                 SetActive(this);
                 SetActive(this);
+            }
         }
 
         virtual ~SocketTestEventLoop()
         {
             if ( m_useLoop )
         }
 
         virtual ~SocketTestEventLoop()
         {
             if ( m_useLoop )
-                SetActive(NULL);
+            {
+                wxEventLoopBase::SetActive(m_evtLoopOld);
+            }
         }
 
     private:
         bool m_useLoop;
         }
 
     private:
         bool m_useLoop;
+        wxEventLoopBase *m_evtLoopOld;
     };
 
     // get the address to connect to, if NULL is returned it means that the
     };
 
     // get the address to connect to, if NULL is returned it means that the
@@ -179,7 +184,8 @@ void SocketTestCase::ReadNormal()
     sock->Read(bufSmall, WXSIZEOF(bufSmall));
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     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];
 
 
     char bufBig[102400];
@@ -187,6 +193,7 @@ void SocketTestCase::ReadNormal()
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
+    CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() );
 }
 
 void SocketTestCase::ReadBlock()
 }
 
 void SocketTestCase::ReadBlock()
@@ -199,7 +206,8 @@ void SocketTestCase::ReadBlock()
     sock->Read(bufSmall, WXSIZEOF(bufSmall));
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     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];
 
 
     char bufBig[102400];
@@ -207,6 +215,7 @@ void SocketTestCase::ReadBlock()
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastCount() );
+    CPPUNIT_ASSERT( WXSIZEOF(bufBig) >= sock->LastReadCount() );
 }
 
 void SocketTestCase::ReadNowait()
 }
 
 void SocketTestCase::ReadNowait()
@@ -235,7 +244,8 @@ void SocketTestCase::ReadWaitall()
     sock->Read(buf, WXSIZEOF(buf));
 
     CPPUNIT_ASSERT_EQUAL( wxSOCKET_NOERROR, sock->LastError() );
     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()
 }
 
 void SocketTestCase::UrlTest()
@@ -246,8 +256,9 @@ void SocketTestCase::UrlTest()
     SocketTestEventLoop loop(ms_useLoop);
 
     wxURL url("http://" + gs_serverHost);
     SocketTestEventLoop loop(ms_useLoop);
 
     wxURL url("http://" + gs_serverHost);
-    wxInputStream * const in = url.GetInputStream();
-    CPPUNIT_ASSERT( in );
+
+    const std::auto_ptr<wxInputStream> in(url.GetInputStream());
+    CPPUNIT_ASSERT( in.get() );
 
     wxStringOutputStream out;
     CPPUNIT_ASSERT_EQUAL( wxSTREAM_EOF, in->Read(out).GetLastError() );
 
     wxStringOutputStream out;
     CPPUNIT_ASSERT_EQUAL( wxSTREAM_EOF, in->Read(out).GetLastError() );