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

Side by Side Diff: content/renderer/media/video_capture_impl_unittest.cc

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 years, 1 month 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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "content/child/child_process.h" 7 #include "content/child/child_process.h"
8 #include "content/common/media/video_capture_messages.h" 8 #include "content/common/media/video_capture_messages.h"
9 #include "content/renderer/media/video_capture_impl.h" 9 #include "content/renderer/media/video_capture_impl.h"
10 #include "media/base/bind_to_current_loop.h" 10 #include "media/base/bind_to_current_loop.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 std::vector<gpu::MailboxHolder> mailbox_holders; 45 std::vector<gpu::MailboxHolder> mailbox_holders;
46 }; 46 };
47 47
48 static const BufferReceivedTestArg kBufferFormats[] = { 48 static const BufferReceivedTestArg kBufferFormats[] = {
49 BufferReceivedTestArg(media::PIXEL_FORMAT_I420), 49 BufferReceivedTestArg(media::PIXEL_FORMAT_I420),
50 BufferReceivedTestArg( 50 BufferReceivedTestArg(
51 media::PIXEL_FORMAT_ARGB, 51 media::PIXEL_FORMAT_ARGB,
52 std::vector<gpu::MailboxHolder>( 52 std::vector<gpu::MailboxHolder>(
53 1, gpu::MailboxHolder(gpu::Mailbox::Generate(), 0, 0)))}; 53 1, gpu::MailboxHolder(gpu::Mailbox::Generate(), 0, 0)))};
54 54
55 class VideoCaptureImplTest : 55 class VideoCaptureImplTest
56 public ::testing::TestWithParam<BufferReceivedTestArg> { 56 : public ::testing::TestWithParam<BufferReceivedTestArg> {
57 public: 57 public:
58 class MockVideoCaptureImpl : public VideoCaptureImpl { 58 class MockVideoCaptureImpl : public VideoCaptureImpl {
59 public: 59 public:
60 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, 60 MockVideoCaptureImpl(const media::VideoCaptureSessionId id,
61 VideoCaptureMessageFilter* filter) 61 VideoCaptureMessageFilter* filter)
62 : VideoCaptureImpl(id, filter), received_buffer_count_(0) { 62 : VideoCaptureImpl(id, filter), received_buffer_count_(0) {}
63 }
64 ~MockVideoCaptureImpl() override {} 63 ~MockVideoCaptureImpl() override {}
65 64
66 // Override Send() to mimic device to send events. 65 // Override Send() to mimic device to send events.
67 void Send(IPC::Message* message) override { 66 void Send(IPC::Message* message) override {
68 CHECK(message); 67 CHECK(message);
69 68
70 // In this method, messages are sent to the according handlers as if 69 // In this method, messages are sent to the according handlers as if
71 // we are the device. 70 // we are the device.
72 bool handled = true; 71 bool handled = true;
73 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) 72 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the 300 // Check that a request to GetDeviceFormatsInUse() ends up eventually in the
302 // provided callback. 301 // provided callback.
303 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) { 302 TEST_F(VideoCaptureImplTest, GetDeviceFormatsInUse) {
304 EXPECT_CALL(*this, OnDeviceFormatsInUse(_)); 303 EXPECT_CALL(*this, OnDeviceFormatsInUse(_));
305 304
306 Init(); 305 Init();
307 GetDeviceFormatsInUse(); 306 GetDeviceFormatsInUse();
308 DeInit(); 307 DeInit();
309 } 308 }
310 309
311 // NEW TEST
312 TEST_P(VideoCaptureImplTest, BufferReceivedWithFormat) { 310 TEST_P(VideoCaptureImplTest, BufferReceivedWithFormat) {
313 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); 311 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1);
314 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); 312 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1);
315 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(1); 313 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(1);
316 314
317 const BufferReceivedTestArg& buffer_arg = GetParam(); 315 const BufferReceivedTestArg& buffer_arg = GetParam();
318 const gfx::Size size(1280, 720); 316 const gfx::Size size(1280, 720);
319 317
320 // Create a fake shared memory for buffer. 318 // Create a fake shared memory for buffer.
321 base::SharedMemory shm; 319 base::SharedMemory shm;
(...skipping 11 matching lines...) Expand all
333 BufferReceived(0, size, buffer_arg.pixel_format, buffer_arg.mailbox_holders); 331 BufferReceived(0, size, buffer_arg.pixel_format, buffer_arg.mailbox_holders);
334 StopCapture(0); 332 StopCapture(0);
335 BufferDestroyed(0); 333 BufferDestroyed(0);
336 DeInit(); 334 DeInit();
337 } 335 }
338 336
339 INSTANTIATE_TEST_CASE_P(I420AndARGB, 337 INSTANTIATE_TEST_CASE_P(I420AndARGB,
340 VideoCaptureImplTest, 338 VideoCaptureImplTest,
341 testing::ValuesIn(kBufferFormats)); 339 testing::ValuesIn(kBufferFormats));
342 340
343 // NEW TEST
344 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) { 341 TEST_F(VideoCaptureImplTest, BufferReceivedAfterStop) {
345 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1); 342 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STARTED)).Times(1);
346 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1); 343 EXPECT_CALL(*this, OnStateUpdate(VIDEO_CAPTURE_STATE_STOPPED)).Times(1);
347 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0); 344 EXPECT_CALL(*this, OnFrameReady(_, _)).Times(0);
348 345
349 // Create a fake shared memory for buffer. 346 // Create a fake shared memory for buffer.
350 base::SharedMemory shm; 347 base::SharedMemory shm;
351 const size_t i420_frame_size = media::VideoFrame::AllocationSize( 348 const size_t i420_frame_size = media::VideoFrame::AllocationSize(
352 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size); 349 media::PIXEL_FORMAT_I420, params_large_.requested_format.frame_size);
353 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size)); 350 ASSERT_TRUE(shm.CreateAndMapAnonymous(i420_frame_size));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 StartCapture(0, params_small_); 397 StartCapture(0, params_small_);
401 398
402 // Receive state change message from browser. 399 // Receive state change message from browser.
403 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR); 400 video_capture_impl_->ReceiveStateChangeMessage(VIDEO_CAPTURE_STATE_ERROR);
404 401
405 StopCapture(0); 402 StopCapture(0);
406 DeInit(); 403 DeInit();
407 } 404 }
408 405
409 } // namespace content 406 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.cc ('k') | content/test/gpu_memory_buffer_factory_test_template.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698