Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "jingle/glue/pseudotcp_adapter.h" | 5 #include "remoting/protocol/pseudotcp_adapter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "jingle/glue/thread_wrapper.h" | 12 #include "jingle/glue/thread_wrapper.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 16 #include "net/udp/udp_socket.h" | |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 18 |
| 20 | 19 namespace remoting { |
| 21 namespace jingle_glue { | 20 namespace protocol { |
| 22 namespace { | |
| 23 class FakeSocket; | |
| 24 } // namespace | |
| 25 } // namespace jingle_glue | |
| 26 | |
| 27 namespace jingle_glue { | |
| 28 | 21 |
| 29 namespace { | 22 namespace { |
| 30 | 23 |
| 31 const int kMessageSize = 1024; | 24 const int kMessageSize = 1024; |
| 32 const int kMessages = 100; | 25 const int kMessages = 100; |
| 33 const int kTestDataSize = kMessages * kMessageSize; | 26 const int kTestDataSize = kMessages * kMessageSize; |
| 34 | 27 |
| 35 class RateLimiter { | 28 class RateLimiter { |
| 36 public: | 29 public: |
| 37 virtual ~RateLimiter() { }; | 30 virtual ~RateLimiter() { }; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 scoped_refptr<net::DrainableIOBuffer> output_buffer_; | 287 scoped_refptr<net::DrainableIOBuffer> output_buffer_; |
| 295 scoped_refptr<net::GrowableIOBuffer> input_buffer_; | 288 scoped_refptr<net::GrowableIOBuffer> input_buffer_; |
| 296 | 289 |
| 297 int write_errors_; | 290 int write_errors_; |
| 298 int read_errors_; | 291 int read_errors_; |
| 299 }; | 292 }; |
| 300 | 293 |
| 301 class PseudoTcpAdapterTest : public testing::Test { | 294 class PseudoTcpAdapterTest : public testing::Test { |
| 302 protected: | 295 protected: |
| 303 void SetUp() override { | 296 void SetUp() override { |
| 304 JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 297 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 305 | 298 |
| 306 host_socket_ = new FakeSocket(); | 299 host_socket_ = new FakeSocket(); |
| 307 client_socket_ = new FakeSocket(); | 300 client_socket_ = new FakeSocket(); |
| 308 | 301 |
| 309 host_socket_->Connect(client_socket_); | 302 host_socket_->Connect(client_socket_); |
| 310 client_socket_->Connect(host_socket_); | 303 client_socket_->Connect(host_socket_); |
| 311 | 304 |
| 312 host_pseudotcp_.reset(new PseudoTcpAdapter(host_socket_)); | 305 host_pseudotcp_.reset(new PseudoTcpAdapter(make_scoped_ptr(host_socket_))); |
| 313 client_pseudotcp_.reset(new PseudoTcpAdapter(client_socket_)); | 306 client_pseudotcp_.reset( |
| 307 new PseudoTcpAdapter(make_scoped_ptr(client_socket_))); | |
| 314 } | 308 } |
| 315 | 309 |
| 316 FakeSocket* host_socket_; | 310 FakeSocket* host_socket_; |
|
weitao
2015/06/19 21:37:59
Where is FakeSocket defined?
Sergey Ulanov
2015/06/19 22:01:34
in this file, line 75
weitao
2015/06/19 22:45:17
Oops, I forgot to expand the collapsed code.
| |
| 317 FakeSocket* client_socket_; | 311 FakeSocket* client_socket_; |
| 318 | 312 |
| 319 scoped_ptr<PseudoTcpAdapter> host_pseudotcp_; | 313 scoped_ptr<PseudoTcpAdapter> host_pseudotcp_; |
| 320 scoped_ptr<PseudoTcpAdapter> client_pseudotcp_; | 314 scoped_ptr<PseudoTcpAdapter> client_pseudotcp_; |
| 321 base::MessageLoop message_loop_; | 315 base::MessageLoop message_loop_; |
| 322 }; | 316 }; |
| 323 | 317 |
| 324 TEST_F(PseudoTcpAdapterTest, DataTransfer) { | 318 TEST_F(PseudoTcpAdapterTest, DataTransfer) { |
| 325 net::TestCompletionCallback host_connect_cb; | 319 net::TestCompletionCallback host_connect_cb; |
| 326 net::TestCompletionCallback client_connect_cb; | 320 net::TestCompletionCallback client_connect_cb; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 new TCPChannelTester(&message_loop_, host_pseudotcp_.get(), | 428 new TCPChannelTester(&message_loop_, host_pseudotcp_.get(), |
| 435 client_pseudotcp_.get()); | 429 client_pseudotcp_.get()); |
| 436 | 430 |
| 437 tester->Start(); | 431 tester->Start(); |
| 438 message_loop_.Run(); | 432 message_loop_.Run(); |
| 439 tester->CheckResults(); | 433 tester->CheckResults(); |
| 440 } | 434 } |
| 441 | 435 |
| 442 } // namespace | 436 } // namespace |
| 443 | 437 |
| 444 } // namespace jingle_glue | 438 } // namespace protocol |
| 439 } // namespace remoting | |
| OLD | NEW |