OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file defines tests that implementations of GpuMemoryBufferFactory should |
| 6 // pass in order to be conformant. |
| 7 |
| 8 #ifndef CONTENT_TEST_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| 9 #define CONTENT_TEST_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| 10 |
| 11 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/buffer_format_util.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 template <typename GpuMemoryBufferFactoryType> |
| 18 class GpuMemoryBufferFactoryTest : public testing::Test { |
| 19 protected: |
| 20 GpuMemoryBufferFactoryType factory_; |
| 21 }; |
| 22 |
| 23 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest); |
| 24 |
| 25 TYPED_TEST_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer) { |
| 26 const gfx::GpuMemoryBufferId kBufferId(1); |
| 27 const int kClientId = 1; |
| 28 |
| 29 gfx::Size buffer_size(2, 2); |
| 30 |
| 31 for (auto format : gfx::GetBufferFormats()) { |
| 32 gfx::BufferUsage usages[] = {gfx::BufferUsage::MAP, |
| 33 gfx::BufferUsage::PERSISTENT_MAP, |
| 34 gfx::BufferUsage::SCANOUT}; |
| 35 for (auto usage : usages) { |
| 36 if (!TypeParam::IsGpuMemoryBufferConfigurationSupported(format, usage)) |
| 37 continue; |
| 38 |
| 39 gfx::GpuMemoryBufferHandle handle = |
| 40 TestFixture::factory_.CreateGpuMemoryBuffer(kBufferId, buffer_size, |
| 41 format, usage, kClientId, |
| 42 gfx::kNullPluginWindow); |
| 43 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER); |
| 44 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId); |
| 45 } |
| 46 } |
| 47 } |
| 48 |
| 49 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected |
| 50 // from a GpuMemoryBuffer factory in order to be conformant. |
| 51 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer); |
| 52 |
| 53 } // namespace content |
| 54 |
| 55 #endif // CONTENT_TEST_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
OLD | NEW |