OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | 5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | 6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
7 | 7 |
| 8 #include <list> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/run_loop.h" |
11 | 14 |
12 namespace base { | 15 namespace base { |
13 class MessageLoop; | 16 class MessageLoop; |
14 } | 17 } // namespace base |
15 | 18 |
16 namespace net { | 19 namespace net { |
17 class DrainableIOBuffer; | 20 class DrainableIOBuffer; |
18 class GrowableIOBuffer; | 21 class GrowableIOBuffer; |
19 class IOBuffer; | 22 class IOBuffer; |
20 } // namespace net | 23 } // namespace net |
21 | 24 |
22 namespace remoting { | 25 namespace remoting { |
| 26 |
| 27 class CompoundBuffer; |
| 28 class VideoPacket; |
| 29 |
23 namespace protocol { | 30 namespace protocol { |
24 | 31 |
| 32 class MessagePipe; |
25 class P2PDatagramSocket; | 33 class P2PDatagramSocket; |
26 class P2PStreamSocket; | 34 class P2PStreamSocket; |
27 | 35 |
28 // This class is used by unit tests to verify that a connection | 36 // This class is used by unit tests to verify that a connection |
29 // between two sockets works properly, i.e. data is delivered from one | 37 // between two sockets works properly, i.e. data is delivered from one |
30 // end to the other. | 38 // end to the other. |
31 class StreamConnectionTester { | 39 class StreamConnectionTester { |
32 public: | 40 public: |
33 StreamConnectionTester(P2PStreamSocket* client_socket, | 41 StreamConnectionTester(P2PStreamSocket* client_socket, |
34 P2PStreamSocket* host_socket, | 42 P2PStreamSocket* host_socket, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; | 105 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_; |
98 scoped_refptr<net::IOBuffer> read_buffer_; | 106 scoped_refptr<net::IOBuffer> read_buffer_; |
99 | 107 |
100 int write_errors_; | 108 int write_errors_; |
101 int read_errors_; | 109 int read_errors_; |
102 int packets_sent_; | 110 int packets_sent_; |
103 int packets_received_; | 111 int packets_received_; |
104 int bad_packets_received_; | 112 int bad_packets_received_; |
105 }; | 113 }; |
106 | 114 |
| 115 class MessagePipeConnectionTester { |
| 116 public: |
| 117 MessagePipeConnectionTester(MessagePipe* client_pipe, |
| 118 MessagePipe* host_pipe, |
| 119 int message_size, |
| 120 int message_count); |
| 121 ~MessagePipeConnectionTester(); |
| 122 |
| 123 void RunAndCheckResults(); |
| 124 |
| 125 protected: |
| 126 void OnMessageReceived(scoped_ptr<CompoundBuffer> message); |
| 127 |
| 128 private: |
| 129 base::RunLoop run_loop_; |
| 130 MessagePipe* host_pipe_; |
| 131 MessagePipe* client_pipe_; |
| 132 int message_size_; |
| 133 int message_count_; |
| 134 |
| 135 std::vector<scoped_ptr<VideoPacket>> sent_messages_; |
| 136 std::vector<scoped_ptr<VideoPacket>> received_messages_; |
| 137 }; |
| 138 |
107 } // namespace protocol | 139 } // namespace protocol |
108 } // namespace remoting | 140 } // namespace remoting |
109 | 141 |
110 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ | 142 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_ |
OLD | NEW |