OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "content/common/gpu/client/gpu_memory_buffer_impl.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 8 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 configuration.format, | 99 configuration.format, |
100 configuration.usage), | 100 configuration.usage), |
101 buffer_size, | 101 buffer_size, |
102 configuration.format, | 102 configuration.format, |
103 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, | 103 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, |
104 base::Unretained(this), | 104 base::Unretained(this), |
105 kBufferId))); | 105 kBufferId))); |
106 ASSERT_TRUE(buffer); | 106 ASSERT_TRUE(buffer); |
107 EXPECT_FALSE(buffer->IsMapped()); | 107 EXPECT_FALSE(buffer->IsMapped()); |
108 | 108 |
109 void* memory = buffer->Map(); | 109 void* memory; |
110 ASSERT_TRUE(memory); | 110 bool rv = buffer->Map(&memory); |
| 111 ASSERT_TRUE(rv); |
111 EXPECT_TRUE(buffer->IsMapped()); | 112 EXPECT_TRUE(buffer->IsMapped()); |
112 uint32 stride = buffer->GetStride(); | 113 uint32 stride; |
| 114 buffer->GetStride(&stride); |
113 EXPECT_GE(stride, width_in_bytes); | 115 EXPECT_GE(stride, width_in_bytes); |
114 memcpy(memory, data.get(), width_in_bytes); | 116 memcpy(memory, data.get(), width_in_bytes); |
115 EXPECT_EQ(memcmp(memory, data.get(), width_in_bytes), 0); | 117 EXPECT_EQ(memcmp(memory, data.get(), width_in_bytes), 0); |
116 buffer->Unmap(); | 118 buffer->Unmap(); |
117 EXPECT_FALSE(buffer->IsMapped()); | 119 EXPECT_FALSE(buffer->IsMapped()); |
118 } | 120 } |
119 } | 121 } |
120 | 122 |
121 std::vector<gfx::GpuMemoryBufferType> GetSupportedGpuMemoryBufferTypes() { | 123 std::vector<gfx::GpuMemoryBufferType> GetSupportedGpuMemoryBufferTypes() { |
122 std::vector<gfx::GpuMemoryBufferType> supported_types; | 124 std::vector<gfx::GpuMemoryBufferType> supported_types; |
123 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | 125 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); |
124 return supported_types; | 126 return supported_types; |
125 } | 127 } |
126 | 128 |
127 INSTANTIATE_TEST_CASE_P( | 129 INSTANTIATE_TEST_CASE_P( |
128 GpuMemoryBufferImplTests, | 130 GpuMemoryBufferImplTests, |
129 GpuMemoryBufferImplTest, | 131 GpuMemoryBufferImplTest, |
130 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes())); | 132 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes())); |
131 | 133 |
132 } // namespace | 134 } // namespace |
133 } // namespace content | 135 } // namespace content |
OLD | NEW |