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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 2659653002: Fix for issue 684766 Old/erroneous frame feedback during tab capture (Closed)
Patch Set: Exercise ResurrectLastOutputBuffer() and apply git cl format 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Unit test for VideoCaptureController. 5 // Unit test for VideoCaptureController.
6 6
7 #include "content/browser/renderer_host/media/video_capture_controller.h" 7 #include "content/browser/renderer_host/media/video_capture_controller.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 base::RunLoop().RunUntilIdle(); 586 base::RunLoop().RunUntilIdle();
587 Mock::VerifyAndClearExpectations(client_a_.get()); 587 Mock::VerifyAndClearExpectations(client_a_.get());
588 588
589 // Second client connects after the error state. It also should get told of 589 // Second client connects after the error state. It also should get told of
590 // the error. 590 // the error.
591 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1); 591 EXPECT_CALL(*client_b_, DoError(route_id)).Times(1);
592 controller_->AddClient(route_id, client_b_.get(), 200, session_200); 592 controller_->AddClient(route_id, client_b_.get(), 200, session_200);
593 Mock::VerifyAndClearExpectations(client_b_.get()); 593 Mock::VerifyAndClearExpectations(client_b_.get());
594 } 594 }
595 595
596 // Tests that frame feedback provided by consumers is correctly reported back
597 // to the producing device for a sequence of frames that is longer than the
598 // number of buffers shared between the device and consumer.
599 TEST_F(VideoCaptureControllerTest, FrameFeedbackIsReportedForSequenceOfFrames) {
600 const int kTestFrameSequenceLength = 10;
601 media::VideoCaptureFormat arbitrary_format(
602 gfx::Size(320, 240), arbitrary_frame_rate_, media::PIXEL_FORMAT_I420);
603
604 // Register |client_a_| at |controller_|.
605 media::VideoCaptureParams session_100;
606 session_100.requested_format = arbitrary_format;
607 const VideoCaptureControllerID route_id(0x99);
608 controller_->AddClient(route_id, client_a_.get(), 100, session_100);
609 base::RunLoop().RunUntilIdle();
610 Mock::VerifyAndClearExpectations(client_a_.get());
611
612 for (int frame_index = 0; frame_index < kTestFrameSequenceLength;
613 frame_index++) {
614 const int stub_frame_feedback_id = frame_index;
615 const float stub_consumer_utilization =
616 static_cast<float>(frame_index) / kTestFrameSequenceLength;
617
618 client_a_->resource_utilization_ = stub_consumer_utilization;
619
620 EXPECT_CALL(*client_a_,
621 DoBufferReady(route_id, arbitrary_format.frame_size))
622 .Times(1);
623 EXPECT_CALL(
624 *mock_consumer_feedback_observer_,
625 OnUtilizationReport(stub_frame_feedback_id, stub_consumer_utilization))
626 .Times(1);
627
628 // Device prepares and pushes a frame.
629 // For the first half of the frames we exercise ReserveOutputBuffer() while
630 // for the second half we exercise ResurrectLastOutputBuffer().
631 // The frame is expected to arrive at |client_a_|.DoBufferReady(), which
632 // automatically notifies |controller_| that it has finished consuming it.
633 media::VideoCaptureDevice::Client::Buffer buffer;
634 if (frame_index < kTestFrameSequenceLength / 2) {
635 buffer = device_client_->ReserveOutputBuffer(
636 arbitrary_format.frame_size, arbitrary_format.pixel_format,
637 arbitrary_format.pixel_storage, stub_frame_feedback_id);
638 } else {
639 buffer = device_client_->ResurrectLastOutputBuffer(
640 arbitrary_format.frame_size, arbitrary_format.pixel_format,
641 arbitrary_format.pixel_storage, stub_frame_feedback_id);
642 }
643 ASSERT_TRUE(buffer.is_valid());
644 device_client_->OnIncomingCapturedBuffer(
645 std::move(buffer), arbitrary_format, arbitrary_reference_time_,
646 arbitrary_timestamp_);
647
648 base::RunLoop().RunUntilIdle();
649 Mock::VerifyAndClearExpectations(client_a_.get());
650 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_);
651 }
652 }
653
596 } // namespace content 654 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698