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