| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/net/udp_transport.h" | 5 #include "media/cast/net/udp_transport.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "media/cast/net/cast_transport_config.h" | 16 #include "media/cast/net/cast_transport_config.h" |
| 17 #include "media/cast/test/utility/net_utility.h" | 17 #include "media/cast/test/utility/net_utility.h" |
| 18 #include "net/base/ip_address.h" | 18 #include "net/base/ip_address.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 namespace cast { | 22 namespace cast { |
| 23 | 23 |
| 24 class MockPacketReceiver { | 24 class MockPacketReceiver { |
| 25 public: | 25 public: |
| 26 MockPacketReceiver(const base::Closure& callback) | 26 MockPacketReceiver(const base::Closure& callback) |
| 27 : packet_callback_(callback) {} | 27 : packet_callback_(callback) {} |
| 28 | 28 |
| 29 bool ReceivedPacket(scoped_ptr<Packet> packet) { | 29 bool ReceivedPacket(std::unique_ptr<Packet> packet) { |
| 30 packet_ = std::string(packet->size(), '\0'); | 30 packet_ = std::string(packet->size(), '\0'); |
| 31 std::copy(packet->begin(), packet->end(), packet_.begin()); | 31 std::copy(packet->begin(), packet->end(), packet_.begin()); |
| 32 packet_callback_.Run(); | 32 packet_callback_.Run(); |
| 33 return true; | 33 return true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string packet() const { return packet_; } | 36 std::string packet() const { return packet_; } |
| 37 PacketReceiverCallbackWithStatus packet_receiver() { | 37 PacketReceiverCallbackWithStatus packet_receiver() { |
| 38 return base::Bind(&MockPacketReceiver::ReceivedPacket, | 38 return base::Bind(&MockPacketReceiver::ReceivedPacket, |
| 39 base::Unretained(this)); | 39 base::Unretained(this)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 send_transport.SendPacket(new base::RefCountedData<Packet>(packet), cb); | 90 send_transport.SendPacket(new base::RefCountedData<Packet>(packet), cb); |
| 91 run_loop.Run(); | 91 run_loop.Run(); |
| 92 EXPECT_TRUE( | 92 EXPECT_TRUE( |
| 93 std::equal(packet.begin(), packet.end(), receiver1.packet().begin())); | 93 std::equal(packet.begin(), packet.end(), receiver1.packet().begin())); |
| 94 EXPECT_TRUE( | 94 EXPECT_TRUE( |
| 95 std::equal(packet.begin(), packet.end(), receiver2.packet().begin())); | 95 std::equal(packet.begin(), packet.end(), receiver2.packet().begin())); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace cast | 98 } // namespace cast |
| 99 } // namespace media | 99 } // namespace media |
| OLD | NEW |