| 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 #include <memory> |
| 6 |
| 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 7 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
| 6 #include "gpu/ipc/client/gpu_memory_buffer_impl_test_template.h" | 8 #include "gpu/ipc/client/gpu_memory_buffer_impl_test_template.h" |
| 7 | 9 |
| 8 namespace gpu { | 10 namespace gpu { |
| 9 namespace { | 11 namespace { |
| 10 | 12 |
| 11 INSTANTIATE_TYPED_TEST_CASE_P(GpuMemoryBufferImplSharedMemory, | 13 INSTANTIATE_TYPED_TEST_CASE_P(GpuMemoryBufferImplSharedMemory, |
| 12 GpuMemoryBufferImplTest, | 14 GpuMemoryBufferImplTest, |
| 13 GpuMemoryBufferImplSharedMemory); | 15 GpuMemoryBufferImplSharedMemory); |
| 14 | 16 |
| 15 void BufferDestroyed(bool* destroyed, const gpu::SyncToken& sync_token) { | 17 void BufferDestroyed(bool* destroyed, const gpu::SyncToken& sync_token) { |
| 16 *destroyed = true; | 18 *destroyed = true; |
| 17 } | 19 } |
| 18 | 20 |
| 19 TEST(GpuMemoryBufferImplSharedMemoryTest, Create) { | 21 TEST(GpuMemoryBufferImplSharedMemoryTest, Create) { |
| 20 const gfx::GpuMemoryBufferId kBufferId(1); | 22 const gfx::GpuMemoryBufferId kBufferId(1); |
| 21 | 23 |
| 22 gfx::Size buffer_size(8, 8); | 24 gfx::Size buffer_size(8, 8); |
| 23 | 25 |
| 24 for (auto format : gfx::GetBufferFormatsForTesting()) { | 26 for (auto format : gfx::GetBufferFormatsForTesting()) { |
| 25 bool destroyed = false; | 27 bool destroyed = false; |
| 26 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 28 std::unique_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
| 27 GpuMemoryBufferImplSharedMemory::Create( | 29 GpuMemoryBufferImplSharedMemory::Create( |
| 28 kBufferId, buffer_size, format, | 30 kBufferId, buffer_size, format, |
| 29 base::Bind(&BufferDestroyed, base::Unretained(&destroyed)))); | 31 base::Bind(&BufferDestroyed, base::Unretained(&destroyed)))); |
| 30 ASSERT_TRUE(buffer); | 32 ASSERT_TRUE(buffer); |
| 31 EXPECT_EQ(buffer->GetFormat(), format); | 33 EXPECT_EQ(buffer->GetFormat(), format); |
| 32 | 34 |
| 33 // Check if destruction callback is executed when deleting the buffer. | 35 // Check if destruction callback is executed when deleting the buffer. |
| 34 buffer.reset(); | 36 buffer.reset(); |
| 35 ASSERT_TRUE(destroyed); | 37 ASSERT_TRUE(destroyed); |
| 36 } | 38 } |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 } // namespace gpu | 42 } // namespace gpu |
| OLD | NEW |