| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_BASE_LISTEN_SOCKET_UNITTEST_H_ | 5 #ifndef NET_BASE_LISTEN_SOCKET_UNITTEST_H_ |
| 6 #define NET_BASE_LISTEN_SOCKET_UNITTEST_H_ | 6 #define NET_BASE_LISTEN_SOCKET_UNITTEST_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void ReportAction(const ListenSocketTestAction& action); | 87 void ReportAction(const ListenSocketTestAction& action); |
| 88 bool NextAction(int timeout); | 88 bool NextAction(int timeout); |
| 89 | 89 |
| 90 // read all pending data from the test socket | 90 // read all pending data from the test socket |
| 91 int ClearTestSocket(); | 91 int ClearTestSocket(); |
| 92 // Release the connection and server sockets | 92 // Release the connection and server sockets |
| 93 void Shutdown(); | 93 void Shutdown(); |
| 94 void Listen(); | 94 void Listen(); |
| 95 void SendFromTester(); | 95 void SendFromTester(); |
| 96 virtual void DidAccept(ListenSocket *server, ListenSocket *connection); | 96 virtual void DidAccept(ListenSocket *server, ListenSocket *connection); |
| 97 virtual void DidRead(ListenSocket *connection, const std::string& data); | 97 virtual void DidRead(ListenSocket *connection, const char* data, int len); |
| 98 virtual void DidClose(ListenSocket *sock); | 98 virtual void DidClose(ListenSocket *sock); |
| 99 virtual bool Send(SOCKET sock, const std::string& str); | 99 virtual bool Send(SOCKET sock, const std::string& str); |
| 100 // verify the send/read from client to server | 100 // verify the send/read from client to server |
| 101 void TestClientSend(); | 101 void TestClientSend(); |
| 102 // verify send/read of a longer string | 102 // verify send/read of a longer string |
| 103 void TestClientSendLong(); | 103 void TestClientSendLong(); |
| 104 // verify a send/read from server to client | 104 // verify a send/read from server to client |
| 105 void TestServerSend(); | 105 void TestServerSend(); |
| 106 | 106 |
| 107 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
| 108 CRITICAL_SECTION lock_; | 108 CRITICAL_SECTION lock_; |
| 109 HANDLE semaphore_; | 109 HANDLE semaphore_; |
| 110 #elif defined(OS_POSIX) | 110 #elif defined(OS_POSIX) |
| 111 pthread_mutex_t lock_; | 111 pthread_mutex_t lock_; |
| 112 sem_t* semaphore_; | 112 sem_t* semaphore_; |
| 113 #endif | 113 #endif |
| 114 | 114 |
| 115 scoped_ptr<base::Thread> thread_; | 115 scoped_ptr<base::Thread> thread_; |
| 116 MessageLoopForIO* loop_; | 116 MessageLoopForIO* loop_; |
| 117 ListenSocket* server_; | 117 ListenSocket* server_; |
| 118 ListenSocket* connection_; | 118 ListenSocket* connection_; |
| 119 ListenSocketTestAction last_action_; | 119 ListenSocketTestAction last_action_; |
| 120 std::deque<ListenSocketTestAction> queue_; | 120 std::deque<ListenSocketTestAction> queue_; |
| 121 SOCKET test_socket_; | 121 SOCKET test_socket_; |
| 122 static const int kTestPort; | 122 static const int kTestPort; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 #endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_ | 125 #endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_ |
| OLD | NEW |