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_tcp_server.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 9 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 virtual void SetUp() OVERRIDE { | 92 virtual void SetUp() OVERRIDE { |
93 socket_ = new FakeServerSocket(); | 93 socket_ = new FakeServerSocket(); |
94 socket_host_.reset(new P2PSocketHostTcpServer( | 94 socket_host_.reset(new P2PSocketHostTcpServer( |
95 &sender_, 0, P2P_SOCKET_TCP_CLIENT)); | 95 &sender_, 0, P2P_SOCKET_TCP_CLIENT)); |
96 socket_host_->socket_.reset(socket_); | 96 socket_host_->socket_.reset(socket_); |
97 | 97 |
98 EXPECT_CALL(sender_, Send( | 98 EXPECT_CALL(sender_, Send( |
99 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 99 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
100 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 100 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
101 | 101 |
| 102 P2PHostAndIPEndPoint dest; |
| 103 dest.ip_address = ParseAddress(kTestIpAddress1, kTestPort1); |
| 104 |
102 socket_host_->Init(ParseAddress(kTestLocalIpAddress, 0), | 105 socket_host_->Init(ParseAddress(kTestLocalIpAddress, 0), |
103 ParseAddress(kTestIpAddress1, kTestPort1)); | 106 dest); |
104 EXPECT_TRUE(socket_->listening()); | 107 EXPECT_TRUE(socket_->listening()); |
105 } | 108 } |
106 | 109 |
107 // Needed by the chilt classes because only this class is a friend | 110 // Needed by the chilt classes because only this class is a friend |
108 // of P2PSocketHostTcp. | 111 // of P2PSocketHostTcp. |
109 net::StreamSocket* GetSocketFormTcpSocketHost(P2PSocketHostTcp* host) { | 112 net::StreamSocket* GetSocketFormTcpSocketHost(P2PSocketHostTcp* host) { |
110 return host->socket_.get(); | 113 return host->socket_.get(); |
111 } | 114 } |
112 | 115 |
113 MockIPCSender sender_; | 116 MockIPCSender sender_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( | 165 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( |
163 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); | 166 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); |
164 scoped_ptr<P2PSocketHost> new_host2( | 167 scoped_ptr<P2PSocketHost> new_host2( |
165 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); | 168 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); |
166 ASSERT_TRUE(new_host2.get() != NULL); | 169 ASSERT_TRUE(new_host2.get() != NULL); |
167 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost( | 170 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost( |
168 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get()))); | 171 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get()))); |
169 } | 172 } |
170 | 173 |
171 } // namespace content | 174 } // namespace content |
OLD | NEW |