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

Side by Side Diff: components/display_compositor/host_shared_bitmap_manager_unittest.cc

Issue 2828353004: Remove HostSharedBitmapManager::AllocateSharedBitmapForChild (Closed)
Patch Set: Created 3 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
« no previous file with comments | « components/display_compositor/host_shared_bitmap_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "components/display_compositor/host_shared_bitmap_manager.h" 8 #include "components/display_compositor/host_shared_bitmap_manager.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 client.DidDeleteSharedBitmap(id); 69 client.DidDeleteSharedBitmap(id);
70 70
71 memset(bitmap->memory(), 0, size_in_bytes); 71 memset(bitmap->memory(), 0, size_in_bytes);
72 72
73 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), 73 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
74 0); 74 0);
75 bitmap.reset(); 75 bitmap.reset();
76 shared_bitmap.reset(); 76 shared_bitmap.reset();
77 } 77 }
78 78
79 TEST_F(HostSharedBitmapManagerTest, TestCreateForChild) {
80 gfx::Size bitmap_size(1, 1);
81 size_t size_in_bytes;
82 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
83 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
84 HostSharedBitmapManagerClient client(manager_.get());
85 base::SharedMemoryHandle handle;
86 client.AllocateSharedBitmapForChild(base::GetCurrentProcessHandle(),
87 size_in_bytes, id, &handle);
88
89 EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle));
90 std::unique_ptr<base::SharedMemory> bitmap(
91 new base::SharedMemory(handle, false));
92 EXPECT_TRUE(bitmap->Map(size_in_bytes));
93 memset(bitmap->memory(), 0xff, size_in_bytes);
94
95 std::unique_ptr<cc::SharedBitmap> shared_bitmap;
96 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
97 EXPECT_TRUE(shared_bitmap);
98 EXPECT_TRUE(
99 memcmp(bitmap->memory(), shared_bitmap->pixels(), size_in_bytes) == 0);
100
101 client.DidDeleteSharedBitmap(id);
102 }
103
104 TEST_F(HostSharedBitmapManagerTest, RemoveProcess) { 79 TEST_F(HostSharedBitmapManagerTest, RemoveProcess) {
105 gfx::Size bitmap_size(1, 1); 80 gfx::Size bitmap_size(1, 1);
106 size_t size_in_bytes; 81 size_t size_in_bytes;
107 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); 82 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
108 std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); 83 std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
109 bitmap->CreateAndMapAnonymous(size_in_bytes); 84 bitmap->CreateAndMapAnonymous(size_in_bytes);
110 memset(bitmap->memory(), 0xff, size_in_bytes); 85 memset(bitmap->memory(), 0xff, size_in_bytes);
111 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); 86 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
112 87
113 base::SharedMemoryHandle handle; 88 base::SharedMemoryHandle handle;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 std::unique_ptr<cc::SharedBitmap> shared_bitmap; 131 std::unique_ptr<cc::SharedBitmap> shared_bitmap;
157 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); 132 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
158 ASSERT_TRUE(shared_bitmap.get() != NULL); 133 ASSERT_TRUE(shared_bitmap.get() != NULL);
159 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), 134 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
160 0); 135 0);
161 client.DidDeleteSharedBitmap(id); 136 client.DidDeleteSharedBitmap(id);
162 } 137 }
163 138
164 } // namespace 139 } // namespace
165 } // namespace display_compositor 140 } // namespace display_compositor
OLDNEW
« no previous file with comments | « components/display_compositor/host_shared_bitmap_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698