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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/protocol/connection_tester.cc » ('j') | remoting/protocol/fake_session.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_tester.h
diff --git a/remoting/protocol/connection_tester.h b/remoting/protocol/connection_tester.h
new file mode 100644
index 0000000000000000000000000000000000000000..2cd8a2dd192079ade3b58fdf328a9a2b4da5c2e9
--- /dev/null
+++ b/remoting/protocol/connection_tester.h
@@ -0,0 +1,107 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_CONNECTION_TESTER_H_
+#define REMOTING_PROTOCOL_CONNECTION_TESTER_H_
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+
+class MessageLoop;
+
+namespace net {
+class DrainableIOBuffer;
+class GrowableIOBuffer;
+class IOBuffer;
+class Socket;
+class StreamSocket;
+} // namespace net
+
+namespace remoting {
+namespace protocol {
+
+// This class is used by unit tests to verify that a connection
+// between two sockets works properly, i.e. data is delivered from one
+// end to the other.
+class StreamConnectionTester {
+ public:
+ StreamConnectionTester(net::StreamSocket* client_socket,
+ net::StreamSocket* host_socket,
+ int message_size,
+ int message_count);
+ ~StreamConnectionTester();
+
+ void Start();
+ void CheckResults();
+
+ protected:
+ void Done();
+ void InitBuffers();
+ void DoWrite();
+ void OnWritten(int result);
+ void HandleWriteResult(int result);
+ void DoRead();
+ void OnRead(int result);
+ void HandleReadResult(int result);
+
+ private:
+ MessageLoop* message_loop_;
+ net::StreamSocket* host_socket_;
+ net::StreamSocket* client_socket_;
+ int message_size_;
+ int message_count_;
+ int test_data_size_;
+ bool done_;
+
+ scoped_refptr<net::DrainableIOBuffer> output_buffer_;
+ scoped_refptr<net::GrowableIOBuffer> input_buffer_;
+
+ int write_errors_;
+ int read_errors_;
+};
+
+class DatagramConnectionTester {
+ public:
+ DatagramConnectionTester(net::Socket* client_socket,
+ net::Socket* host_socket,
+ int message_size,
+ int message_count,
+ int delay_ms);
+ ~DatagramConnectionTester() ;
+
+ void Start();
+ void CheckResults();
+
+ private:
+ void Done();
+ void DoWrite();
+ void OnWritten(int result);
+ void HandleWriteResult(int result);
+ void DoRead();
+ void OnRead(int result);
+ void HandleReadResult(int result);
+
+ MessageLoop* message_loop_;
+ net::Socket* host_socket_;
+ net::Socket* client_socket_;
+ int message_size_;
+ int message_count_;
+ int delay_ms_;
+ bool done_;
+
+ std::vector<scoped_refptr<net::IOBuffer> > sent_packets_;
+ scoped_refptr<net::IOBuffer> read_buffer_;
+
+ int write_errors_;
+ int read_errors_;
+ int packets_sent_;
+ int packets_received_;
+ int bad_packets_received_;
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_CONNECTION_TESTER_H_
« 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