OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 int recv_size_; | 162 int recv_size_; |
163 net::CompletionCallback recv_callback_; | 163 net::CompletionCallback recv_callback_; |
164 }; | 164 }; |
165 | 165 |
166 } // namespace | 166 } // namespace |
167 | 167 |
168 namespace content { | 168 namespace content { |
169 | 169 |
170 class P2PSocketHostUdpTest : public testing::Test { | 170 class P2PSocketHostUdpTest : public testing::Test { |
171 protected: | 171 protected: |
172 virtual void SetUp() override { | 172 void SetUp() override { |
173 EXPECT_CALL(sender_, Send( | 173 EXPECT_CALL(sender_, Send( |
174 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 174 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
175 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 175 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
176 | 176 |
177 socket_host_.reset(new P2PSocketHostUdp(&sender_, 0, &throttler_)); | 177 socket_host_.reset(new P2PSocketHostUdp(&sender_, 0, &throttler_)); |
178 socket_ = new FakeDatagramServerSocket(&sent_packets_); | 178 socket_ = new FakeDatagramServerSocket(&sent_packets_); |
179 socket_host_->socket_.reset(socket_); | 179 socket_host_->socket_.reset(socket_); |
180 | 180 |
181 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); | 181 local_address_ = ParseAddress(kTestLocalIpAddress, kTestPort1); |
182 socket_host_->Init(local_address_, P2PHostAndIPEndPoint()); | 182 socket_host_->Init(local_address_, P2PHostAndIPEndPoint()); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 socket_host_->Send(dest3, packet1, options, 0); | 367 socket_host_->Send(dest3, packet1, options, 0); |
368 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); | 368 net::IPEndPoint dest4 = ParseAddress(kTestIpAddress1, 2224); |
369 // This packet should also be dropped. | 369 // This packet should also be dropped. |
370 socket_host_->Send(dest4, packet1, options, 0); | 370 socket_host_->Send(dest4, packet1, options, 0); |
371 // |dest1| is known, we can send as many packets to it. | 371 // |dest1| is known, we can send as many packets to it. |
372 socket_host_->Send(dest1_, packet1, options, 0); | 372 socket_host_->Send(dest1_, packet1, options, 0); |
373 ASSERT_EQ(sent_packets_.size(), 4U); | 373 ASSERT_EQ(sent_packets_.size(), 4U); |
374 } | 374 } |
375 | 375 |
376 } // namespace content | 376 } // namespace content |
OLD | NEW |