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

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

Issue 2717213004: Move SharedBitmapManager implementation out of content/ (Closed)
Patch Set: rebase 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') | content/browser/DEPS » ('j') | 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 "content/common/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
11 namespace content { 11 namespace display_compositor {
12 namespace { 12 namespace {
13 13
14 class HostSharedBitmapManagerTest : public testing::Test { 14 class HostSharedBitmapManagerTest : public testing::Test {
15 protected: 15 protected:
16 void SetUp() override { manager_.reset(new HostSharedBitmapManager()); } 16 void SetUp() override { manager_.reset(new HostSharedBitmapManager()); }
17 std::unique_ptr<HostSharedBitmapManager> manager_; 17 std::unique_ptr<HostSharedBitmapManager> manager_;
18 }; 18 };
19 19
20 TEST_F(HostSharedBitmapManagerTest, TestCreate) { 20 TEST_F(HostSharedBitmapManagerTest, TestCreate) {
21 gfx::Size bitmap_size(1, 1); 21 gfx::Size bitmap_size(1, 1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 large_bitmap2 = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id); 59 large_bitmap2 = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id);
60 EXPECT_TRUE(large_bitmap2.get() == NULL); 60 EXPECT_TRUE(large_bitmap2.get() == NULL);
61 61
62 std::unique_ptr<cc::SharedBitmap> shared_bitmap2; 62 std::unique_ptr<cc::SharedBitmap> shared_bitmap2;
63 shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id); 63 shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id);
64 EXPECT_TRUE(shared_bitmap2->pixels() == shared_bitmap->pixels()); 64 EXPECT_TRUE(shared_bitmap2->pixels() == shared_bitmap->pixels());
65 shared_bitmap2.reset(); 65 shared_bitmap2.reset();
66 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), 66 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
67 0); 67 0);
68 68
69 client.ChildDeletedSharedBitmap(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) { 79 TEST_F(HostSharedBitmapManagerTest, TestCreateForChild) {
(...skipping 11 matching lines...) Expand all
91 new base::SharedMemory(handle, false)); 91 new base::SharedMemory(handle, false));
92 EXPECT_TRUE(bitmap->Map(size_in_bytes)); 92 EXPECT_TRUE(bitmap->Map(size_in_bytes));
93 memset(bitmap->memory(), 0xff, size_in_bytes); 93 memset(bitmap->memory(), 0xff, size_in_bytes);
94 94
95 std::unique_ptr<cc::SharedBitmap> shared_bitmap; 95 std::unique_ptr<cc::SharedBitmap> shared_bitmap;
96 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); 96 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
97 EXPECT_TRUE(shared_bitmap); 97 EXPECT_TRUE(shared_bitmap);
98 EXPECT_TRUE( 98 EXPECT_TRUE(
99 memcmp(bitmap->memory(), shared_bitmap->pixels(), size_in_bytes) == 0); 99 memcmp(bitmap->memory(), shared_bitmap->pixels(), size_in_bytes) == 0);
100 100
101 client.ChildDeletedSharedBitmap(id); 101 client.DidDeleteSharedBitmap(id);
102 } 102 }
103 103
104 TEST_F(HostSharedBitmapManagerTest, RemoveProcess) { 104 TEST_F(HostSharedBitmapManagerTest, RemoveProcess) {
105 gfx::Size bitmap_size(1, 1); 105 gfx::Size bitmap_size(1, 1);
106 size_t size_in_bytes; 106 size_t size_in_bytes;
107 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); 107 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
108 std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); 108 std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
109 bitmap->CreateAndMapAnonymous(size_in_bytes); 109 bitmap->CreateAndMapAnonymous(size_in_bytes);
110 memset(bitmap->memory(), 0xff, size_in_bytes); 110 memset(bitmap->memory(), 0xff, size_in_bytes);
111 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); 111 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bitmap2->CreateAndMapAnonymous(size_in_bytes); 151 bitmap2->CreateAndMapAnonymous(size_in_bytes);
152 memset(bitmap2->memory(), 0x00, size_in_bytes); 152 memset(bitmap2->memory(), 0x00, size_in_bytes);
153 153
154 client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), id); 154 client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), id);
155 155
156 std::unique_ptr<cc::SharedBitmap> shared_bitmap; 156 std::unique_ptr<cc::SharedBitmap> shared_bitmap;
157 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); 157 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
158 ASSERT_TRUE(shared_bitmap.get() != NULL); 158 ASSERT_TRUE(shared_bitmap.get() != NULL);
159 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), 159 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
160 0); 160 0);
161 client.ChildDeletedSharedBitmap(id); 161 client.DidDeleteSharedBitmap(id);
162 } 162 }
163 163
164 } // namespace 164 } // namespace
165 } // namespace content 165 } // namespace display_compositor
OLDNEW
« no previous file with comments | « components/display_compositor/host_shared_bitmap_manager.cc ('k') | content/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698