Chromium Code Reviews| Index: remoting/protocol/connection_unittest.cc |
| diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc |
| index 6e96e3bcb46d32d061601908f2a992f13ba6a795..e4aadcb48ad0673d6dd944b3d03852d766f73b0e 100644 |
| --- a/remoting/protocol/connection_unittest.cc |
| +++ b/remoting/protocol/connection_unittest.cc |
| @@ -75,13 +75,17 @@ class TestScreenCapturer : public webrtc::DesktopCapturer { |
| std::unique_ptr<webrtc::DesktopFrame> frame( |
| new webrtc::BasicDesktopFrame(webrtc::DesktopSize(100, 100))); |
| memset(frame->data(), 0, frame->stride() * frame->size().height()); |
| - frame->mutable_updated_region()->SetRect( |
| - webrtc::DesktopRect::MakeSize(frame->size())); |
| + if (!first_frame_sent_) { |
| + first_frame_sent_ = true; |
|
Irfan
2016/06/02 19:06:00
Can you please explain what this does ?
Sergey Ulanov
2016/06/03 06:01:23
added a comment.
|
| + frame->mutable_updated_region()->SetRect( |
| + webrtc::DesktopRect::MakeSize(frame->size())); |
| + } |
| callback_->OnCaptureCompleted(frame.release()); |
| } |
| private: |
| Callback* callback_ = nullptr; |
| + bool first_frame_sent_ = false; |
| }; |
| } // namespace |
| @@ -188,6 +192,36 @@ class ConnectionTest : public testing::Test, |
| run_loop_->Quit(); |
| } |
| + void WaitFirstVideoFrame() { |
| + base::RunLoop run_loop; |
| + |
| + // Expect frames to be passed to FrameConsumer when WebRTC is used, or to |
| + // VideoStub otherwise. |
| + if (is_using_webrtc()) { |
| + client_video_renderer_.GetFrameConsumer()->set_on_frame_callback( |
| + base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop))); |
| + } else { |
| + client_video_renderer_.GetVideoStub()->set_on_frame_callback( |
| + base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop))); |
| + } |
| + |
| + run_loop.Run(); |
| + |
| + if (is_using_webrtc()) { |
| + EXPECT_EQ( |
| + client_video_renderer_.GetFrameConsumer()->received_frames().size(), |
| + 1U); |
| + EXPECT_EQ( |
| + client_video_renderer_.GetVideoStub()->received_packets().size(), 0U); |
| + } else { |
| + EXPECT_EQ( |
| + client_video_renderer_.GetFrameConsumer()->received_frames().size(), |
| + 0U); |
| + EXPECT_EQ( |
| + client_video_renderer_.GetVideoStub()->received_packets().size(), 1U); |
| + } |
| + } |
| + |
| base::MessageLoopForIO message_loop_; |
| std::unique_ptr<base::RunLoop> run_loop_; |
| @@ -285,34 +319,21 @@ TEST_P(ConnectionTest, Video) { |
| host_connection_->StartVideoStream( |
| base::WrapUnique(new TestScreenCapturer())); |
| - base::RunLoop run_loop; |
| + WaitFirstVideoFrame(); |
| +} |
| - // Expect frames to be passed to FrameConsumer when WebRTC is used, or to |
| - // VideoStub otherwise. |
| - if (is_using_webrtc()) { |
| - client_video_renderer_.GetFrameConsumer()->set_on_frame_callback( |
| - base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop))); |
| - } else { |
| - client_video_renderer_.GetVideoStub()->set_on_frame_callback( |
| - base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop))); |
| - } |
| +TEST_P(ConnectionTest, VideoAfterIceDelay) { |
| + // Add signaling delay to slow down ICE. |
| + host_session_->set_signaling_delay(base::TimeDelta::FromMilliseconds(200)); |
|
Irfan
2016/06/02 19:06:00
Comment seems to indicate this is ICE specific, bu
Sergey Ulanov
2016/06/03 06:01:23
ICE is used internally it WebRTC too. But this com
|
| + client_session_->set_signaling_delay(base::TimeDelta::FromMilliseconds(200)); |
| - run_loop.Run(); |
| + Connect(); |
| - if (is_using_webrtc()) { |
| - EXPECT_EQ( |
| - client_video_renderer_.GetFrameConsumer()->received_frames().size(), |
| - 1U); |
| - EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(), |
| - 0U); |
| - } else { |
| - EXPECT_EQ( |
| - client_video_renderer_.GetFrameConsumer()->received_frames().size(), |
| - 0U); |
| - EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(), |
| - 1U); |
| - } |
| + std::unique_ptr<VideoStream> video_stream = |
| + host_connection_->StartVideoStream( |
| + base::WrapUnique(new TestScreenCapturer())); |
| + WaitFirstVideoFrame(); |
| } |
| } // namespace protocol |