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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 protected: | 44 protected: |
45 // A GpuMemoryBuffer Mock to provide a trivial RGBA buffer as Map() backing. | 45 // A GpuMemoryBuffer Mock to provide a trivial RGBA buffer as Map() backing. |
46 // We need to allocate on ctor and deallocate on dtor so that consecutive | 46 // We need to allocate on ctor and deallocate on dtor so that consecutive |
47 // Map()-Unmap() cycles yield the same underlying data pointer. | 47 // Map()-Unmap() cycles yield the same underlying data pointer. |
48 class MockGpuMemoryBuffer : public gfx::GpuMemoryBuffer { | 48 class MockGpuMemoryBuffer : public gfx::GpuMemoryBuffer { |
49 public: | 49 public: |
50 explicit MockGpuMemoryBuffer(const gfx::Size& size) | 50 explicit MockGpuMemoryBuffer(const gfx::Size& size) |
51 : size_(size), data_(new uint8[size_.GetArea() * 4]), mapped_(false) {} | 51 : size_(size), data_(new uint8[size_.GetArea() * 4]), mapped_(false) {} |
52 ~MockGpuMemoryBuffer() override { delete[] data_; } | 52 ~MockGpuMemoryBuffer() override { delete[] data_; } |
53 | 53 |
54 bool Map(void** data) override { | 54 bool Map() override { |
55 EXPECT_EQ(mapped_, false); | 55 EXPECT_FALSE(mapped_); |
56 mapped_ = true; | 56 mapped_ = true; |
57 data[0] = static_cast<void*>(data_); | |
58 return true; | 57 return true; |
59 } | 58 } |
| 59 void* memory(size_t plane) override { |
| 60 EXPECT_TRUE(mapped_); |
| 61 EXPECT_EQ(0u, plane); |
| 62 return static_cast<void*>(data_); |
| 63 } |
60 void Unmap() override { | 64 void Unmap() override { |
61 EXPECT_EQ(mapped_, true); | 65 EXPECT_TRUE(mapped_); |
62 mapped_ = false; | 66 mapped_ = false; |
63 } | 67 } |
64 gfx::Size GetSize() const override { return size_; } | 68 gfx::Size GetSize() const override { return size_; } |
65 gfx::BufferFormat GetFormat() const override { | 69 gfx::BufferFormat GetFormat() const override { |
66 return gfx::BufferFormat::BGRA_8888; | 70 return gfx::BufferFormat::BGRA_8888; |
67 } | 71 } |
68 void GetStride(int* stride) const override { | 72 int stride(size_t plane) const override { |
69 *stride = size_.width() * 4; | 73 EXPECT_EQ(0u, plane); |
70 return; | 74 return size_.width() * 4; |
71 } | 75 } |
72 gfx::GpuMemoryBufferId GetId() const override { | 76 gfx::GpuMemoryBufferId GetId() const override { |
73 return gfx::GpuMemoryBufferId(0); | 77 return gfx::GpuMemoryBufferId(0); |
74 } | 78 } |
75 gfx::GpuMemoryBufferHandle GetHandle() const override { | 79 gfx::GpuMemoryBufferHandle GetHandle() const override { |
76 return gfx::GpuMemoryBufferHandle(); | 80 return gfx::GpuMemoryBufferHandle(); |
77 } | 81 } |
78 ClientBuffer AsClientBuffer() override { return nullptr; } | 82 ClientBuffer AsClientBuffer() override { return nullptr; } |
79 | 83 |
80 private: | 84 private: |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 if (buffer4->data() != nullptr) | 364 if (buffer4->data() != nullptr) |
361 memset(buffer4->data(), 0x77, buffer4->mapped_size()); | 365 memset(buffer4->data(), 0x77, buffer4->mapped_size()); |
362 buffer4.reset(); | 366 buffer4.reset(); |
363 } | 367 } |
364 | 368 |
365 INSTANTIATE_TEST_CASE_P(, | 369 INSTANTIATE_TEST_CASE_P(, |
366 VideoCaptureBufferPoolTest, | 370 VideoCaptureBufferPoolTest, |
367 testing::ValuesIn(kCapturePixelFormatAndStorages)); | 371 testing::ValuesIn(kCapturePixelFormatAndStorages)); |
368 | 372 |
369 } // namespace content | 373 } // namespace content |
OLD | NEW |