]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/streams/socketstream.cpp
Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox.
[wxWidgets.git] / tests / streams / socketstream.cpp
index e719f0b99445712680ac8e12c6a2b7fdceacef8c..74b814f19e36120daa94948abab4f37d8a1aeb8c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Vadim Zeitlin
 // RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vadim Zeitlin
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
@@ -106,19 +106,33 @@ 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);
-        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);
+        ALL_SOCKET_TESTS();
+        // some tests don't pass with NOWAIT flag but this is probably not a
+        // bug (TODO: check this)
+#if 0
+        CPPUNIT_TEST( PseudoTest_SetNoWait );
+        ALL_SOCKET_TESTS();
+#endif
+        CPPUNIT_TEST( PseudoTest_SetWaitAll );
+        ALL_SOCKET_TESTS();
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -139,12 +153,19 @@ private:
             ;
     }
 
+    void PseudoTest_SetNoWait() { ms_flags = wxSOCKET_NOWAIT; }
+    void PseudoTest_SetWaitAll() { ms_flags = wxSOCKET_WAITALL; }
+
     wxSocketClient *m_readSocket,
                    *m_writeSocket;
     wxThread *m_writeThread,
              *m_readThread;
+
+    static wxSocketFlags ms_flags;
 };
 
+wxSocketFlags socketStream::ms_flags = wxSOCKET_NONE;
+
 socketStream::socketStream()
 {
     m_readSocket =
@@ -177,12 +198,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(ms_flags);
     CPPUNIT_ASSERT( m_readSocket->Connect(LocalAddress(TEST_PORT_READ)) );
 
-    m_writeSocket = new wxSocketClient;
-    m_writeSocket->SetTimeout(3);
+    m_writeSocket = new wxSocketClient(ms_flags);
     CPPUNIT_ASSERT( m_writeSocket->Connect(LocalAddress(TEST_PORT_WRITE)) );
 }