| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/protocol/client_video_dispatcher.h" | 5 #include "remoting/protocol/client_video_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace remoting { | 22 namespace remoting { |
| 23 namespace protocol { | 23 namespace protocol { |
| 24 | 24 |
| 25 class ClientVideoDispatcherTest : public testing::Test, | 25 class ClientVideoDispatcherTest : public testing::Test, |
| 26 public VideoStub, | 26 public VideoStub, |
| 27 public ChannelDispatcherBase::EventHandler { | 27 public ChannelDispatcherBase::EventHandler { |
| 28 public: | 28 public: |
| 29 ClientVideoDispatcherTest(); | 29 ClientVideoDispatcherTest(); |
| 30 | 30 |
| 31 // VideoStub interface. | 31 // VideoStub interface. |
| 32 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 32 void ProcessVideoPacket(std::unique_ptr<VideoPacket> video_packet, |
| 33 const base::Closure& done) override; | 33 const base::Closure& done) override; |
| 34 | 34 |
| 35 // ChannelDispatcherBase::EventHandler interface. | 35 // ChannelDispatcherBase::EventHandler interface. |
| 36 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; | 36 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 void OnChannelError(int error); | 39 void OnChannelError(int error); |
| 40 | 40 |
| 41 void OnMessageReceived(scoped_ptr<CompoundBuffer> buffer); | 41 void OnMessageReceived(std::unique_ptr<CompoundBuffer> buffer); |
| 42 void OnReadError(int error); | 42 void OnReadError(int error); |
| 43 | 43 |
| 44 base::MessageLoop message_loop_; | 44 base::MessageLoop message_loop_; |
| 45 | 45 |
| 46 // Set to true in OnChannelInitialized(). | 46 // Set to true in OnChannelInitialized(). |
| 47 bool initialized_ = false; | 47 bool initialized_ = false; |
| 48 | 48 |
| 49 // Client side. | 49 // Client side. |
| 50 FakeStreamChannelFactory client_channel_factory_; | 50 FakeStreamChannelFactory client_channel_factory_; |
| 51 StreamMessageChannelFactoryAdapter channel_factory_adapter_; | 51 StreamMessageChannelFactoryAdapter channel_factory_adapter_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 78 base::Bind(&ClientVideoDispatcherTest::OnMessageReceived, | 78 base::Bind(&ClientVideoDispatcherTest::OnMessageReceived, |
| 79 base::Unretained(this)), | 79 base::Unretained(this)), |
| 80 base::Bind(&ClientVideoDispatcherTest::OnReadError, | 80 base::Bind(&ClientVideoDispatcherTest::OnReadError, |
| 81 base::Unretained(this))); | 81 base::Unretained(this))); |
| 82 writer_.Start( | 82 writer_.Start( |
| 83 base::Bind(&P2PStreamSocket::Write, base::Unretained(&host_socket_)), | 83 base::Bind(&P2PStreamSocket::Write, base::Unretained(&host_socket_)), |
| 84 BufferedSocketWriter::WriteFailedCallback()); | 84 BufferedSocketWriter::WriteFailedCallback()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ClientVideoDispatcherTest::ProcessVideoPacket( | 87 void ClientVideoDispatcherTest::ProcessVideoPacket( |
| 88 scoped_ptr<VideoPacket> video_packet, | 88 std::unique_ptr<VideoPacket> video_packet, |
| 89 const base::Closure& done) { | 89 const base::Closure& done) { |
| 90 video_packets_.push_back(video_packet.release()); | 90 video_packets_.push_back(video_packet.release()); |
| 91 packet_done_callbacks_.push_back(done); | 91 packet_done_callbacks_.push_back(done); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ClientVideoDispatcherTest::OnChannelInitialized( | 94 void ClientVideoDispatcherTest::OnChannelInitialized( |
| 95 ChannelDispatcherBase* channel_dispatcher) { | 95 ChannelDispatcherBase* channel_dispatcher) { |
| 96 initialized_ = true; | 96 initialized_ = true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ClientVideoDispatcherTest::OnChannelError(int error) { | 99 void ClientVideoDispatcherTest::OnChannelError(int error) { |
| 100 // Don't expect channel creation to fail. | 100 // Don't expect channel creation to fail. |
| 101 FAIL(); | 101 FAIL(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ClientVideoDispatcherTest::OnMessageReceived( | 104 void ClientVideoDispatcherTest::OnMessageReceived( |
| 105 scoped_ptr<CompoundBuffer> buffer) { | 105 std::unique_ptr<CompoundBuffer> buffer) { |
| 106 scoped_ptr<VideoAck> ack = ParseMessage<VideoAck>(buffer.get()); | 106 std::unique_ptr<VideoAck> ack = ParseMessage<VideoAck>(buffer.get()); |
| 107 EXPECT_TRUE(ack); | 107 EXPECT_TRUE(ack); |
| 108 ack_messages_.push_back(ack.release()); | 108 ack_messages_.push_back(ack.release()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void ClientVideoDispatcherTest::OnReadError(int error) { | 111 void ClientVideoDispatcherTest::OnReadError(int error) { |
| 112 LOG(FATAL) << "Unexpected read error: " << error; | 112 LOG(FATAL) << "Unexpected read error: " << error; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Verify that the client can receive video packets and acks are not sent for | 115 // Verify that the client can receive video packets and acks are not sent for |
| 116 // VideoPackets that don't have frame_id field set. | 116 // VideoPackets that don't have frame_id field set. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 base::RunLoop().RunUntilIdle(); | 213 base::RunLoop().RunUntilIdle(); |
| 214 | 214 |
| 215 // Verify order of Ack messages. | 215 // Verify order of Ack messages. |
| 216 ASSERT_EQ(2U, ack_messages_.size()); | 216 ASSERT_EQ(2U, ack_messages_.size()); |
| 217 EXPECT_EQ(kTestFrameId, ack_messages_[0]->frame_id()); | 217 EXPECT_EQ(kTestFrameId, ack_messages_[0]->frame_id()); |
| 218 EXPECT_EQ(kTestFrameId + 1, ack_messages_[1]->frame_id()); | 218 EXPECT_EQ(kTestFrameId + 1, ack_messages_[1]->frame_id()); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace protocol | 221 } // namespace protocol |
| 222 } // namespace remoting | 222 } // namespace remoting |
| OLD | NEW |