| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // must remain alive until after its destruction. | 116 // must remain alive until after its destruction. |
| 117 scoped_ptr<VideoReceiver> receiver_; | 117 scoped_ptr<VideoReceiver> receiver_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); | 119 DISALLOW_COPY_AND_ASSIGN(VideoReceiverTest); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 TEST_F(VideoReceiverTest, GetOnePacketEncodedFrame) { | 122 TEST_F(VideoReceiverTest, GetOnePacketEncodedFrame) { |
| 123 SimpleEventSubscriber event_subscriber; | 123 SimpleEventSubscriber event_subscriber; |
| 124 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); | 124 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber); |
| 125 | 125 |
| 126 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) | 126 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _)) |
| 127 .WillRepeatedly(testing::Return(true)); | 127 .WillRepeatedly(testing::Return(true)); |
| 128 | 128 |
| 129 // Enqueue a request for a video frame. | 129 // Enqueue a request for a video frame. |
| 130 receiver_->GetEncodedVideoFrame( | 130 receiver_->GetEncodedVideoFrame( |
| 131 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, | 131 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, |
| 132 base::Unretained(&fake_video_client_))); | 132 base::Unretained(&fake_video_client_))); |
| 133 | 133 |
| 134 // The request should not be satisfied since no packets have been received. | 134 // The request should not be satisfied since no packets have been received. |
| 135 task_runner_->RunTasks(); | 135 task_runner_->RunTasks(); |
| 136 EXPECT_EQ(0, fake_video_client_.number_times_called()); | 136 EXPECT_EQ(0, fake_video_client_.number_times_called()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 ASSERT_TRUE(!frame_events.empty()); | 148 ASSERT_TRUE(!frame_events.empty()); |
| 149 EXPECT_EQ(kVideoAckSent, frame_events.begin()->type); | 149 EXPECT_EQ(kVideoAckSent, frame_events.begin()->type); |
| 150 EXPECT_EQ(rtp_header_.frame_id, frame_events.begin()->frame_id); | 150 EXPECT_EQ(rtp_header_.frame_id, frame_events.begin()->frame_id); |
| 151 EXPECT_EQ(rtp_header_.webrtc.header.timestamp, | 151 EXPECT_EQ(rtp_header_.webrtc.header.timestamp, |
| 152 frame_events.begin()->rtp_timestamp); | 152 frame_events.begin()->rtp_timestamp); |
| 153 | 153 |
| 154 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); | 154 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); |
| 155 } | 155 } |
| 156 | 156 |
| 157 TEST_F(VideoReceiverTest, MultiplePendingGetCalls) { | 157 TEST_F(VideoReceiverTest, MultiplePendingGetCalls) { |
| 158 EXPECT_CALL(mock_transport_, SendRtcpPacket(_)) | 158 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _)) |
| 159 .WillRepeatedly(testing::Return(true)); | 159 .WillRepeatedly(testing::Return(true)); |
| 160 | 160 |
| 161 // Enqueue a request for an video frame. | 161 // Enqueue a request for an video frame. |
| 162 const VideoFrameEncodedCallback frame_encoded_callback = | 162 const VideoFrameEncodedCallback frame_encoded_callback = |
| 163 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, | 163 base::Bind(&FakeVideoClient::DeliverEncodedVideoFrame, |
| 164 base::Unretained(&fake_video_client_)); | 164 base::Unretained(&fake_video_client_)); |
| 165 receiver_->GetEncodedVideoFrame(frame_encoded_callback); | 165 receiver_->GetEncodedVideoFrame(frame_encoded_callback); |
| 166 task_runner_->RunTasks(); | 166 task_runner_->RunTasks(); |
| 167 EXPECT_EQ(0, fake_video_client_.number_times_called()); | 167 EXPECT_EQ(0, fake_video_client_.number_times_called()); |
| 168 | 168 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Move forward another |rtp_max_delay_ms| and run any pending tasks (there | 229 // Move forward another |rtp_max_delay_ms| and run any pending tasks (there |
| 230 // should be none). Expect no additional frames where emitted. | 230 // should be none). Expect no additional frames where emitted. |
| 231 testing_clock_->Advance( | 231 testing_clock_->Advance( |
| 232 base::TimeDelta::FromMilliseconds(config_.rtp_max_delay_ms)); | 232 base::TimeDelta::FromMilliseconds(config_.rtp_max_delay_ms)); |
| 233 task_runner_->RunTasks(); | 233 task_runner_->RunTasks(); |
| 234 EXPECT_EQ(3, fake_video_client_.number_times_called()); | 234 EXPECT_EQ(3, fake_video_client_.number_times_called()); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace cast | 237 } // namespace cast |
| 238 } // namespace media | 238 } // namespace media |
| OLD | NEW |