Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: remoting/host/video_frame_pump_unittest.cc

Issue 1150163002: Update VideoFramePump to pass un-changed frames to encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work-around Visual Studio issue w/ undefined references Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/video_frame_pump.cc ('k') | remoting/host/video_frame_recorder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/video_frame_pump_unittest.cc
diff --git a/remoting/host/video_frame_pump_unittest.cc b/remoting/host/video_frame_pump_unittest.cc
index cd5cd016f6abd6c2587d92bd1213ef03f51a65e8..f72644bffd4a8d1f66b99b7a61c8d2a9ee4a4806 100644
--- a/remoting/host/video_frame_pump_unittest.cc
+++ b/remoting/host/video_frame_pump_unittest.cc
@@ -26,9 +26,11 @@
using ::remoting::protocol::MockVideoStub;
using ::testing::_;
+using ::testing::AtLeast;
using ::testing::DoAll;
using ::testing::Expectation;
using ::testing::InvokeWithoutArgs;
+using ::testing::Return;
namespace remoting {
@@ -38,6 +40,18 @@ ACTION(FinishSend) {
arg1.Run();
}
+scoped_ptr<webrtc::DesktopFrame> CreateNullFrame(
+ webrtc::DesktopCapturer::Callback*) {
+ return nullptr;
+}
+
+scoped_ptr<webrtc::DesktopFrame> CreateUnchangedFrame(
+ webrtc::DesktopCapturer::Callback*) {
+ const webrtc::DesktopSize kSize(800, 640);
+ // updated_region() is already empty by default in new BasicDesktopFrames.
+ return make_scoped_ptr(new webrtc::BasicDesktopFrame(kSize));
+}
+
} // namespace
static const int kWidth = 640;
@@ -159,6 +173,65 @@ TEST_F(VideoFramePumpTest, StartAndStop) {
capture_task_runner_, capturer.Pass())),
encoder.Pass(), &video_stub_));
+ // Run MessageLoop until the first frame is received.
+ run_loop.Run();
+}
+
+// Tests that the pump handles null frames returned by the capturer.
+TEST_F(VideoFramePumpTest, NullFrame) {
+ scoped_ptr<FakeDesktopCapturer> capturer(new FakeDesktopCapturer);
+ scoped_ptr<MockVideoEncoder> encoder(new MockVideoEncoder);
+
+ base::RunLoop run_loop;
+
+ // Set up the capturer to return null frames.
+ capturer->set_frame_generator(base::Bind(&CreateNullFrame));
+
+ // Expect that the VideoEncoder::Encode() method is never called.
+ EXPECT_CALL(*encoder, EncodePtr(_)).Times(0);
+
+ // When the first ProcessVideoPacket is received we stop the VideoFramePump.
+ EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
+ .WillOnce(DoAll(FinishSend(),
+ InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)))
+ .RetiresOnSaturation();
+
+ // Start video frame capture.
+ pump_.reset(new VideoFramePump(encode_task_runner_,
+ make_scoped_ptr(new DesktopCapturerProxy(
+ capture_task_runner_, capturer.Pass())),
+ encoder.Pass(), &video_stub_));
+
+ // Run MessageLoop until the first frame is received..
+ run_loop.Run();
+}
+
+// Tests how the pump handles unchanged frames returned by the capturer.
+TEST_F(VideoFramePumpTest, UnchangedFrame) {
+ scoped_ptr<FakeDesktopCapturer> capturer(new FakeDesktopCapturer);
+ scoped_ptr<MockVideoEncoder> encoder(new MockVideoEncoder);
+
+ base::RunLoop run_loop;
+
+ // Set up the capturer to return unchanged frames.
+ capturer->set_frame_generator(base::Bind(&CreateUnchangedFrame));
+
+ // Expect that the VideoEncoder::Encode() method is called.
+ EXPECT_CALL(*encoder, EncodePtr(_)).WillRepeatedly(Return(nullptr));
+
+ // When the first ProcessVideoPacket is received we stop the VideoFramePump.
+ // TODO(wez): Verify that the generated packet has no content here.
+ EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
+ .WillOnce(DoAll(FinishSend(),
+ InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)))
+ .RetiresOnSaturation();
+
+ // Start video frame capture.
+ pump_.reset(new VideoFramePump(encode_task_runner_,
+ make_scoped_ptr(new DesktopCapturerProxy(
+ capture_task_runner_, capturer.Pass())),
+ encoder.Pass(), &video_stub_));
+
// Run MessageLoop until the first frame is received..
run_loop.Run();
}
« no previous file with comments | « remoting/host/video_frame_pump.cc ('k') | remoting/host/video_frame_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698