Chromium Code Reviews| 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 ea619735dac198edd5389e09b26b8b5104e44869..af19bd4557da920292f01f15341fde94253b4525 100644 |
| --- a/remoting/host/video_frame_pump_unittest.cc |
| +++ b/remoting/host/video_frame_pump_unittest.cc |
| @@ -12,8 +12,8 @@ |
| #include "remoting/base/auto_thread_task_runner.h" |
| #include "remoting/codec/video_encoder.h" |
| #include "remoting/codec/video_encoder_verbatim.h" |
| +#include "remoting/host/desktop_capturer_proxy.h" |
| #include "remoting/host/fake_desktop_capturer.h" |
| -#include "remoting/host/fake_mouse_cursor_monitor.h" |
| #include "remoting/host/host_mock_objects.h" |
| #include "remoting/proto/control.pb.h" |
| #include "remoting/proto/video.pb.h" |
| @@ -21,23 +21,15 @@ |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| -#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" |
| #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h" |
| using ::remoting::protocol::MockClientStub; |
| using ::remoting::protocol::MockVideoStub; |
| using ::testing::_; |
| -using ::testing::AtLeast; |
| -using ::testing::AnyNumber; |
| -using ::testing::DeleteArg; |
| using ::testing::DoAll; |
| using ::testing::Expectation; |
| -using ::testing::InSequence; |
| using ::testing::InvokeWithoutArgs; |
| -using ::testing::Return; |
| -using ::testing::ReturnRef; |
| -using ::testing::SaveArg; |
| namespace remoting { |
| @@ -56,10 +48,6 @@ ACTION(FinishSend) { |
| static const int kWidth = 640; |
| static const int kHeight = 480; |
| -static const int kCursorWidth = 64; |
| -static const int kCursorHeight = 32; |
| -static const int kHotspotX = 11; |
| -static const int kHotspotY = 12; |
| class MockVideoEncoder : public VideoEncoder { |
| public: |
| @@ -107,22 +95,6 @@ class ThreadCheckDesktopCapturer : public FakeDesktopCapturer { |
| DISALLOW_COPY_AND_ASSIGN(ThreadCheckDesktopCapturer); |
| }; |
| -class ThreadCheckMouseCursorMonitor : public FakeMouseCursorMonitor { |
| - public: |
| - ThreadCheckMouseCursorMonitor( |
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| - : task_runner_(task_runner) { |
| - } |
| - ~ThreadCheckMouseCursorMonitor() override { |
| - EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); |
| - } |
| - |
| - private: |
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(ThreadCheckMouseCursorMonitor); |
| -}; |
| - |
| class VideoFramePumpTest : public testing::Test { |
| public: |
| VideoFramePumpTest(); |
| @@ -132,45 +104,31 @@ class VideoFramePumpTest : public testing::Test { |
| void StartVideoFramePump( |
| scoped_ptr<webrtc::DesktopCapturer> capturer, |
| - scoped_ptr<VideoEncoder> encoder, |
| - scoped_ptr<webrtc::MouseCursorMonitor> mouse_monitor); |
| + scoped_ptr<VideoEncoder> encoder); |
| void StopVideoFramePump(); |
| // webrtc::DesktopCapturer mocks. |
| void OnCapturerStart(webrtc::DesktopCapturer::Callback* callback); |
| void OnCaptureFrame(const webrtc::DesktopRegion& region); |
| - // webrtc::MouseCursorMonitor mocks. |
| - void OnMouseCursorMonitorInit( |
| - webrtc::MouseCursorMonitor::Callback* callback, |
| - webrtc::MouseCursorMonitor::Mode mode); |
| - void OnCaptureMouse(); |
| - void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
| - |
| protected: |
| base::MessageLoop message_loop_; |
| base::RunLoop run_loop_; |
| scoped_refptr<AutoThreadTaskRunner> capture_task_runner_; |
| scoped_refptr<AutoThreadTaskRunner> encode_task_runner_; |
| scoped_refptr<AutoThreadTaskRunner> main_task_runner_; |
| - scoped_refptr<VideoFramePump> scheduler_; |
| + scoped_ptr<VideoFramePump> pump_; |
| - MockClientStub client_stub_; |
| MockVideoStub video_stub_; |
| // Points to the callback passed to webrtc::DesktopCapturer::Start(). |
| webrtc::DesktopCapturer::Callback* capturer_callback_; |
| - // Points to the callback passed to webrtc::MouseCursor::Init(). |
| - webrtc::MouseCursorMonitor::Callback* mouse_monitor_callback_; |
| - |
| private: |
| DISALLOW_COPY_AND_ASSIGN(VideoFramePumpTest); |
| }; |
| -VideoFramePumpTest::VideoFramePumpTest() |
| - : capturer_callback_(nullptr), |
| - mouse_monitor_callback_(nullptr) { |
| +VideoFramePumpTest::VideoFramePumpTest() : capturer_callback_(nullptr) { |
| } |
| void VideoFramePumpTest::SetUp() { |
| @@ -192,23 +150,15 @@ void VideoFramePumpTest::TearDown() { |
| void VideoFramePumpTest::StartVideoFramePump( |
| scoped_ptr<webrtc::DesktopCapturer> capturer, |
| - scoped_ptr<VideoEncoder> encoder, |
| - scoped_ptr<webrtc::MouseCursorMonitor> mouse_monitor) { |
| - scheduler_ = new VideoFramePump( |
| - capture_task_runner_, |
| - encode_task_runner_, |
| - main_task_runner_, |
| - capturer.Pass(), |
| - mouse_monitor.Pass(), |
| - encoder.Pass(), |
| - &client_stub_, |
| - &video_stub_); |
| - scheduler_->Start(); |
| + scoped_ptr<VideoEncoder> encoder) { |
| + pump_.reset(new VideoFramePump(encode_task_runner_, |
| + make_scoped_ptr(new DesktopCapturerProxy( |
| + capture_task_runner_, capturer.Pass())), |
| + encoder.Pass(), &video_stub_)); |
| } |
| void VideoFramePumpTest::StopVideoFramePump() { |
| - scheduler_->Stop(); |
| - scheduler_ = nullptr; |
| + pump_.reset(); |
| } |
| void VideoFramePumpTest::OnCapturerStart( |
| @@ -227,62 +177,11 @@ void VideoFramePumpTest::OnCaptureFrame(const webrtc::DesktopRegion& region) { |
| capturer_callback_->OnCaptureCompleted(frame.release()); |
| } |
| -void VideoFramePumpTest::OnCaptureMouse() { |
| - EXPECT_TRUE(mouse_monitor_callback_); |
| - |
| - scoped_ptr<webrtc::MouseCursor> mouse_cursor( |
| - new webrtc::MouseCursor( |
| - new webrtc::BasicDesktopFrame( |
| - webrtc::DesktopSize(kCursorWidth, kCursorHeight)), |
| - webrtc::DesktopVector(kHotspotX, kHotspotY))); |
| - |
| - mouse_monitor_callback_->OnMouseCursor(mouse_cursor.release()); |
| -} |
| - |
| -void VideoFramePumpTest::OnMouseCursorMonitorInit( |
| - webrtc::MouseCursorMonitor::Callback* callback, |
| - webrtc::MouseCursorMonitor::Mode mode) { |
| - EXPECT_FALSE(mouse_monitor_callback_); |
| - EXPECT_TRUE(callback); |
| - |
| - mouse_monitor_callback_ = callback; |
| -} |
| - |
| -void VideoFramePumpTest::SetCursorShape( |
| - const protocol::CursorShapeInfo& cursor_shape) { |
| - EXPECT_TRUE(cursor_shape.has_width()); |
| - EXPECT_EQ(kCursorWidth, cursor_shape.width()); |
| - EXPECT_TRUE(cursor_shape.has_height()); |
| - EXPECT_EQ(kCursorHeight, cursor_shape.height()); |
| - EXPECT_TRUE(cursor_shape.has_hotspot_x()); |
| - EXPECT_EQ(kHotspotX, cursor_shape.hotspot_x()); |
| - EXPECT_TRUE(cursor_shape.has_hotspot_y()); |
| - EXPECT_EQ(kHotspotY, cursor_shape.hotspot_y()); |
| - EXPECT_TRUE(cursor_shape.has_data()); |
| - EXPECT_EQ(kCursorWidth * kCursorHeight * webrtc::DesktopFrame::kBytesPerPixel, |
| - static_cast<int>(cursor_shape.data().size())); |
| -} |
| - |
| // This test mocks capturer, encoder and network layer to simulate one capture |
| -// cycle. When the first encoded packet is submitted to the network |
| -// VideoFramePump is instructed to come to a complete stop. We expect the stop |
| -// sequence to be executed successfully. |
| +// cycle. |
| TEST_F(VideoFramePumpTest, StartAndStop) { |
| scoped_ptr<webrtc::MockScreenCapturer> capturer( |
| new webrtc::MockScreenCapturer()); |
| - scoped_ptr<MockMouseCursorMonitor> cursor_monitor( |
| - new MockMouseCursorMonitor()); |
| - |
| - { |
| - InSequence s; |
| - |
| - EXPECT_CALL(*cursor_monitor, Init(_, _)) |
| - .WillOnce( |
| - Invoke(this, &VideoFramePumpTest::OnMouseCursorMonitorInit)); |
| - |
| - EXPECT_CALL(*cursor_monitor, Capture()) |
| - .WillRepeatedly(Invoke(this, &VideoFramePumpTest::OnCaptureMouse)); |
| - } |
| Expectation capturer_start = |
| EXPECT_CALL(*capturer, Start(_)) |
| @@ -310,13 +209,8 @@ TEST_F(VideoFramePumpTest, StartAndStop) { |
| InvokeWithoutArgs(this, &VideoFramePumpTest::StopVideoFramePump))) |
| .RetiresOnSaturation(); |
| - EXPECT_CALL(client_stub_, SetCursorShape(_)) |
| - .WillOnce(Invoke(this, &VideoFramePumpTest::SetCursorShape)); |
| - |
| // Start video frame capture. |
| - scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( |
| - new FakeMouseCursorMonitor()); |
| - StartVideoFramePump(capturer.Pass(), encoder.Pass(), cursor_monitor.Pass()); |
| + StartVideoFramePump(capturer.Pass(), encoder.Pass()); |
| // Run until there are no more pending tasks from the VideoFramePump. |
| // Otherwise, a lingering frame capture might attempt to trigger a capturer |
| @@ -324,8 +218,7 @@ TEST_F(VideoFramePumpTest, StartAndStop) { |
| base::RunLoop().RunUntilIdle(); |
| } |
| -// Verify that the capturer, encoder and mouse monitor are torn down on the |
| -// correct threads. |
| +// Verify that the capturer and encoder are torn down on the correct threads. |
| TEST_F(VideoFramePumpTest, DeleteOnThreads) { |
|
Wez
2015/02/12 21:59:15
Add a test for actually capturing across threads?
Sergey Ulanov
2015/02/13 08:39:45
Done.
|
| capture_task_runner_ = AutoThread::Create("capture", main_task_runner_); |
| encode_task_runner_ = AutoThread::Create("encode", main_task_runner_); |
| @@ -334,13 +227,10 @@ TEST_F(VideoFramePumpTest, DeleteOnThreads) { |
| new ThreadCheckDesktopCapturer(capture_task_runner_)); |
| scoped_ptr<VideoEncoder> encoder( |
| new ThreadCheckVideoEncoder(encode_task_runner_)); |
| - scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( |
| - new ThreadCheckMouseCursorMonitor(capture_task_runner_)); |
| - // Start and stop the scheduler, so it will tear down the screen capturer, |
| - // video encoder and mouse monitor. |
| - StartVideoFramePump(capturer.Pass(), encoder.Pass(), |
| - mouse_cursor_monitor.Pass()); |
| + // Start and stop the scheduler, so it will tear down the screen capturer and |
| + // video encoder. |
| + StartVideoFramePump(capturer.Pass(), encoder.Pass()); |
| StopVideoFramePump(); |
| } |