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

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: Created 3 years, 11 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 // 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 // The frame is expected to arrive at |client_a_|.DoBufferReady(), which
630 // automatically notifies |controller_| that it has finished consuming it.
631 media::VideoCaptureDevice::Client::Buffer buffer =
632 device_client_->ReserveOutputBuffer(
633 arbitrary_format.frame_size, arbitrary_format.pixel_format,
634 arbitrary_format.pixel_storage, stub_frame_feedback_id);
635 ASSERT_TRUE(buffer.is_valid());
636 device_client_->OnIncomingCapturedBuffer(
637 std::move(buffer), arbitrary_format, arbitrary_reference_time_,
638 arbitrary_timestamp_);
639
640 base::RunLoop().RunUntilIdle();
641 Mock::VerifyAndClearExpectations(client_a_.get());
642 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_);
643 }
644 }
645
596 } // namespace content 646 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698