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" |
11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/base/sys_byteorder.h" | 14 #include "net/base/sys_byteorder.h" |
15 #include "net/udp/datagram_server_socket.h" | 15 #include "net/udp/datagram_server_socket.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using ::testing::_; | 19 using ::testing::_; |
20 using ::testing::DeleteArg; | 20 using ::testing::DeleteArg; |
21 using ::testing::DoAll; | 21 using ::testing::DoAll; |
22 using ::testing::Return; | 22 using ::testing::Return; |
23 | 23 |
24 namespace content { | |
25 | |
24 namespace { | 26 namespace { |
jam
2011/08/24 00:24:27
ditto
Sergey Ulanov
2011/08/24 01:57:48
Done.
| |
25 | 27 |
26 class FakeDatagramServerSocket : public net::DatagramServerSocket { | 28 class FakeDatagramServerSocket : public net::DatagramServerSocket { |
27 public: | 29 public: |
28 typedef std::pair<net::IPEndPoint, std::vector<char> > UDPPacket; | 30 typedef std::pair<net::IPEndPoint, std::vector<char> > UDPPacket; |
29 | 31 |
30 // P2PSocketHostUdp destroyes a socket on errors so sent packets | 32 // P2PSocketHostUdp destroyes a socket on errors so sent packets |
31 // need to be stored outside of this object. | 33 // need to be stored outside of this object. |
32 explicit FakeDatagramServerSocket(std::deque<UDPPacket>* sent_packets) | 34 explicit FakeDatagramServerSocket(std::deque<UDPPacket>* sent_packets) |
33 : sent_packets_(sent_packets), recv_callback_(NULL) { | 35 : sent_packets_(sent_packets), recv_callback_(NULL) { |
34 } | 36 } |
(...skipping 194 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 |