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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_
10 #include "base/memory/ref_counted.h"
17 class DrainableIOBuffer
;
18 class GrowableIOBuffer
;
25 class P2PDatagramSocket
;
26 class P2PStreamSocket
;
28 // 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
31 class StreamConnectionTester
{
33 StreamConnectionTester(P2PStreamSocket
* client_socket
,
34 P2PStreamSocket
* host_socket
,
37 ~StreamConnectionTester();
40 bool done() { return done_
; }
47 void OnWritten(int result
);
48 void HandleWriteResult(int result
);
50 void OnRead(int result
);
51 void HandleReadResult(int result
);
54 base::MessageLoop
* message_loop_
;
55 P2PStreamSocket
* host_socket_
;
56 P2PStreamSocket
* client_socket_
;
61 scoped_refptr
<net::DrainableIOBuffer
> output_buffer_
;
62 scoped_refptr
<net::GrowableIOBuffer
> input_buffer_
;
68 class DatagramConnectionTester
{
70 DatagramConnectionTester(P2PDatagramSocket
* client_socket
,
71 P2PDatagramSocket
* host_socket
,
75 ~DatagramConnectionTester() ;
83 void OnWritten(int result
);
84 void HandleWriteResult(int result
);
86 void OnRead(int result
);
87 void HandleReadResult(int result
);
89 base::MessageLoop
* message_loop_
;
90 P2PDatagramSocket
* host_socket_
;
91 P2PDatagramSocket
* client_socket_
;
97 std::vector
<scoped_refptr
<net::IOBuffer
> > sent_packets_
;
98 scoped_refptr
<net::IOBuffer
> read_buffer_
;
103 int packets_received_
;
104 int bad_packets_received_
;
107 } // namespace protocol
108 } // namespace remoting
110 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_