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
;
27 // This class is used by unit tests to verify that a connection
28 // between two sockets works properly, i.e. data is delivered from one
30 class StreamConnectionTester
{
32 StreamConnectionTester(net::StreamSocket
* client_socket
,
33 net::StreamSocket
* host_socket
,
36 ~StreamConnectionTester();
39 bool done() { return done_
; }
46 void OnWritten(int result
);
47 void HandleWriteResult(int result
);
49 void OnRead(int result
);
50 void HandleReadResult(int result
);
53 base::MessageLoop
* message_loop_
;
54 net::StreamSocket
* host_socket_
;
55 net::StreamSocket
* client_socket_
;
60 scoped_refptr
<net::DrainableIOBuffer
> output_buffer_
;
61 scoped_refptr
<net::GrowableIOBuffer
> input_buffer_
;
67 class DatagramConnectionTester
{
69 DatagramConnectionTester(net::Socket
* client_socket
,
70 net::Socket
* host_socket
,
74 ~DatagramConnectionTester() ;
82 void OnWritten(int result
);
83 void HandleWriteResult(int result
);
85 void OnRead(int result
);
86 void HandleReadResult(int result
);
88 base::MessageLoop
* message_loop_
;
89 net::Socket
* host_socket_
;
90 net::Socket
* client_socket_
;
96 std::vector
<scoped_refptr
<net::IOBuffer
> > sent_packets_
;
97 scoped_refptr
<net::IOBuffer
> read_buffer_
;
102 int packets_received_
;
103 int bad_packets_received_
;
106 } // namespace protocol
107 } // namespace remoting
109 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_