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

Unified Diff: components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc

Issue 2909873002: Add cc::SharedBitmap::shared_memory_handle() (Closed)
Patch Set: fix tests Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc
diff --git a/components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc b/components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc
index ee7a92f1ab80f70dc4b43c5b18d54ec208d9173f..c129e1dfb76768a6c0d12e123bc53748206edf2a 100644
--- a/components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc
+++ b/components/viz/display_compositor/host_shared_bitmap_manager_unittest.cc
@@ -133,5 +133,27 @@ TEST_F(HostSharedBitmapManagerTest, AddDuplicate) {
client.DidDeleteSharedBitmap(id);
}
+TEST_F(HostSharedBitmapManagerTest, SharedMemoryHandle) {
+ gfx::Size bitmap_size(1, 1);
+ size_t size_in_bytes;
+ EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
+ std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
+ auto shared_memory_guid = bitmap->handle().GetGUID();
+ bitmap->CreateAndMapAnonymous(size_in_bytes);
+ memset(bitmap->memory(), 0xff, size_in_bytes);
+ cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
+
+ HostSharedBitmapManagerClient client(manager_.get());
+ base::SharedMemoryHandle handle = bitmap->handle().Duplicate();
+ client.ChildAllocatedSharedBitmap(size_in_bytes, handle, id);
+
+ std::unique_ptr<cc::SharedBitmap> shared_bitmap;
+ shared_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(1, 1), id);
+ EXPECT_EQ(shared_bitmap->GetSharedMemoryHandle().GetGUID(),
+ shared_memory_guid);
+
+ client.DidDeleteSharedBitmap(id);
+}
+
} // namespace
} // namespace viz

Powered by Google App Engine
This is Rietveld 408576698