| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/renderer_host/p2p/socket_host_udp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 net::BoundNetLog net_log_; | 106 net::BoundNetLog net_log_; |
| 107 | 107 |
| 108 scoped_refptr<net::IOBuffer> recv_buffer_; | 108 scoped_refptr<net::IOBuffer> recv_buffer_; |
| 109 net::IPEndPoint* recv_address_; | 109 net::IPEndPoint* recv_address_; |
| 110 int recv_size_; | 110 int recv_size_; |
| 111 net::CompletionCallback* recv_callback_; | 111 net::CompletionCallback* recv_callback_; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 } // namespace | 114 } // namespace |
| 115 | 115 |
| 116 namespace content { |
| 117 |
| 116 class P2PSocketHostUdpTest : public testing::Test { | 118 class P2PSocketHostUdpTest : public testing::Test { |
| 117 protected: | 119 protected: |
| 118 virtual void SetUp() OVERRIDE { | 120 virtual void SetUp() OVERRIDE { |
| 119 EXPECT_CALL(sender_, Send( | 121 EXPECT_CALL(sender_, Send( |
| 120 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 122 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
| 121 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 123 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
| 122 | 124 |
| 123 socket_host_.reset(new P2PSocketHostUdp(&sender_, 0, 0)); | 125 socket_host_.reset(new P2PSocketHostUdp(&sender_, 0, 0)); |
| 124 socket_ = new FakeDatagramServerSocket(&sent_packets_); | 126 socket_ = new FakeDatagramServerSocket(&sent_packets_); |
| 125 socket_host_->socket_.reset(socket_); | 127 socket_host_->socket_.reset(socket_); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 socket_->ReceivePacket(dest1_, request_packet); | 231 socket_->ReceivePacket(dest1_, request_packet); |
| 230 | 232 |
| 231 // Should fail when trying to send the same packet to |dest2_|. | 233 // Should fail when trying to send the same packet to |dest2_|. |
| 232 std::vector<char> packet; | 234 std::vector<char> packet; |
| 233 CreateRandomPacket(&packet); | 235 CreateRandomPacket(&packet); |
| 234 EXPECT_CALL(sender_, Send( | 236 EXPECT_CALL(sender_, Send( |
| 235 MatchMessage(static_cast<uint32>(P2PMsg_OnError::ID)))) | 237 MatchMessage(static_cast<uint32>(P2PMsg_OnError::ID)))) |
| 236 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 238 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
| 237 socket_host_->Send(dest2_, packet); | 239 socket_host_->Send(dest2_, packet); |
| 238 } | 240 } |
| 241 |
| 242 } // namespace content |
| OLD | NEW |