| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 // This file defines tests that implementations of GpuMemoryBufferFactory should | 5 // This file defines tests that implementations of GpuMemoryBufferFactory should |
| 6 // pass in order to be conformant. | 6 // pass in order to be conformant. |
| 7 | 7 |
| 8 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ | 8 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| 9 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ | 9 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| 10 | 10 |
| 11 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 11 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 12 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/buffer_format_util.h" | 14 #include "ui/gfx/buffer_format_util.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 template <typename GpuMemoryBufferFactoryType> | 18 template <typename GpuMemoryBufferFactoryType> |
| 18 class GpuMemoryBufferFactoryTest : public testing::Test { | 19 class GpuMemoryBufferFactoryTest : public testing::Test { |
| 19 protected: | 20 protected: |
| 20 GpuMemoryBufferFactoryType factory_; | 21 GpuMemoryBufferFactoryType factory_; |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest); | 24 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest); |
| 24 | 25 |
| 25 TYPED_TEST_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer) { | 26 TYPED_TEST_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer) { |
| 26 const gfx::GpuMemoryBufferId kBufferId(1); | 27 const gfx::GpuMemoryBufferId kBufferId(1); |
| 27 const int kClientId = 1; | 28 const int kClientId = 1; |
| 28 | 29 |
| 29 gfx::Size buffer_size(2, 2); | 30 gfx::Size buffer_size(2, 2); |
| 30 | 31 |
| 31 for (auto format : gfx::GetBufferFormatsForTesting()) { | 32 for (auto format : gfx::GetBufferFormatsForTesting()) { |
| 32 gfx::BufferUsage usages[] = { | 33 gfx::BufferUsage usages[] = { |
| 33 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, | 34 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, |
| 34 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 35 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
| 35 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; | 36 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; |
| 36 for (auto usage : usages) { | 37 for (auto usage : usages) { |
| 37 if (!TypeParam::IsGpuMemoryBufferConfigurationSupported(format, usage)) | 38 if (!gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage)) |
| 38 continue; | 39 continue; |
| 39 | 40 |
| 40 gfx::GpuMemoryBufferHandle handle = | 41 gfx::GpuMemoryBufferHandle handle = |
| 41 TestFixture::factory_.CreateGpuMemoryBuffer(kBufferId, buffer_size, | 42 TestFixture::factory_.CreateGpuMemoryBuffer(kBufferId, buffer_size, |
| 42 format, usage, kClientId, | 43 format, usage, kClientId, |
| 43 gfx::kNullPluginWindow); | 44 gfx::kNullPluginWindow); |
| 44 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER); | 45 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER); |
| 45 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId); | 46 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId); |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 | 50 |
| 50 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected | 51 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected |
| 51 // from a GpuMemoryBuffer factory in order to be conformant. | 52 // from a GpuMemoryBuffer factory in order to be conformant. |
| 52 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer); | 53 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer); |
| 53 | 54 |
| 54 template <typename GpuMemoryBufferFactoryType> | 55 template <typename GpuMemoryBufferFactoryType> |
| 55 class GpuMemoryBufferFactoryImportTest | 56 class GpuMemoryBufferFactoryImportTest |
| 56 : public GpuMemoryBufferFactoryTest<GpuMemoryBufferFactoryType> {}; | 57 : public GpuMemoryBufferFactoryTest<GpuMemoryBufferFactoryType> {}; |
| 57 | 58 |
| 58 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest); | 59 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest); |
| 59 | 60 |
| 60 TYPED_TEST_P(GpuMemoryBufferFactoryImportTest, | 61 TYPED_TEST_P(GpuMemoryBufferFactoryImportTest, |
| 61 CreateGpuMemoryBufferFromHandle) { | 62 CreateGpuMemoryBufferFromHandle) { |
| 62 const int kClientId = 1; | 63 const int kClientId = 1; |
| 63 | 64 |
| 64 gfx::Size buffer_size(2, 2); | 65 gfx::Size buffer_size(2, 2); |
| 65 | 66 |
| 66 for (auto format : gfx::GetBufferFormatsForTesting()) { | 67 for (auto format : gfx::GetBufferFormatsForTesting()) { |
| 67 if (!TypeParam::IsGpuMemoryBufferConfigurationSupported( | 68 if (!gpu::IsNativeGpuMemoryBufferConfigurationSupported( |
| 68 format, gfx::BufferUsage::GPU_READ)) { | 69 format, gfx::BufferUsage::GPU_READ)) { |
| 69 continue; | 70 continue; |
| 70 } | 71 } |
| 71 | 72 |
| 72 const gfx::GpuMemoryBufferId kBufferId1(1); | 73 const gfx::GpuMemoryBufferId kBufferId1(1); |
| 73 gfx::GpuMemoryBufferHandle handle1 = | 74 gfx::GpuMemoryBufferHandle handle1 = |
| 74 TestFixture::factory_.CreateGpuMemoryBuffer( | 75 TestFixture::factory_.CreateGpuMemoryBuffer( |
| 75 kBufferId1, buffer_size, format, gfx::BufferUsage::GPU_READ, | 76 kBufferId1, buffer_size, format, gfx::BufferUsage::GPU_READ, |
| 76 kClientId, gfx::kNullPluginWindow); | 77 kClientId, gfx::kNullPluginWindow); |
| 77 EXPECT_NE(handle1.type, gfx::EMPTY_BUFFER); | 78 EXPECT_NE(handle1.type, gfx::EMPTY_BUFFER); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 // The GpuMemoryBufferFactoryImportTest test case verifies that the | 92 // The GpuMemoryBufferFactoryImportTest test case verifies that the |
| 92 // GpuMemoryBufferFactory implementation handles import of buffers correctly. | 93 // GpuMemoryBufferFactory implementation handles import of buffers correctly. |
| 93 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest, | 94 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest, |
| 94 CreateGpuMemoryBufferFromHandle); | 95 CreateGpuMemoryBufferFromHandle); |
| 95 | 96 |
| 96 } // namespace content | 97 } // namespace content |
| 97 | 98 |
| 98 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ | 99 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| OLD | NEW |