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

Unified Diff: ui/gfx/mojo/struct_traits_unittest.cc

Issue 2534533002: gfx: Fix [de]serializing non-shm GpuMemoryBufferHandle. (Closed)
Patch Set: test Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mojo/struct_traits_unittest.cc
diff --git a/ui/gfx/mojo/struct_traits_unittest.cc b/ui/gfx/mojo/struct_traits_unittest.cc
index e7cb15f72250c6cd519b9b19ea3e799d56d932b2..addb13d5855437d03dfc7b7eee50ca453be74370 100644
--- a/ui/gfx/mojo/struct_traits_unittest.cc
+++ b/ui/gfx/mojo/struct_traits_unittest.cc
@@ -144,10 +144,6 @@ TEST_F(StructTraitsTest, GpuMemoryBufferHandle) {
const gfx::GpuMemoryBufferId kId(99);
const uint32_t kOffset = 126;
const int32_t kStride = 256;
-#if defined(USE_OZONE)
- const uint64_t kSize = kOffset + kStride;
- const uint64_t kModifier = 2;
-#endif
base::SharedMemory shared_memory;
ASSERT_TRUE(shared_memory.CreateAnonymous(1024));
ASSERT_TRUE(shared_memory.Map(1024));
@@ -159,11 +155,6 @@ TEST_F(StructTraitsTest, GpuMemoryBufferHandle) {
handle.offset = kOffset;
handle.stride = kStride;
-#if defined(USE_OZONE)
- handle.native_pixmap_handle.planes.emplace_back(kOffset, kStride, kSize,
- kModifier);
-#endif
-
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
gfx::GpuMemoryBufferHandle output;
proxy->EchoGpuMemoryBufferHandle(handle, &output);
@@ -172,17 +163,26 @@ TEST_F(StructTraitsTest, GpuMemoryBufferHandle) {
EXPECT_EQ(kOffset, output.offset);
EXPECT_EQ(kStride, output.stride);
-#if defined(USE_OZONE)
- ASSERT_EQ(1u, output.native_pixmap_handle.planes.size());
- EXPECT_EQ(kSize, output.native_pixmap_handle.planes.back().size);
- EXPECT_EQ(kModifier, output.native_pixmap_handle.planes.back().modifier);
-#endif
-
#if !defined(OS_MACOSX) && !defined(OS_IOS)
// TODO: Add support for mach_port on mac.
base::SharedMemory output_memory(output.handle, true);
EXPECT_TRUE(output_memory.Map(1024));
#endif
+
+#if defined(USE_OZONE)
+ const uint64_t kSize = kOffset + kStride;
+ const uint64_t kModifier = 2;
+ handle.type = gfx::OZONE_NATIVE_PIXMAP;
+ handle.id = kId;
+ handle.native_pixmap_handle.planes.emplace_back(kOffset, kStride, kSize,
+ kModifier);
+ proxy->EchoGpuMemoryBufferHandle(handle, &output);
+ EXPECT_EQ(gfx::OZONE_NATIVE_PIXMAP, output.type);
+ EXPECT_EQ(kId, output.id);
+ ASSERT_EQ(1u, output.native_pixmap_handle.planes.size());
+ EXPECT_EQ(kSize, output.native_pixmap_handle.planes.back().size);
+ EXPECT_EQ(kModifier, output.native_pixmap_handle.planes.back().modifier);
+#endif
}
TEST_F(StructTraitsTest, NullGpuMemoryBufferHandle) {
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698