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.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 | 8 |
9 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 9 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
10 #include "net/base/sys_byteorder.h" | 10 #include "net/base/sys_byteorder.h" |
11 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using ::testing::_; | 15 using ::testing::_; |
16 using ::testing::DeleteArg; | 16 using ::testing::DeleteArg; |
17 using ::testing::DoAll; | 17 using ::testing::DoAll; |
18 using ::testing::Return; | 18 using ::testing::Return; |
19 | 19 |
20 namespace content { | |
jam
2011/08/24 00:24:27
ditto
Sergey Ulanov
2011/08/24 01:57:48
Not sure what's wrong here.
jam
2011/08/24 16:30:53
oops sorry that was by mistake
| |
21 | |
20 class P2PSocketHostTcpTest : public testing::Test { | 22 class P2PSocketHostTcpTest : public testing::Test { |
21 protected: | 23 protected: |
22 virtual void SetUp() OVERRIDE { | 24 virtual void SetUp() OVERRIDE { |
23 EXPECT_CALL(sender_, Send( | 25 EXPECT_CALL(sender_, Send( |
24 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 26 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
25 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 27 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
26 | 28 |
27 socket_host_.reset(new P2PSocketHostTcp(&sender_, 0, 0)); | 29 socket_host_.reset(new P2PSocketHostTcp(&sender_, 0, 0)); |
28 socket_ = new FakeSocket(&sent_data_); | 30 socket_ = new FakeSocket(&sent_data_); |
29 socket_->SetLocalAddress(ParseAddress(kTestLocalIpAddress, kTestPort1)); | 31 socket_->SetLocalAddress(ParseAddress(kTestLocalIpAddress, kTestPort1)); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 std::vector<char> packet; | 160 std::vector<char> packet; |
159 CreateRandomPacket(&packet); | 161 CreateRandomPacket(&packet); |
160 socket_host_->Send(dest_, packet); | 162 socket_host_->Send(dest_, packet); |
161 | 163 |
162 std::string expected_data; | 164 std::string expected_data; |
163 expected_data.append(IntToSize(packet.size())); | 165 expected_data.append(IntToSize(packet.size())); |
164 expected_data.append(packet.begin(), packet.end()); | 166 expected_data.append(packet.begin(), packet.end()); |
165 | 167 |
166 EXPECT_EQ(expected_data, sent_data_); | 168 EXPECT_EQ(expected_data, sent_data_); |
167 } | 169 } |
170 | |
171 } // namespace content | |
OLD | NEW |