| 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_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 "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.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" |
| 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 { | 20 namespace content { |
| 21 | 21 |
| 22 class P2PSocketHostTcpTestBase : public testing::Test { | 22 class P2PSocketHostTcpTestBase : public testing::Test { |
| 23 protected: | 23 protected: |
| 24 explicit P2PSocketHostTcpTestBase(P2PSocketType type) | 24 explicit P2PSocketHostTcpTestBase(P2PSocketType type) |
| 25 : socket_type_(type) { | 25 : socket_type_(type) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() override { |
| 29 EXPECT_CALL(sender_, Send( | 29 EXPECT_CALL(sender_, Send( |
| 30 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) | 30 MatchMessage(static_cast<uint32>(P2PMsg_OnSocketCreated::ID)))) |
| 31 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); | 31 .WillOnce(DoAll(DeleteArg<0>(), Return(true))); |
| 32 | 32 |
| 33 if (socket_type_ == P2P_SOCKET_TCP_CLIENT) { | 33 if (socket_type_ == P2P_SOCKET_TCP_CLIENT) { |
| 34 socket_host_.reset( | 34 socket_host_.reset( |
| 35 new P2PSocketHostTcp(&sender_, 0, P2P_SOCKET_TCP_CLIENT, NULL)); | 35 new P2PSocketHostTcp(&sender_, 0, P2P_SOCKET_TCP_CLIENT, NULL)); |
| 36 } else { | 36 } else { |
| 37 socket_host_.reset(new P2PSocketHostStunTcp( | 37 socket_host_.reset(new P2PSocketHostStunTcp( |
| 38 &sender_, 0, P2P_SOCKET_STUN_TCP_CLIENT, NULL)); | 38 &sender_, 0, P2P_SOCKET_STUN_TCP_CLIENT, NULL)); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 message_loop.RunUntilIdle(); | 382 message_loop.RunUntilIdle(); |
| 383 | 383 |
| 384 std::string expected_data; | 384 std::string expected_data; |
| 385 expected_data.append(packet1.begin(), packet1.end()); | 385 expected_data.append(packet1.begin(), packet1.end()); |
| 386 expected_data.append(packet2.begin(), packet2.end()); | 386 expected_data.append(packet2.begin(), packet2.end()); |
| 387 | 387 |
| 388 EXPECT_EQ(expected_data, sent_data_); | 388 EXPECT_EQ(expected_data, sent_data_); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace content | 391 } // namespace content |
| OLD | NEW |