| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
| 10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // must remain alive until after its destruction. | 114 // must remain alive until after its destruction. |
| 115 scoped_ptr<VideoReceiver> receiver_; | 115 scoped_ptr<VideoReceiver> receiver_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); | 117 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 TEST_F(VideoReceiverTest, GetOnePacketEncodedFrame) { | 120 TEST_F(VideoReceiverTest, GetOnePacketEncodedFrame) { |
| 121 SimpleEventSubscriber event_subscriber; | 121 SimpleEventSubscriber event_subscriber; |
| 122 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); | 122 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); |
| 123 | 123 |
| 124 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) | 124 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _)) |
| 125 .WillRepeatedly(testing::Return(true)); | 125 .WillRepeatedly(testing::Return(true)); |
| 126 | 126 |
| 127 // Enqueue a request for a video frame. | 127 // Enqueue a request for a video frame. |
| 128 receiver_->GetEncodedVideoFrame( | 128 receiver_->GetEncodedVideoFrame( |
| 129 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, | 129 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, |
| 130 base::Unretained(&fake_video_client_))); | 130 base::Unretained(&fake_video_client_))); |
| 131 | 131 |
| 132 // The request should not be satisfied since no packets have been received. | 132 // The request should not be satisfied since no packets have been received. |
| 133 task_runner_->RunTasks(); | 133 task_runner_->RunTasks(); |
| 134 EXPECT_EQ(0, fake_video_client_.number_times_called()); | 134 EXPECT_EQ(0, fake_video_client_.number_times_called()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 145 | 145 |
| 146 ASSERT_TRUE(!frame_events.empty()); | 146 ASSERT_TRUE(!frame_events.empty()); |
| 147 EXPECT_EQ(kVideoAckSent, frame_events.begin()->type); | 147 EXPECT_EQ(kVideoAckSent, frame_events.begin()->type); |
| 148 EXPECT_EQ(rtp_header_.frame_id, frame_events.begin()->frame_id); | 148 EXPECT_EQ(rtp_header_.frame_id, frame_events.begin()->frame_id); |
| 149 EXPECT_EQ(rtp_header_.rtp_timestamp, frame_events.begin()->rtp_timestamp); | 149 EXPECT_EQ(rtp_header_.rtp_timestamp, frame_events.begin()->rtp_timestamp); |
| 150 | 150 |
| 151 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); | 151 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(VideoReceiverTest, MultiplePendingGetCalls) { | 154 TEST_F(VideoReceiverTest, MultiplePendingGetCalls) { |
| 155 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) | 155 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _)) |
| 156 .WillRepeatedly(testing::Return(true)); | 156 .WillRepeatedly(testing::Return(true)); |
| 157 | 157 |
| 158 // Enqueue a request for an video frame. | 158 // Enqueue a request for an video frame. |
| 159 const VideoFrameEncodedCallback frame_encoded_callback = | 159 const VideoFrameEncodedCallback frame_encoded_callback = |
| 160 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, | 160 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, |
| 161 base::Unretained(&fake_video_client_)); | 161 base::Unretained(&fake_video_client_)); |
| 162 receiver_->GetEncodedVideoFrame(frame_encoded_callback); | 162 receiver_->GetEncodedVideoFrame(frame_encoded_callback); |
| 163 task_runner_->RunTasks(); | 163 task_runner_->RunTasks(); |
| 164 EXPECT_EQ(0, fake_video_client_.number_times_called()); | 164 EXPECT_EQ(0, fake_video_client_.number_times_called()); |
| 165 | 165 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Move forward another |rtp_max_delay_ms| and run any pending tasks (there | 223 // Move forward another |rtp_max_delay_ms| and run any pending tasks (there |
| 224 // should be none). Expect no additional frames where emitted. | 224 // should be none). Expect no additional frames where emitted. |
| 225 testing_clock_->Advance( | 225 testing_clock_->Advance( |
| 226 base::TimeDelta::FromMilliseconds(config_.rtp_max_delay_ms)); | 226 base::TimeDelta::FromMilliseconds(config_.rtp_max_delay_ms)); |
| 227 task_runner_->RunTasks(); | 227 task_runner_->RunTasks(); |
| 228 EXPECT_EQ(3, fake_video_client_.number_times_called()); | 228 EXPECT_EQ(3, fake_video_client_.number_times_called()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace cast | 231 } // namespace cast |
| 232 } // namespace media | 232 } // namespace media |
| OLD | NEW |