OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/video_scheduler.h" | 5 #include "remoting/host/video_scheduler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 FinishSend(), | 310 FinishSend(), |
311 InvokeWithoutArgs(this, &VideoSchedulerTest::StopVideoScheduler))) | 311 InvokeWithoutArgs(this, &VideoSchedulerTest::StopVideoScheduler))) |
312 .RetiresOnSaturation(); | 312 .RetiresOnSaturation(); |
313 | 313 |
314 EXPECT_CALL(client_stub_, SetCursorShape(_)) | 314 EXPECT_CALL(client_stub_, SetCursorShape(_)) |
315 .WillOnce(Invoke(this, &VideoSchedulerTest::SetCursorShape)); | 315 .WillOnce(Invoke(this, &VideoSchedulerTest::SetCursorShape)); |
316 | 316 |
317 // Start video frame capture. | 317 // Start video frame capture. |
318 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( | 318 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( |
319 new FakeMouseCursorMonitor()); | 319 new FakeMouseCursorMonitor()); |
320 StartVideoScheduler(capturer.PassAs<webrtc::DesktopCapturer>(), | 320 StartVideoScheduler(capturer.Pass(), encoder.Pass(), cursor_monitor.Pass()); |
321 encoder.PassAs<VideoEncoder>(), | |
322 cursor_monitor.PassAs<webrtc::MouseCursorMonitor>()); | |
323 | 321 |
324 // Run until there are no more pending tasks from the VideoScheduler. | 322 // Run until there are no more pending tasks from the VideoScheduler. |
325 // Otherwise, a lingering frame capture might attempt to trigger a capturer | 323 // Otherwise, a lingering frame capture might attempt to trigger a capturer |
326 // expectation action and crash. | 324 // expectation action and crash. |
327 base::RunLoop().RunUntilIdle(); | 325 base::RunLoop().RunUntilIdle(); |
328 } | 326 } |
329 | 327 |
330 // Verify that the capturer, encoder and mouse monitor are torn down on the | 328 // Verify that the capturer, encoder and mouse monitor are torn down on the |
331 // correct threads. | 329 // correct threads. |
332 TEST_F(VideoSchedulerTest, DeleteOnThreads) { | 330 TEST_F(VideoSchedulerTest, DeleteOnThreads) { |
333 capture_task_runner_ = AutoThread::Create("capture", main_task_runner_); | 331 capture_task_runner_ = AutoThread::Create("capture", main_task_runner_); |
334 encode_task_runner_ = AutoThread::Create("encode", main_task_runner_); | 332 encode_task_runner_ = AutoThread::Create("encode", main_task_runner_); |
335 | 333 |
336 scoped_ptr<webrtc::DesktopCapturer> capturer( | 334 scoped_ptr<webrtc::DesktopCapturer> capturer( |
337 new ThreadCheckDesktopCapturer(capture_task_runner_)); | 335 new ThreadCheckDesktopCapturer(capture_task_runner_)); |
338 scoped_ptr<VideoEncoder> encoder( | 336 scoped_ptr<VideoEncoder> encoder( |
339 new ThreadCheckVideoEncoder(encode_task_runner_)); | 337 new ThreadCheckVideoEncoder(encode_task_runner_)); |
340 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( | 338 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor( |
341 new ThreadCheckMouseCursorMonitor(capture_task_runner_)); | 339 new ThreadCheckMouseCursorMonitor(capture_task_runner_)); |
342 | 340 |
343 // Start and stop the scheduler, so it will tear down the screen capturer, | 341 // Start and stop the scheduler, so it will tear down the screen capturer, |
344 // video encoder and mouse monitor. | 342 // video encoder and mouse monitor. |
345 StartVideoScheduler(capturer.Pass(), encoder.Pass(), | 343 StartVideoScheduler(capturer.Pass(), encoder.Pass(), |
346 mouse_cursor_monitor.Pass()); | 344 mouse_cursor_monitor.Pass()); |
347 StopVideoScheduler(); | 345 StopVideoScheduler(); |
348 } | 346 } |
349 | 347 |
350 } // namespace remoting | 348 } // namespace remoting |
OLD | NEW |