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 "content/browser/renderer_host/p2p/socket_host_tcp.h" | 7 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
8 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 8 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 net::IPEndPoint local_address_; | 73 net::IPEndPoint local_address_; |
74 | 74 |
75 scoped_ptr<net::StreamSocket>* accept_socket_; | 75 scoped_ptr<net::StreamSocket>* accept_socket_; |
76 net::CompletionCallback* accept_callback_; | 76 net::CompletionCallback* accept_callback_; |
77 | 77 |
78 std::list<net::StreamSocket*> incoming_sockets_; | 78 std::list<net::StreamSocket*> incoming_sockets_; |
79 }; | 79 }; |
80 | 80 |
81 } // namespace | 81 } // namespace |
82 | 82 |
| 83 namespace content { |
| 84 |
83 class P2PSocketHostTcpServerTest : public testing::Test { | 85 class P2PSocketHostTcpServerTest : public testing::Test { |
84 protected: | 86 protected: |
85 virtual void SetUp() OVERRIDE { | 87 virtual void SetUp() OVERRIDE { |
86 socket_ = new FakeServerSocket(); | 88 socket_ = new FakeServerSocket(); |
87 socket_host_.reset(new P2PSocketHostTcpServer(&sender_, 0, 0)); | 89 socket_host_.reset(new P2PSocketHostTcpServer(&sender_, 0, 0)); |
88 socket_host_->socket_.reset(socket_); | 90 socket_host_->socket_.reset(socket_); |
89 | 91 |
90 EXPECT_CALL(sender_, Send( | 92 EXPECT_CALL(sender_, Send( |
91 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 93 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
92 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 94 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 socket_host_->AcceptIncomingTcpConnection(addr1, kAcceptedSocketId1)); | 154 socket_host_->AcceptIncomingTcpConnection(addr1, kAcceptedSocketId1)); |
153 ASSERT_TRUE(new_host1.get() != NULL); | 155 ASSERT_TRUE(new_host1.get() != NULL); |
154 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( | 156 EXPECT_EQ(incoming1, GetSocketFormTcpSocketHost( |
155 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); | 157 reinterpret_cast<P2PSocketHostTcp*>(new_host1.get()))); |
156 scoped_ptr<P2PSocketHost> new_host2( | 158 scoped_ptr<P2PSocketHost> new_host2( |
157 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); | 159 socket_host_->AcceptIncomingTcpConnection(addr2, kAcceptedSocketId2)); |
158 ASSERT_TRUE(new_host2.get() != NULL); | 160 ASSERT_TRUE(new_host2.get() != NULL); |
159 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost( | 161 EXPECT_EQ(incoming2, GetSocketFormTcpSocketHost( |
160 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get()))); | 162 reinterpret_cast<P2PSocketHostTcp*>(new_host2.get()))); |
161 } | 163 } |
| 164 |
| 165 } // namespace content |
OLD | NEW |