Chromium Code Reviews| 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 // Unit test for VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/video_capture_manager.h" | 7 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 vcm_->UnregisterListener(); | 356 vcm_->UnregisterListener(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 TEST_F(VideoCaptureManagerTest, AddObserver) { | 359 TEST_F(VideoCaptureManagerTest, AddObserver) { |
| 360 InSequence s; | 360 InSequence s; |
| 361 MockVideoCaptureObserver observer; | 361 MockVideoCaptureObserver observer; |
| 362 vcm_->AddVideoCaptureObserver(&observer); | 362 vcm_->AddVideoCaptureObserver(&observer); |
| 363 | 363 |
| 364 EXPECT_CALL(observer, | 364 EXPECT_CALL(observer, |
| 365 OnVideoCaptureStarted(WrappedDeviceFactory::DEFAULT_FACING)); | 365 OnVideoCaptureStarted(WrappedDeviceFactory::DEFAULT_FACING)); |
| 366 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | |
| 367 EXPECT_CALL(*frame_observer_, OnStarted(_)); | |
| 366 EXPECT_CALL(observer, | 368 EXPECT_CALL(observer, |
| 367 OnVideoCaptureStopped(WrappedDeviceFactory::DEFAULT_FACING)); | 369 OnVideoCaptureStopped(WrappedDeviceFactory::DEFAULT_FACING)); |
| 370 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | |
|
chfremer
2017/03/02 17:56:10
Why are we adding these expectations?
It appears
braveyao
2017/03/03 17:53:12
Done.
No particular reason. Just to remove the GMO
chfremer
2017/03/03 19:08:33
Ah, I understand.
I think the GMOCK Warning also r
braveyao
2017/03/03 21:34:55
Acknowledged.
| |
| 368 | 371 |
| 369 int video_session_id = vcm_->Open(devices_.front()); | 372 int video_session_id = vcm_->Open(devices_.front()); |
| 370 VideoCaptureControllerID client_id = StartClient(video_session_id, true); | 373 VideoCaptureControllerID client_id = StartClient(video_session_id, true); |
| 371 | 374 |
| 372 StopClient(client_id); | 375 StopClient(client_id); |
| 373 vcm_->Close(video_session_id); | 376 vcm_->Close(video_session_id); |
| 374 | 377 |
| 375 // Wait to check callbacks before removing the listener. | 378 // Wait to check callbacks before removing the listener. |
| 376 base::RunLoop().RunUntilIdle(); | 379 base::RunLoop().RunUntilIdle(); |
| 377 vcm_->UnregisterListener(); | 380 vcm_->UnregisterListener(); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 EXPECT_CALL(*video_capture_device_factory_, WillResumeDevice()).Times(1); | 736 EXPECT_CALL(*video_capture_device_factory_, WillResumeDevice()).Times(1); |
| 734 ResumeClient(video_session_id, client_id); | 737 ResumeClient(video_session_id, client_id); |
| 735 | 738 |
| 736 // Attempting to resume the client a second time should not cause any calls to | 739 // Attempting to resume the client a second time should not cause any calls to |
| 737 // VideoCaptureDevice::Resume(). | 740 // VideoCaptureDevice::Resume(). |
| 738 ResumeClient(video_session_id, client_id); | 741 ResumeClient(video_session_id, client_id); |
| 739 | 742 |
| 740 // Add a second client that is never paused, then pause/resume the first | 743 // Add a second client that is never paused, then pause/resume the first |
| 741 // client, and no calls to VideoCaptureDevice::MaybeSuspend() or Resume() are | 744 // client, and no calls to VideoCaptureDevice::MaybeSuspend() or Resume() are |
| 742 // made. | 745 // made. |
| 746 EXPECT_CALL(*frame_observer_, OnStarted(_)); | |
|
chfremer
2017/03/02 17:56:10
Hmm. The purpose of this test is somewhat unclear
braveyao
2017/03/03 17:53:12
This is needed because StartClient() are called tw
| |
| 743 const VideoCaptureControllerID client_id2 = | 747 const VideoCaptureControllerID client_id2 = |
| 744 StartClient(video_session_id, true); | 748 StartClient(video_session_id, true); |
| 745 PauseClient(client_id); | 749 PauseClient(client_id); |
| 746 ResumeClient(video_session_id, client_id); | 750 ResumeClient(video_session_id, client_id); |
| 747 | 751 |
| 748 StopClient(client_id); | 752 StopClient(client_id); |
| 749 StopClient(client_id2); | 753 StopClient(client_id2); |
| 750 | 754 |
| 751 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); | 755 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)); |
| 752 vcm_->Close(video_session_id); | 756 vcm_->Close(video_session_id); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 // Wait to check callbacks before removing the listener. | 790 // Wait to check callbacks before removing the listener. |
| 787 base::RunLoop().RunUntilIdle(); | 791 base::RunLoop().RunUntilIdle(); |
| 788 vcm_->UnregisterListener(); | 792 vcm_->UnregisterListener(); |
| 789 } | 793 } |
| 790 #endif | 794 #endif |
| 791 | 795 |
| 792 // TODO(mcasas): Add a test to check consolidation of the supported formats | 796 // TODO(mcasas): Add a test to check consolidation of the supported formats |
| 793 // provided by the device when http://crbug.com/323913 is closed. | 797 // provided by the device when http://crbug.com/323913 is closed. |
| 794 | 798 |
| 795 } // namespace content | 799 } // namespace content |
| OLD | NEW |