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" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 std::vector<char> packet; | 333 std::vector<char> packet; |
334 CreateRandomPacket(&packet); | 334 CreateRandomPacket(&packet); |
335 socket_host_->Send(dest_, packet); | 335 socket_host_->Send(dest_, packet); |
336 | 336 |
337 EXPECT_EQ(0U, sent_data_.size()); | 337 EXPECT_EQ(0U, sent_data_.size()); |
338 } | 338 } |
339 | 339 |
340 // Verify that asynchronous writes are handled correctly. | 340 // Verify that asynchronous writes are handled correctly. |
341 TEST_F(P2PSocketHostStunTcpTest, AsyncWrites) { | 341 TEST_F(P2PSocketHostStunTcpTest, AsyncWrites) { |
342 MessageLoop message_loop; | 342 base::MessageLoop message_loop; |
343 | 343 |
344 socket_->set_async_write(true); | 344 socket_->set_async_write(true); |
345 | 345 |
346 EXPECT_CALL(sender_, Send( | 346 EXPECT_CALL(sender_, Send( |
347 MatchMessage(static_cast<uint32>(P2PMsg_OnSendComplete::ID)))) | 347 MatchMessage(static_cast<uint32>(P2PMsg_OnSendComplete::ID)))) |
348 .Times(2) | 348 .Times(2) |
349 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true))); | 349 .WillRepeatedly(DoAll(DeleteArg<0>(), Return(true))); |
350 | 350 |
351 std::vector<char> packet1; | 351 std::vector<char> packet1; |
352 CreateStunRequest(&packet1); | 352 CreateStunRequest(&packet1); |
353 socket_host_->Send(dest_, packet1); | 353 socket_host_->Send(dest_, packet1); |
354 | 354 |
355 std::vector<char> packet2; | 355 std::vector<char> packet2; |
356 CreateStunResponse(&packet2); | 356 CreateStunResponse(&packet2); |
357 socket_host_->Send(dest_, packet2); | 357 socket_host_->Send(dest_, packet2); |
358 | 358 |
359 message_loop.RunUntilIdle(); | 359 message_loop.RunUntilIdle(); |
360 | 360 |
361 std::string expected_data; | 361 std::string expected_data; |
362 expected_data.append(packet1.begin(), packet1.end()); | 362 expected_data.append(packet1.begin(), packet1.end()); |
363 expected_data.append(packet2.begin(), packet2.end()); | 363 expected_data.append(packet2.begin(), packet2.end()); |
364 | 364 |
365 EXPECT_EQ(expected_data, sent_data_); | 365 EXPECT_EQ(expected_data, sent_data_); |
366 } | 366 } |
367 | 367 |
368 } // namespace content | 368 } // namespace content |
OLD | NEW |