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

Side by Side Diff: content/browser/media/capture/web_contents_video_capture_device_unittest.cc

Issue 2673373003: getUserMeida: report device starting states (Closed)
Patch Set: address comments on PS#4 and revise unittests Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 "content/browser/media/capture/web_contents_video_capture_device.h" 5 #include "content/browser/media/capture/web_contents_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 MOCK_METHOD7(OnIncomingCapturedData, 236 MOCK_METHOD7(OnIncomingCapturedData,
237 void(const uint8_t* data, 237 void(const uint8_t* data,
238 int length, 238 int length,
239 const media::VideoCaptureFormat& frame_format, 239 const media::VideoCaptureFormat& frame_format,
240 int rotation, 240 int rotation,
241 base::TimeTicks reference_time, 241 base::TimeTicks reference_time,
242 base::TimeDelta timestamp, 242 base::TimeDelta timestamp,
243 int frame_feedback_id)); 243 int frame_feedback_id));
244 244
245 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 245 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
246 MOCK_METHOD0(OnStarted, void(void));
246 247
247 media::VideoCaptureDevice::Client::Buffer ReserveOutputBuffer( 248 media::VideoCaptureDevice::Client::Buffer ReserveOutputBuffer(
248 const gfx::Size& dimensions, 249 const gfx::Size& dimensions,
249 media::VideoPixelFormat format, 250 media::VideoPixelFormat format,
250 media::VideoPixelStorage storage, 251 media::VideoPixelStorage storage,
251 int frame_feedback_id) override { 252 int frame_feedback_id) override {
252 CHECK_EQ(format, media::PIXEL_FORMAT_I420); 253 CHECK_EQ(format, media::PIXEL_FORMAT_I420);
253 int buffer_id_to_drop = 254 int buffer_id_to_drop =
254 media::VideoCaptureBufferPool::kInvalidId; // Ignored. 255 media::VideoCaptureBufferPool::kInvalidId; // Ignored.
255 const int buffer_id = buffer_pool_->ReserveForProducer( 256 const int buffer_id = buffer_pool_->ReserveForProducer(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 wait_color_yuv_(kWaitColorNotSet), 340 wait_color_yuv_(kWaitColorNotSet),
340 expecting_frames_(true) { 341 expecting_frames_(true) {
341 client_.reset(new StubClient( 342 client_.reset(new StubClient(
342 base::Bind(&StubClientObserver::DidDeliverFrame, 343 base::Bind(&StubClientObserver::DidDeliverFrame,
343 base::Unretained(this)), 344 base::Unretained(this)),
344 base::Bind(&StubClientObserver::OnError, base::Unretained(this)))); 345 base::Bind(&StubClientObserver::OnError, base::Unretained(this))));
345 } 346 }
346 347
347 virtual ~StubClientObserver() {} 348 virtual ~StubClientObserver() {}
348 349
349 std::unique_ptr<media::VideoCaptureDevice::Client> PassClient() { 350 std::unique_ptr<StubClient> PassClient() { return std::move(client_); }
350 return std::move(client_);
351 }
352 351
353 void SetIsExpectingFrames(bool expecting_frames) { 352 void SetIsExpectingFrames(bool expecting_frames) {
354 expecting_frames_ = expecting_frames; 353 expecting_frames_ = expecting_frames;
355 } 354 }
356 355
357 void QuitIfConditionsMet(SkColor color, const gfx::Size& size) { 356 void QuitIfConditionsMet(SkColor color, const gfx::Size& size) {
358 EXPECT_TRUE(expecting_frames_); 357 EXPECT_TRUE(expecting_frames_);
359 if (error_encountered_ || wait_color_yuv_ == kNotInterested || 358 if (error_encountered_ || wait_color_yuv_ == kNotInterested ||
360 wait_color_yuv_ == color) { 359 wait_color_yuv_ == color) {
361 last_frame_color_yuv_ = color; 360 last_frame_color_yuv_ = color;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 std::unique_ptr<media::VideoCaptureDevice> device_; 628 std::unique_ptr<media::VideoCaptureDevice> device_;
630 }; 629 };
631 630
632 // In real-world use cases, there can exist a race condition between starting 631 // In real-world use cases, there can exist a race condition between starting
633 // capture on a WebContents and having the WebContents be destroyed in the 632 // capture on a WebContents and having the WebContents be destroyed in the
634 // meantime. This tests that WebContentsVideoCaptureDevice errors-out 633 // meantime. This tests that WebContentsVideoCaptureDevice errors-out
635 // gracefully. 634 // gracefully.
636 TEST_F(WebContentsVideoCaptureDeviceTest, 635 TEST_F(WebContentsVideoCaptureDeviceTest,
637 SafelyStartsUpAfterWebContentsHasGone) { 636 SafelyStartsUpAfterWebContentsHasGone) {
638 ResetWebContents(); 637 ResetWebContents();
639 device()->AllocateAndStart(DefaultCaptureParams(), 638 auto client = client_observer()->PassClient();
640 client_observer()->PassClient()); 639 EXPECT_CALL(*client, OnStarted());
640 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
641 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForError()); 641 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForError());
642 device()->StopAndDeAllocate(); 642 device()->StopAndDeAllocate();
643 } 643 }
644 644
645 // Tests that WebContentsVideoCaptureDevice starts, captures a frame, and then 645 // Tests that WebContentsVideoCaptureDevice starts, captures a frame, and then
646 // gracefully errors-out if the WebContents is destroyed before the device is 646 // gracefully errors-out if the WebContents is destroyed before the device is
647 // stopped. 647 // stopped.
648 TEST_F(WebContentsVideoCaptureDeviceTest, 648 TEST_F(WebContentsVideoCaptureDeviceTest,
649 RunsThenErrorsOutWhenWebContentsIsDestroyed) { 649 RunsThenErrorsOutWhenWebContentsIsDestroyed) {
650 // We'll simulate the tab being closed after the capture pipeline is up and 650 // We'll simulate the tab being closed after the capture pipeline is up and
651 // running. 651 // running.
652 device()->AllocateAndStart(DefaultCaptureParams(), 652 auto client = client_observer()->PassClient();
653 client_observer()->PassClient()); 653 EXPECT_CALL(*client, OnStarted());
654 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
654 655
655 // Do one capture to prove the tab is initially open and being captured 656 // Do one capture to prove the tab is initially open and being captured
656 // normally. 657 // normally.
657 test_view()->SetSolidColor(SK_ColorRED); 658 test_view()->SetSolidColor(SK_ColorRED);
658 SimulateDrawEvent(); 659 SimulateDrawEvent();
659 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 660 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
660 661
661 base::RunLoop().RunUntilIdle(); 662 base::RunLoop().RunUntilIdle();
662 663
663 // Post a task to close the tab. We should see an error reported to the 664 // Post a task to close the tab. We should see an error reported to the
(...skipping 23 matching lines...) Expand all
687 // wind up in the idle state. 688 // wind up in the idle state.
688 base::RunLoop().RunUntilIdle(); 689 base::RunLoop().RunUntilIdle();
689 } 690 }
690 691
691 // Tests that frames are delivered to different clients across restarts of the 692 // Tests that frames are delivered to different clients across restarts of the
692 // same instance. 693 // same instance.
693 TEST_F(WebContentsVideoCaptureDeviceTest, 694 TEST_F(WebContentsVideoCaptureDeviceTest,
694 DeliversToCorrectClientAcrossRestarts) { 695 DeliversToCorrectClientAcrossRestarts) {
695 // While the device is up-and-running, expect frame captures. 696 // While the device is up-and-running, expect frame captures.
696 client_observer()->SetIsExpectingFrames(true); 697 client_observer()->SetIsExpectingFrames(true);
697 device()->AllocateAndStart(DefaultCaptureParams(), 698 auto client = client_observer()->PassClient();
698 client_observer()->PassClient()); 699 EXPECT_CALL(*client, OnStarted());
700 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
699 base::RunLoop().RunUntilIdle(); 701 base::RunLoop().RunUntilIdle();
700 test_view()->SetSolidColor(SK_ColorRED); 702 test_view()->SetSolidColor(SK_ColorRED);
701 SimulateDrawEvent(); 703 SimulateDrawEvent();
702 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 704 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
703 SimulateDrawEvent(); 705 SimulateDrawEvent();
704 test_view()->SetSolidColor(SK_ColorGREEN); 706 test_view()->SetSolidColor(SK_ColorGREEN);
705 SimulateDrawEvent(); 707 SimulateDrawEvent();
706 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); 708 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN));
707 SimulateDrawEvent(); 709 SimulateDrawEvent();
708 device()->StopAndDeAllocate(); 710 device()->StopAndDeAllocate();
709 711
710 base::RunLoop().RunUntilIdle(); 712 base::RunLoop().RunUntilIdle();
711 713
712 // Now that the device is stopped, expect frames are no longer captured. 714 // Now that the device is stopped, expect frames are no longer captured.
713 client_observer()->SetIsExpectingFrames(false); 715 client_observer()->SetIsExpectingFrames(false);
714 SimulateDrawEvent(); 716 SimulateDrawEvent();
715 SimulateDrawEvent(); 717 SimulateDrawEvent();
716 base::RunLoop().RunUntilIdle(); 718 base::RunLoop().RunUntilIdle();
717 719
718 // Re-start the device with a different client. Only the second client should 720 // Re-start the device with a different client. Only the second client should
719 // expect to see any frame captures. 721 // expect to see any frame captures.
720 StubClientObserver observer2; 722 StubClientObserver observer2;
721 observer2.SetIsExpectingFrames(true); 723 observer2.SetIsExpectingFrames(true);
722 device()->AllocateAndStart(DefaultCaptureParams(), observer2.PassClient()); 724 auto client2 = observer2.PassClient();
725 EXPECT_CALL(*client2, OnStarted());
726 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client2));
723 test_view()->SetSolidColor(SK_ColorBLUE); 727 test_view()->SetSolidColor(SK_ColorBLUE);
724 SimulateDrawEvent(); 728 SimulateDrawEvent();
725 ASSERT_NO_FATAL_FAILURE(observer2.WaitForNextColor(SK_ColorBLUE)); 729 ASSERT_NO_FATAL_FAILURE(observer2.WaitForNextColor(SK_ColorBLUE));
726 test_view()->SetSolidColor(SK_ColorYELLOW); 730 test_view()->SetSolidColor(SK_ColorYELLOW);
727 SimulateDrawEvent(); 731 SimulateDrawEvent();
728 ASSERT_NO_FATAL_FAILURE(observer2.WaitForNextColor(SK_ColorYELLOW)); 732 ASSERT_NO_FATAL_FAILURE(observer2.WaitForNextColor(SK_ColorYELLOW));
729 device()->StopAndDeAllocate(); 733 device()->StopAndDeAllocate();
730 } 734 }
731 735
732 // The "happy case" test. No scaling is needed, so we should be able to change 736 // The "happy case" test. No scaling is needed, so we should be able to change
733 // the picture emitted from the source and expect to see each delivered to the 737 // the picture emitted from the source and expect to see each delivered to the
734 // consumer. The test will alternate between the RGB/SkBitmap and YUV/VideoFrame 738 // consumer. The test will alternate between the RGB/SkBitmap and YUV/VideoFrame
735 // capture paths. 739 // capture paths.
736 TEST_F(WebContentsVideoCaptureDeviceTest, GoesThroughAllTheMotions) { 740 TEST_F(WebContentsVideoCaptureDeviceTest, GoesThroughAllTheMotions) {
737 device()->AllocateAndStart(DefaultCaptureParams(), 741 auto client = client_observer()->PassClient();
738 client_observer()->PassClient()); 742 EXPECT_CALL(*client, OnStarted());
743 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
739 744
740 for (int i = 0; i < 3; i++) { 745 for (int i = 0; i < 3; i++) {
741 SCOPED_TRACE(base::StringPrintf("Iteration #%d", i)); 746 SCOPED_TRACE(base::StringPrintf("Iteration #%d", i));
742 747
743 test_view()->SetSolidColor(SK_ColorRED); 748 test_view()->SetSolidColor(SK_ColorRED);
744 for (int j = 0; j <= i; j++) 749 for (int j = 0; j <= i; j++)
745 SimulateDrawEvent(); 750 SimulateDrawEvent();
746 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 751 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
747 752
748 test_view()->SetSolidColor(SK_ColorGREEN); 753 test_view()->SetSolidColor(SK_ColorGREEN);
(...skipping 15 matching lines...) Expand all
764 device()->StopAndDeAllocate(); 769 device()->StopAndDeAllocate();
765 } 770 }
766 771
767 // Tests that, when configured with the FIXED_ASPECT_RATIO resolution change 772 // Tests that, when configured with the FIXED_ASPECT_RATIO resolution change
768 // policy, the source size changes result in video frames of possibly varying 773 // policy, the source size changes result in video frames of possibly varying
769 // resolutions, but all with the same aspect ratio. 774 // resolutions, but all with the same aspect ratio.
770 TEST_F(WebContentsVideoCaptureDeviceTest, VariableResolution_FixedAspectRatio) { 775 TEST_F(WebContentsVideoCaptureDeviceTest, VariableResolution_FixedAspectRatio) {
771 auto capture_params = DefaultCaptureParams(); 776 auto capture_params = DefaultCaptureParams();
772 capture_params.resolution_change_policy = 777 capture_params.resolution_change_policy =
773 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO; 778 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO;
774 device()->AllocateAndStart(capture_params, client_observer()->PassClient()); 779 auto client = client_observer()->PassClient();
780 EXPECT_CALL(*client, OnStarted());
781 device()->AllocateAndStart(capture_params, std::move(client));
775 782
776 // Source size equals maximum size. Expect delivered frames to be 783 // Source size equals maximum size. Expect delivered frames to be
777 // kTestWidth by kTestHeight. 784 // kTestWidth by kTestHeight.
778 test_view()->SetSolidColor(SK_ColorRED); 785 test_view()->SetSolidColor(SK_ColorRED);
779 const float device_scale_factor = GetDeviceScaleFactor(); 786 const float device_scale_factor = GetDeviceScaleFactor();
780 SimulateSourceSizeChange(gfx::ConvertSizeToDIP( 787 SimulateSourceSizeChange(gfx::ConvertSizeToDIP(
781 device_scale_factor, gfx::Size(kTestWidth, kTestHeight))); 788 device_scale_factor, gfx::Size(kTestWidth, kTestHeight)));
782 SimulateDrawsUntilNewFrameSizeArrives( 789 SimulateDrawsUntilNewFrameSizeArrives(
783 SK_ColorRED, gfx::Size(kTestWidth, kTestHeight)); 790 SK_ColorRED, gfx::Size(kTestWidth, kTestHeight));
784 791
(...skipping 25 matching lines...) Expand all
810 device()->StopAndDeAllocate(); 817 device()->StopAndDeAllocate();
811 } 818 }
812 819
813 // Tests that, when configured with the ANY_WITHIN_LIMIT resolution change 820 // Tests that, when configured with the ANY_WITHIN_LIMIT resolution change
814 // policy, the source size changes result in video frames of possibly varying 821 // policy, the source size changes result in video frames of possibly varying
815 // resolutions. 822 // resolutions.
816 TEST_F(WebContentsVideoCaptureDeviceTest, VariableResolution_AnyWithinLimits) { 823 TEST_F(WebContentsVideoCaptureDeviceTest, VariableResolution_AnyWithinLimits) {
817 auto capture_params = DefaultCaptureParams(); 824 auto capture_params = DefaultCaptureParams();
818 capture_params.resolution_change_policy = 825 capture_params.resolution_change_policy =
819 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; 826 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT;
820 device()->AllocateAndStart(capture_params, client_observer()->PassClient()); 827 auto client = client_observer()->PassClient();
828 EXPECT_CALL(*client, OnStarted());
829 device()->AllocateAndStart(capture_params, std::move(client));
821 830
822 // Source size equals maximum size. Expect delivered frames to be 831 // Source size equals maximum size. Expect delivered frames to be
823 // kTestWidth by kTestHeight. 832 // kTestWidth by kTestHeight.
824 test_view()->SetSolidColor(SK_ColorRED); 833 test_view()->SetSolidColor(SK_ColorRED);
825 const float device_scale_factor = GetDeviceScaleFactor(); 834 const float device_scale_factor = GetDeviceScaleFactor();
826 SimulateSourceSizeChange(gfx::ConvertSizeToDIP( 835 SimulateSourceSizeChange(gfx::ConvertSizeToDIP(
827 device_scale_factor, gfx::Size(kTestWidth, kTestHeight))); 836 device_scale_factor, gfx::Size(kTestWidth, kTestHeight)));
828 SimulateDrawsUntilNewFrameSizeArrives( 837 SimulateDrawsUntilNewFrameSizeArrives(
829 SK_ColorRED, gfx::Size(kTestWidth, kTestHeight)); 838 SK_ColorRED, gfx::Size(kTestWidth, kTestHeight));
830 839
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 policy == media::RESOLUTION_POLICY_FIXED_RESOLUTION ? oddball_size 890 policy == media::RESOLUTION_POLICY_FIXED_RESOLUTION ? oddball_size
882 : standard_size, 891 : standard_size,
883 1.0f / GetDeviceScaleFactor()); 892 1.0f / GetDeviceScaleFactor());
884 ASSERT_NE(capture_preferred_size, web_contents()->GetPreferredSize()); 893 ASSERT_NE(capture_preferred_size, web_contents()->GetPreferredSize());
885 894
886 // Start the WebContentsVideoCaptureDevice. 895 // Start the WebContentsVideoCaptureDevice.
887 auto capture_params = DefaultCaptureParams(); 896 auto capture_params = DefaultCaptureParams();
888 capture_params.requested_format.frame_size = oddball_size; 897 capture_params.requested_format.frame_size = oddball_size;
889 capture_params.resolution_change_policy = policy; 898 capture_params.resolution_change_policy = policy;
890 StubClientObserver unused_observer; 899 StubClientObserver unused_observer;
891 device()->AllocateAndStart(capture_params, unused_observer.PassClient()); 900 auto client = unused_observer.PassClient();
901 EXPECT_CALL(*client, OnStarted());
902 device()->AllocateAndStart(capture_params, std::move(client));
892 base::RunLoop().RunUntilIdle(); 903 base::RunLoop().RunUntilIdle();
893 904
894 // Check that the preferred size of the WebContents matches the one provided 905 // Check that the preferred size of the WebContents matches the one provided
895 // by WebContentsVideoCaptureDevice. 906 // by WebContentsVideoCaptureDevice.
896 EXPECT_EQ(capture_preferred_size, web_contents()->GetPreferredSize()); 907 EXPECT_EQ(capture_preferred_size, web_contents()->GetPreferredSize());
897 908
898 // Stop the WebContentsVideoCaptureDevice. 909 // Stop the WebContentsVideoCaptureDevice.
899 device()->StopAndDeAllocate(); 910 device()->StopAndDeAllocate();
900 base::RunLoop().RunUntilIdle(); 911 base::RunLoop().RunUntilIdle();
901 }; 912 };
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000)); 958 policies[i], gfx::Size(1000, 1000), gfx::Size(1000, 1000));
948 RunTestForPreferredSize( 959 RunTestForPreferredSize(
949 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000)); 960 policies[i], gfx::Size(1600, 1000), gfx::Size(1600, 1000));
950 RunTestForPreferredSize( 961 RunTestForPreferredSize(
951 policies[i], gfx::Size(837, 999), gfx::Size(837, 999)); 962 policies[i], gfx::Size(837, 999), gfx::Size(837, 999));
952 } 963 }
953 } 964 }
954 965
955 // Tests the Suspend/Resume() functionality. 966 // Tests the Suspend/Resume() functionality.
956 TEST_F(WebContentsVideoCaptureDeviceTest, SuspendsAndResumes) { 967 TEST_F(WebContentsVideoCaptureDeviceTest, SuspendsAndResumes) {
957 device()->AllocateAndStart(DefaultCaptureParams(), 968 auto client = client_observer()->PassClient();
958 client_observer()->PassClient()); 969 EXPECT_CALL(*client, OnStarted());
970 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
959 971
960 for (int i = 0; i < 3; ++i) { 972 for (int i = 0; i < 3; ++i) {
961 // Draw a RED frame and wait for a normal frame capture to occur. 973 // Draw a RED frame and wait for a normal frame capture to occur.
962 test_view()->SetSolidColor(SK_ColorRED); 974 test_view()->SetSolidColor(SK_ColorRED);
963 SimulateDrawEvent(); 975 SimulateDrawEvent();
964 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 976 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
965 977
966 // Suspend capture and then draw a GREEN frame. No frame capture should 978 // Suspend capture and then draw a GREEN frame. No frame capture should
967 // occur. 979 // occur.
968 device()->MaybeSuspend(); 980 device()->MaybeSuspend();
(...skipping 12 matching lines...) Expand all
981 test_view()->SetSolidColor(SK_ColorBLUE); 993 test_view()->SetSolidColor(SK_ColorBLUE);
982 SimulateDrawEvent(); 994 SimulateDrawEvent();
983 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorBLUE)); 995 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorBLUE));
984 } 996 }
985 997
986 device()->StopAndDeAllocate(); 998 device()->StopAndDeAllocate();
987 } 999 }
988 1000
989 // Tests the RequestRefreshFrame() functionality. 1001 // Tests the RequestRefreshFrame() functionality.
990 TEST_F(WebContentsVideoCaptureDeviceTest, ProvidesRefreshFrames) { 1002 TEST_F(WebContentsVideoCaptureDeviceTest, ProvidesRefreshFrames) {
991 device()->AllocateAndStart(DefaultCaptureParams(), 1003 auto client = client_observer()->PassClient();
992 client_observer()->PassClient()); 1004 EXPECT_CALL(*client, OnStarted());
1005 device()->AllocateAndStart(DefaultCaptureParams(), std::move(client));
993 1006
994 // Request a refresh frame before the first frame has been drawn. This forces 1007 // Request a refresh frame before the first frame has been drawn. This forces
995 // a capture. 1008 // a capture.
996 test_view()->SetSolidColor(SK_ColorRED); 1009 test_view()->SetSolidColor(SK_ColorRED);
997 SimulateRefreshFrameRequest(); 1010 SimulateRefreshFrameRequest();
998 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 1011 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
999 1012
1000 // Now, draw a frame and wait for a normal frame capture to occur. 1013 // Now, draw a frame and wait for a normal frame capture to occur.
1001 test_view()->SetSolidColor(SK_ColorGREEN); 1014 test_view()->SetSolidColor(SK_ColorGREEN);
1002 SimulateDrawEvent(); 1015 SimulateDrawEvent();
1003 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); 1016 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN));
1004 1017
1005 // Now, make three more refresh frame requests. Although the source has 1018 // Now, make three more refresh frame requests. Although the source has
1006 // changed to BLUE, no draw event has occurred. Therefore, expect the refresh 1019 // changed to BLUE, no draw event has occurred. Therefore, expect the refresh
1007 // frames to contain the content from the last drawn frame, which is GREEN. 1020 // frames to contain the content from the last drawn frame, which is GREEN.
1008 test_view()->SetSolidColor(SK_ColorBLUE); 1021 test_view()->SetSolidColor(SK_ColorBLUE);
1009 for (int i = 0; i < 3; ++i) { 1022 for (int i = 0; i < 3; ++i) {
1010 SimulateRefreshFrameRequest(); 1023 SimulateRefreshFrameRequest();
1011 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); 1024 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN));
1012 } 1025 }
1013 1026
1014 device()->StopAndDeAllocate(); 1027 device()->StopAndDeAllocate();
1015 } 1028 }
1016 1029
1017 } // namespace 1030 } // namespace
1018 } // namespace content 1031 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698