Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: content/common/gpu/gpu_memory_buffer_factory_test_template.h

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This file defines tests that implementations of GpuMemoryBufferFactory should
6 // pass in order to be conformant.
7
8 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_
9 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_
10
11 #include "content/common/gpu/gpu_memory_buffer_factory.h"
12 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gfx/buffer_format_util.h"
15
16 namespace content {
17
18 template <typename GpuMemoryBufferFactoryType>
19 class GpuMemoryBufferFactoryTest : public testing::Test {
20 protected:
21 GpuMemoryBufferFactoryType factory_;
22 };
23
24 TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest);
25
26 TYPED_TEST_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer) {
27 const gfx::GpuMemoryBufferId kBufferId(1);
28 const int kClientId = 1;
29
30 gfx::Size buffer_size(2, 2);
31
32 for (auto format : gfx::GetBufferFormatsForTesting()) {
33 gfx::BufferUsage usages[] = {
34 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
35 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
36 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
37 for (auto usage : usages) {
38 if (!gpu::IsNativeGpuMemoryBufferConfigurationSupported(format, usage))
39 continue;
40
41 gfx::GpuMemoryBufferHandle handle =
42 TestFixture::factory_.CreateGpuMemoryBuffer(kBufferId, buffer_size,
43 format, usage, kClientId,
44 gfx::kNullPluginWindow);
45 EXPECT_NE(handle.type, gfx::EMPTY_BUFFER);
46 TestFixture::factory_.DestroyGpuMemoryBuffer(kBufferId, kClientId);
47 }
48 }
49 }
50
51 // The GpuMemoryBufferFactoryTest test case verifies behavior that is expected
52 // from a GpuMemoryBuffer factory in order to be conformant.
53 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer);
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
98
99 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_TEST_TEMPLATE_H_
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_surface_texture_unittest.cc ('k') | content/common/gpu/gpu_memory_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698