| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 | 62 |
| 63 // This had to be split out into a separate class because I couldn't | 63 // This had to be split out into a separate class because I couldn't |
| 64 // make a the testing::Test class refcounted. | 64 // make a the testing::Test class refcounted. |
| 65 class ListenSocketTester : | 65 class ListenSocketTester : |
| 66 public ListenSocket::ListenSocketDelegate, | 66 public ListenSocket::ListenSocketDelegate, |
| 67 public base::RefCountedThreadSafe<ListenSocketTester> { | 67 public base::RefCountedThreadSafe<ListenSocketTester> { |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 friend class base::RefCountedThreadSafe<ListenSocketTester>; |
| 71 |
| 72 virtual ~ListenSocketTester() {} |
| 73 |
| 70 virtual ListenSocket* DoListen(); | 74 virtual ListenSocket* DoListen(); |
| 71 | 75 |
| 72 public: | 76 public: |
| 73 ListenSocketTester() | 77 ListenSocketTester() |
| 74 : thread_(NULL), | 78 : thread_(NULL), |
| 75 loop_(NULL), | 79 loop_(NULL), |
| 76 server_(NULL), | 80 server_(NULL), |
| 77 connection_(NULL){ | 81 connection_(NULL){ |
| 78 } | 82 } |
| 79 | 83 |
| 80 virtual ~ListenSocketTester() { | |
| 81 } | |
| 82 | |
| 83 virtual void SetUp(); | 84 virtual void SetUp(); |
| 84 virtual void TearDown(); | 85 virtual void TearDown(); |
| 85 | 86 |
| 86 void ReportAction(const ListenSocketTestAction& action); | 87 void ReportAction(const ListenSocketTestAction& action); |
| 87 bool NextAction(int timeout); | 88 bool NextAction(int timeout); |
| 88 | 89 |
| 89 // read all pending data from the test socket | 90 // read all pending data from the test socket |
| 90 int ClearTestSocket(); | 91 int ClearTestSocket(); |
| 91 // Release the connection and server sockets | 92 // Release the connection and server sockets |
| 92 void Shutdown(); | 93 void Shutdown(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 MessageLoopForIO* loop_; | 116 MessageLoopForIO* loop_; |
| 116 ListenSocket* server_; | 117 ListenSocket* server_; |
| 117 ListenSocket* connection_; | 118 ListenSocket* connection_; |
| 118 ListenSocketTestAction last_action_; | 119 ListenSocketTestAction last_action_; |
| 119 std::deque<ListenSocketTestAction> queue_; | 120 std::deque<ListenSocketTestAction> queue_; |
| 120 SOCKET test_socket_; | 121 SOCKET test_socket_; |
| 121 static const int kTestPort; | 122 static const int kTestPort; |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 #endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_ | 125 #endif // NET_BASE_LISTEN_SOCKET_UNITTEST_H_ |
| OLD | NEW |