| 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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER); | 45 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER); |
| 46 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId); | 46 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected | 51 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected |
| 52 // from a GpuMemoryBuffer factory in order to be conformant. | 52 // from a GpuMemoryBuffer factory in order to be conformant. |
| 53 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer); | 53 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer); |
| 54 | 54 |
| 55 template <typename GpuMemoryBufferFactoryType> | |
| 56 class GpuMemoryBufferFactoryImportTest | |
| 57 : public GpuMemoryBufferFactoryTest<GpuMemoryBufferFactoryType> {}; | |
| 58 | |
| 59 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest); | |
| 60 | |
| 61 TYPED_TEST_P(GpuMemoryBufferFactoryImportTest, | |
| 62 CreateGpuMemoryBufferFromHandle) { | |
| 63 const int kClientId = 1; | |
| 64 | |
| 65 gfx::Size buffer_size(2, 2); | |
| 66 | |
| 67 for (auto format : gfx::GetBufferFormatsForTesting()) { | |
| 68 if (!gpu::IsNativeGpuMemoryBufferConfigurationSupported( | |
| 69 format, gfx::BufferUsage::GPU_READ)) { | |
| 70 continue; | |
| 71 } | |
| 72 | |
| 73 const gfx::GpuMemoryBufferId kBufferId1(1); | |
| 74 gfx::GpuMemoryBufferHandle handle1 = | |
| 75 TestFixture::factory_.CreateGpuMemoryBuffer( | |
| 76 kBufferId1, buffer_size, format, gfx::BufferUsage::GPU_READ, | |
| 77 kClientId, gfx::kNullPluginWindow); | |
| 78 EXPECT_NE(handle1.type, gfx::EMPTY_BUFFER); | |
| 79 | |
| 80 // Create new buffer from |handle1|. | |
| 81 const gfx::GpuMemoryBufferId kBufferId2(2); | |
| 82 gfx::GpuMemoryBufferHandle handle2 = | |
| 83 TestFixture::factory_.CreateGpuMemoryBufferFromHandle( | |
| 84 handle1, kBufferId2, buffer_size, format, kClientId); | |
| 85 EXPECT_NE(handle2.type, gfx::EMPTY_BUFFER); | |
| 86 | |
| 87 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId1, kClientId); | |
| 88 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId2, kClientId); | |
| 89 } | |
| 90 } | |
| 91 | |
| 92 // The GpuMemoryBufferFactoryImportTest test case verifies that the | |
| 93 // GpuMemoryBufferFactory implementation handles import of buffers correctly. | |
| 94 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryImportTest, | |
| 95 CreateGpuMemoryBufferFromHandle); | |
| 96 | |
| 97 } // namespace content | 55 } // namespace content |
| 98 | 56 |
| 99 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ | 57 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_ |
| OLD | NEW |