OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/mojo/traits_test_service.mojom.h" | 8 #include "ui/gfx/mojo/traits_test_service.mojom.h" |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gfx/selection_bound.h" | 10 #include "ui/gfx/selection_bound.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 handle.stride = kStride; | 156 handle.stride = kStride; |
157 | 157 |
158 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 158 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
159 gfx::GpuMemoryBufferHandle output; | 159 gfx::GpuMemoryBufferHandle output; |
160 proxy->EchoGpuMemoryBufferHandle(handle, &output); | 160 proxy->EchoGpuMemoryBufferHandle(handle, &output); |
161 EXPECT_EQ(gfx::SHARED_MEMORY_BUFFER, output.type); | 161 EXPECT_EQ(gfx::SHARED_MEMORY_BUFFER, output.type); |
162 EXPECT_EQ(kId, output.id); | 162 EXPECT_EQ(kId, output.id); |
163 EXPECT_EQ(kOffset, output.offset); | 163 EXPECT_EQ(kOffset, output.offset); |
164 EXPECT_EQ(kStride, output.stride); | 164 EXPECT_EQ(kStride, output.stride); |
165 | 165 |
166 #if !defined(OS_MACOSX) && !defined(OS_IOS) | |
167 // TODO: Add support for mach_port on mac. | |
168 base::SharedMemory output_memory(output.handle, true); | 166 base::SharedMemory output_memory(output.handle, true); |
169 EXPECT_TRUE(output_memory.Map(1024)); | 167 EXPECT_TRUE(output_memory.Map(1024)); |
170 #endif | |
171 | 168 |
172 #if defined(USE_OZONE) | 169 #if defined(USE_OZONE) |
173 const uint64_t kSize = kOffset + kStride; | 170 const uint64_t kSize = kOffset + kStride; |
174 const uint64_t kModifier = 2; | 171 const uint64_t kModifier = 2; |
175 handle.type = gfx::OZONE_NATIVE_PIXMAP; | 172 handle.type = gfx::OZONE_NATIVE_PIXMAP; |
176 handle.id = kId; | 173 handle.id = kId; |
177 handle.native_pixmap_handle.planes.emplace_back(kOffset, kStride, kSize, | 174 handle.native_pixmap_handle.planes.emplace_back(kOffset, kStride, kSize, |
178 kModifier); | 175 kModifier); |
179 proxy->EchoGpuMemoryBufferHandle(handle, &output); | 176 proxy->EchoGpuMemoryBufferHandle(handle, &output); |
180 EXPECT_EQ(gfx::OZONE_NATIVE_PIXMAP, output.type); | 177 EXPECT_EQ(gfx::OZONE_NATIVE_PIXMAP, output.type); |
181 EXPECT_EQ(kId, output.id); | 178 EXPECT_EQ(kId, output.id); |
182 ASSERT_EQ(1u, output.native_pixmap_handle.planes.size()); | 179 ASSERT_EQ(1u, output.native_pixmap_handle.planes.size()); |
183 EXPECT_EQ(kSize, output.native_pixmap_handle.planes.back().size); | 180 EXPECT_EQ(kSize, output.native_pixmap_handle.planes.back().size); |
184 EXPECT_EQ(kModifier, output.native_pixmap_handle.planes.back().modifier); | 181 EXPECT_EQ(kModifier, output.native_pixmap_handle.planes.back().modifier); |
185 #endif | 182 #endif |
186 } | 183 } |
187 | 184 |
188 TEST_F(StructTraitsTest, NullGpuMemoryBufferHandle) { | 185 TEST_F(StructTraitsTest, NullGpuMemoryBufferHandle) { |
189 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 186 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
190 GpuMemoryBufferHandle output; | 187 GpuMemoryBufferHandle output; |
191 proxy->EchoGpuMemoryBufferHandle(GpuMemoryBufferHandle(), &output); | 188 proxy->EchoGpuMemoryBufferHandle(GpuMemoryBufferHandle(), &output); |
192 EXPECT_TRUE(output.is_null()); | 189 EXPECT_TRUE(output.is_null()); |
193 } | 190 } |
194 | 191 |
195 } // namespace gfx | 192 } // namespace gfx |
OLD | NEW |