Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: remoting/protocol/connection_tester.h

Issue 8743023: Separate Authenticator and Session unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | remoting/protocol/connection_tester.cc » ('j') | remoting/protocol/fake_session.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TESTER_H_
7
8 #include <vector>
9
10 #include "base/memory/ref_counted.h"
11
12 class MessageLoop;
13
14 namespace net {
15 class DrainableIOBuffer;
16 class GrowableIOBuffer;
17 class IOBuffer;
18 class Socket;
19 class StreamSocket;
20 } // namespace net
21
22 namespace remoting {
23 namespace protocol {
24
25 // This class is used by unit tests to verify that a connection
26 // between two sockets works properly, i.e. data is delivered from one
27 // end to the other.
28 class StreamConnectionTester {
29 public:
30 StreamConnectionTester(net::StreamSocket* client_socket,
31 net::StreamSocket* host_socket,
32 int message_size,
33 int message_count);
34 ~StreamConnectionTester();
35
36 void Start();
37 void CheckResults();
38
39 protected:
40 void Done();
41 void InitBuffers();
42 void DoWrite();
43 void OnWritten(int result);
44 void HandleWriteResult(int result);
45 void DoRead();
46 void OnRead(int result);
47 void HandleReadResult(int result);
48
49 private:
50 MessageLoop* message_loop_;
51 net::StreamSocket* host_socket_;
52 net::StreamSocket* client_socket_;
53 int message_size_;
54 int message_count_;
55 int test_data_size_;
56 bool done_;
57
58 scoped_refptr<net::DrainableIOBuffer> output_buffer_;
59 scoped_refptr<net::GrowableIOBuffer> input_buffer_;
60
61 int write_errors_;
62 int read_errors_;
63 };
64
65 class DatagramConnectionTester {
66 public:
67 DatagramConnectionTester(net::Socket* client_socket,
68 net::Socket* host_socket,
69 int message_size,
70 int message_count,
71 int delay_ms);
72 ~DatagramConnectionTester() ;
73
74 void Start();
75 void CheckResults();
76
77 private:
78 void Done();
79 void DoWrite();
80 void OnWritten(int result);
81 void HandleWriteResult(int result);
82 void DoRead();
83 void OnRead(int result);
84 void HandleReadResult(int result);
85
86 MessageLoop* message_loop_;
87 net::Socket* host_socket_;
88 net::Socket* client_socket_;
89 int message_size_;
90 int message_count_;
91 int delay_ms_;
92 bool done_;
93
94 std::vector<scoped_refptr<net::IOBuffer> > sent_packets_;
95 scoped_refptr<net::IOBuffer> read_buffer_;
96
97 int write_errors_;
98 int read_errors_;
99 int packets_sent_;
100 int packets_received_;
101 int bad_packets_received_;
102 };
103
104 } // namespace protocol
105 } // namespace remoting
106
107 #endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/connection_tester.cc » ('j') | remoting/protocol/fake_session.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698