1 // Copyright 2014 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.
5 #include "content/common/gpu/gpu_memory_buffer_factory.h"
7 #include "testing/gtest/include/gtest/gtest.h"
12 class GpuMemoryBufferFactoryTest
13 : public testing::TestWithParam
<gfx::GpuMemoryBufferType
> {
15 GpuMemoryBufferFactoryTest() : factory_(nullptr) {}
17 // Overridden from testing::Test:
18 void SetUp() override
{
19 factory_
= GpuMemoryBufferFactory::Create(GetParam());
20 factory_
->GetSupportedGpuMemoryBufferConfigurations(
21 &supported_configurations_
);
23 void TearDown() override
{ factory_
.reset(); }
26 scoped_ptr
<GpuMemoryBufferFactory
> factory_
;
27 std::vector
<GpuMemoryBufferFactory::Configuration
> supported_configurations_
;
30 TEST_P(GpuMemoryBufferFactoryTest
, CreateAndDestroy
) {
31 const int kBufferId
= 1;
32 const int kClientId
= 1;
34 gfx::Size
buffer_size(2, 2);
36 for (auto configuration
: supported_configurations_
) {
37 gfx::GpuMemoryBufferHandle handle
= factory_
->CreateGpuMemoryBuffer(
38 kBufferId
, buffer_size
, configuration
.format
, configuration
.usage
,
39 kClientId
, gfx::kNullPluginWindow
);
40 EXPECT_EQ(handle
.type
, GetParam());
41 factory_
->DestroyGpuMemoryBuffer(kBufferId
, kClientId
);
45 std::vector
<gfx::GpuMemoryBufferType
>
46 GetSupportedGpuMemoryBufferFactoryTypes() {
47 std::vector
<gfx::GpuMemoryBufferType
> supported_types
;
48 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types
);
49 return supported_types
;
52 INSTANTIATE_TEST_CASE_P(
53 GpuMemoryBufferFactoryTests
,
54 GpuMemoryBufferFactoryTest
,
55 ::testing::ValuesIn(GetSupportedGpuMemoryBufferFactoryTypes()));
58 } // namespace content