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

Unified Diff: remoting/protocol/connection_tester.cc

Issue 1662673002: Add MessageChanneFactory interface and use it in ChannelDispatcherBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@framing
Patch Set: Created 4 years, 11 months 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 | « remoting/protocol/connection_tester.h ('k') | remoting/protocol/ice_connection_to_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_tester.cc
diff --git a/remoting/protocol/connection_tester.cc b/remoting/protocol/connection_tester.cc
index 111ebc104db8798d1cdd181fd27f7479f238fdce..2ef402885713456e35d39fcbb86ce105110f0933 100644
--- a/remoting/protocol/connection_tester.cc
+++ b/remoting/protocol/connection_tester.cc
@@ -8,6 +8,9 @@
#include "base/message_loop/message_loop.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "remoting/proto/video.pb.h"
+#include "remoting/protocol/message_pipe.h"
+#include "remoting/protocol/message_serialization.h"
#include "remoting/protocol/p2p_datagram_socket.h"
#include "remoting/protocol/p2p_stream_socket.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -257,5 +260,46 @@ void DatagramConnectionTester::HandleReadResult(int result) {
}
}
+MessagePipeConnectionTester::MessagePipeConnectionTester(
+ MessagePipe* client_pipe,
+ MessagePipe* host_pipe,
+ int message_size,
+ int message_count)
+ : host_pipe_(host_pipe),
+ client_pipe_(client_pipe),
+ message_size_(message_size),
+ message_count_(message_count) {}
+MessagePipeConnectionTester::~MessagePipeConnectionTester() {}
+
+void MessagePipeConnectionTester::RunAndCheckResults() {
+ host_pipe_->StartReceiving(base::Bind(
+ &MessagePipeConnectionTester::OnMessageReceived, base::Unretained(this)));
+
+ for (int i = 0; i < message_count_; ++i) {
+ scoped_ptr<VideoPacket> message(new VideoPacket());
+ message->mutable_data()->resize(message_size_);
+ for (int p = 0; p < message_size_; ++p) {
+ message->mutable_data()[0] = static_cast<char>(i + p);
+ }
+ client_pipe_->Send(message.get(), base::Closure());
+ sent_messages_.push_back(std::move(message));
+ }
+
+ run_loop_.Run();
+
+ ASSERT_EQ(sent_messages_.size(), received_messages_.size());
+ for (size_t i = 0; i < sent_messages_.size(); ++i) {
+ EXPECT_TRUE(sent_messages_[i]->data() == received_messages_[i]->data());
+ }
+}
+
+void MessagePipeConnectionTester::OnMessageReceived(
+ scoped_ptr<CompoundBuffer> message) {
+ received_messages_.push_back(ParseMessage<VideoPacket>(message.get()));
+ if (received_messages_.size() >= sent_messages_.size()) {
+ run_loop_.Quit();
+ }
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « remoting/protocol/connection_tester.h ('k') | remoting/protocol/ice_connection_to_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698