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

Unified Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 2573223002: [Mojo Video Capture] Simplify media::VideoCaptureDevice::Client:Buffer to a struct (Closed)
Patch Set: Merge Ownership into BufferAccessProvider. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_controller_unittest.cc
diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
index 599f34e1ded58790deed403e599439e796be7c2e..09f1507fdcafd7057e0f79bd4d5549c7e9d70a0a 100644
--- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
@@ -115,8 +115,6 @@ class MockFrameBufferPool : public media::FrameBufferPool {
public:
MOCK_METHOD1(SetBufferHold, void(int buffer_id));
MOCK_METHOD1(ReleaseBufferHold, void(int buffer_id));
- MOCK_METHOD1(GetHandleForTransit,
- mojo::ScopedSharedBufferHandle(int buffer_id));
};
// Test class.
@@ -315,14 +313,14 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
uint8_t buffer_no = 1;
const int arbitrary_frame_feedback_id = 101;
ASSERT_EQ(0.0, device_client_->GetBufferPoolUtilization());
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id));
- ASSERT_TRUE(buffer.get());
+ media::VideoCaptureDevice::Client::Buffer buffer =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
+ ASSERT_TRUE(buffer.is_valid());
+ auto buffer_access = buffer.access_provider->GetReadWriteAccess();
ASSERT_EQ(1.0 / kPoolSize, device_client_->GetBufferPoolUtilization());
- memset(buffer->data(), buffer_no++, buffer->mapped_size());
+ memset(buffer_access->data(), buffer_no++, buffer_access->mapped_size());
{
InSequence s;
EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1)).Times(1);
@@ -348,14 +346,14 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
client_b_->resource_utilization_ = -1.0;
{
InSequence s;
- EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer->id()))
+ EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer.id))
.Times(1);
// Expect VideoCaptureController to call the load observer with a
// resource utilization of 0.5 (the largest of all reported values).
EXPECT_CALL(*mock_consumer_feedback_observer_,
OnUtilizationReport(arbitrary_frame_feedback_id, 0.5))
.Times(1);
- EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer->id()))
+ EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer.id))
.Times(1);
}
@@ -374,28 +372,27 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// case pretend that the Buffer pointer is held by the device for a long
// delay. This shouldn't affect anything.
const int arbitrary_frame_feedback_id_2 = 102;
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer2 =
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id_2);
- ASSERT_TRUE(buffer2.get());
- memset(buffer2->data(), buffer_no++, buffer2->mapped_size());
+ media::VideoCaptureDevice::Client::Buffer buffer2 =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id_2);
+ ASSERT_TRUE(buffer2.is_valid());
+ auto buffer2_access = buffer2.access_provider->GetReadWriteAccess();
+ memset(buffer2_access->data(), buffer_no++, buffer2_access->mapped_size());
client_a_->resource_utilization_ = 0.5;
client_b_->resource_utilization_ = 3.14;
// Expect VideoCaptureController to call the load observer with a
// resource utilization of 3.14 (the largest of all reported values).
{
InSequence s;
- EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer2->id()))
+ EXPECT_CALL(*mock_frame_receiver_observer_, SetBufferHold(buffer2.id))
.Times(1);
// Expect VideoCaptureController to call the load observer with a
// resource utilization of 3.14 (the largest of all reported values).
EXPECT_CALL(*mock_consumer_feedback_observer_,
OnUtilizationReport(arbitrary_frame_feedback_id_2, 3.14))
.Times(1);
- EXPECT_CALL(*mock_frame_receiver_observer_,
- ReleaseBufferHold(buffer2->id()))
+ EXPECT_CALL(*mock_frame_receiver_observer_, ReleaseBufferHold(buffer2.id))
.Times(1);
}
@@ -442,13 +439,13 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
// Third, fourth, and fifth buffers. Pretend they all arrive at the same time.
for (int i = 0; i < kPoolSize; i++) {
const int arbitrary_frame_feedback_id = 200 + i;
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer =
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id);
- ASSERT_TRUE(buffer.get());
- memset(buffer->data(), buffer_no++, buffer->mapped_size());
+ media::VideoCaptureDevice::Client::Buffer buffer =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
+ ASSERT_TRUE(buffer.is_valid());
+ auto buffer_access = buffer.access_provider->GetReadWriteAccess();
+ memset(buffer_access->data(), buffer_no++, buffer_access->mapped_size());
device_client_->OnIncomingCapturedBuffer(std::move(buffer),
device_format,
arbitrary_reference_time_,
@@ -456,11 +453,10 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
}
// ReserveOutputBuffer ought to fail now, because the pool is depleted.
ASSERT_FALSE(device_client_
- ->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id)
- .get());
+ ->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id)
+ .is_valid());
// The new client needs to be notified of the creation of |kPoolSize| buffers;
// the old clients only |kPoolSize - 2|.
@@ -494,31 +490,31 @@ TEST_P(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
EXPECT_CALL(*client_b_, DoEnded(client_b_route_1)).Times(1);
controller_->StopSession(300);
// Queue up another buffer.
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer3 =
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id);
- ASSERT_TRUE(buffer3.get());
- memset(buffer3->data(), buffer_no++, buffer3->mapped_size());
+ media::VideoCaptureDevice::Client::Buffer buffer3 =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
+ ASSERT_TRUE(buffer3.is_valid());
+ auto buffer3_access = buffer3.access_provider->GetReadWriteAccess();
+ memset(buffer3_access->data(), buffer_no++, buffer3_access->mapped_size());
device_client_->OnIncomingCapturedBuffer(std::move(buffer3),
device_format,
arbitrary_reference_time_,
arbitrary_timestamp_);
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer4 =
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id);
+ media::VideoCaptureDevice::Client::Buffer buffer4 =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
{
// Kill A2 via session close (posts a task to disconnect, but A2 must not
// be sent either of these two buffers).
EXPECT_CALL(*client_a_, DoEnded(client_a_route_2)).Times(1);
controller_->StopSession(200);
}
- ASSERT_TRUE(buffer4.get());
- memset(buffer4->data(), buffer_no++, buffer4->mapped_size());
+ ASSERT_TRUE(buffer4.is_valid());
+ auto buffer4_access = buffer4.access_provider->GetReadWriteAccess();
+ memset(buffer4_access->data(), buffer_no++, buffer4_access->mapped_size());
device_client_->OnIncomingCapturedBuffer(std::move(buffer4),
device_format,
arbitrary_reference_time_,
@@ -568,12 +564,11 @@ TEST_F(VideoCaptureControllerTest, ErrorBeforeDeviceCreation) {
media::VideoCaptureFormat device_format(
capture_resolution, arbitrary_frame_rate_, media::PIXEL_FORMAT_I420,
media::PIXEL_STORAGE_CPU);
- const int arbitrary_frame_feedback_id = 101;
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id));
+ const int arbitrary_frame_feedback_id = 101;
+ media::VideoCaptureDevice::Client::Buffer buffer =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
device_client_->OnIncomingCapturedBuffer(std::move(buffer),
device_format,
arbitrary_reference_time_,
@@ -605,12 +600,11 @@ TEST_F(VideoCaptureControllerTest, ErrorAfterDeviceCreation) {
media::VideoCaptureFormat device_format(
gfx::Size(10, 10), arbitrary_frame_rate_, media::PIXEL_FORMAT_I420);
const int arbitrary_frame_feedback_id = 101;
- std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer(
- device_client_->ReserveOutputBuffer(device_format.frame_size,
- device_format.pixel_format,
- device_format.pixel_storage,
- arbitrary_frame_feedback_id));
- ASSERT_TRUE(buffer.get());
+ media::VideoCaptureDevice::Client::Buffer buffer =
+ device_client_->ReserveOutputBuffer(
+ device_format.frame_size, device_format.pixel_format,
+ device_format.pixel_storage, arbitrary_frame_feedback_id);
+ ASSERT_TRUE(buffer.is_valid());
device_client_->OnError(FROM_HERE, "Test Error");
device_client_->OnIncomingCapturedBuffer(std::move(buffer),

Powered by Google App Engine
This is Rietveld 408576698