Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 VideoCaptureBufferPool. | 5 // Unit test for VideoCaptureBufferPool. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" | 7 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "cc/test/test_context_provider.h" | 13 #include "cc/test/test_context_provider.h" |
| 14 #include "cc/test/test_web_graphics_context_3d.h" | 14 #include "cc/test/test_web_graphics_context_3d.h" |
| 15 #include "content/browser/compositor/buffer_queue.h" | 15 #include "content/browser/compositor/buffer_queue.h" |
| 16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 16 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 17 #include "content/browser/renderer_host/media/video_capture_controller.h" | 17 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 18 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
| 19 #include "media/base/video_util.h" | 19 #include "media/base/video_util.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 static const media::VideoPixelFormat kCaptureFormats[] = { | 25 static const media::VideoPixelFormat kCaptureFormats[] = { |
| 26 media::PIXEL_FORMAT_I420, | 26 media::PIXEL_FORMAT_I420, |
| 27 media::PIXEL_FORMAT_TEXTURE, | 27 media::PIXEL_FORMAT_TEXTURE, |
| 28 #if !defined(OS_ANDROID) | 28 #if !defined(OS_ANDROID) |
| 29 media::PIXEL_FORMAT_GPUMEMORYBUFFER | 29 // TODO(mcasas): Re-enable after removing usage of |
| 30 // BrowserGpuMemoryBufferManager from unit tests. | |
| 31 // media::PIXEL_FORMAT_GPUMEMORYBUFFER | |
|
reveman
2015/06/17 18:28:01
I had to disable this as BrowserGpuMemoryBufferMan
| |
| 30 #endif | 32 #endif |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 static const int kTestBufferPoolSize = 3; | 35 static const int kTestBufferPoolSize = 3; |
| 34 | 36 |
| 35 class VideoCaptureBufferPoolTest | 37 class VideoCaptureBufferPoolTest |
| 36 : public testing::TestWithParam<media::VideoPixelFormat> { | 38 : public testing::TestWithParam<media::VideoPixelFormat> { |
| 37 protected: | 39 protected: |
| 38 // A GpuMemoryBuffer Mock to provide a trivial RGBA buffer as Map() backing. | 40 // A GpuMemoryBuffer Mock to provide a trivial RGBA buffer as Map() backing. |
| 39 // We need to allocate on ctor and deallocate on dtor so that consecutive | 41 // We need to allocate on ctor and deallocate on dtor so that consecutive |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 70 uint8* const data_; | 72 uint8* const data_; |
| 71 bool mapped_; | 73 bool mapped_; |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 #if !defined(OS_ANDROID) | 76 #if !defined(OS_ANDROID) |
| 75 // The next two classes are needed to replicate the GpuMemoryBuffer allocation | 77 // The next two classes are needed to replicate the GpuMemoryBuffer allocation |
| 76 // on Browser side. | 78 // on Browser side. |
| 77 class StubBrowserGpuMemoryBufferManager | 79 class StubBrowserGpuMemoryBufferManager |
| 78 : public BrowserGpuMemoryBufferManager { | 80 : public BrowserGpuMemoryBufferManager { |
| 79 public: | 81 public: |
| 80 StubBrowserGpuMemoryBufferManager() | 82 StubBrowserGpuMemoryBufferManager() {} |
| 81 : BrowserGpuMemoryBufferManager(nullptr, 1) {} | |
| 82 | 83 |
| 83 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( | 84 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( |
| 84 const gfx::Size& size, | 85 const gfx::Size& size, |
| 85 gfx::GpuMemoryBuffer::Format format, | 86 gfx::GpuMemoryBuffer::Format format, |
| 86 gfx::GpuMemoryBuffer::Usage usage) override { | 87 gfx::GpuMemoryBuffer::Usage usage) override { |
| 87 return make_scoped_ptr(new MockGpuMemoryBuffer(size)); | 88 return make_scoped_ptr(new MockGpuMemoryBuffer(size)); |
| 88 } | 89 } |
| 89 }; | 90 }; |
| 90 class MockBufferQueue : public BufferQueue { | 91 class MockBufferQueue : public BufferQueue { |
| 91 public: | 92 public: |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 if (buffer4->data() != nullptr) | 337 if (buffer4->data() != nullptr) |
| 337 memset(buffer4->data(), 0x77, buffer4->size()); | 338 memset(buffer4->data(), 0x77, buffer4->size()); |
| 338 buffer4.reset(); | 339 buffer4.reset(); |
| 339 } | 340 } |
| 340 | 341 |
| 341 INSTANTIATE_TEST_CASE_P(, | 342 INSTANTIATE_TEST_CASE_P(, |
| 342 VideoCaptureBufferPoolTest, | 343 VideoCaptureBufferPoolTest, |
| 343 testing::ValuesIn(kCaptureFormats)); | 344 testing::ValuesIn(kCaptureFormats)); |
| 344 | 345 |
| 345 } // namespace content | 346 } // namespace content |
| OLD | NEW |