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

Side by Side Diff: components/exo/shared_memory_unittest.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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/exo/shared_memory.cc ('k') | components/exo/sub_surface_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/shared_memory.h" 5 #include "components/exo/shared_memory.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
11 #include "components/exo/test/exo_test_base.h" 11 #include "components/exo/test/exo_test_base.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gfx/buffer_format_util.h" 13 #include "ui/gfx/buffer_format_util.h"
14 14
15 namespace exo { 15 namespace exo {
16 namespace { 16 namespace {
17 17
18 using SharedMemoryTest = test::ExoTestBase; 18 using SharedMemoryTest = test::ExoTestBase;
19 19
20 std::unique_ptr<SharedMemory> CreateSharedMemory(size_t size) { 20 std::unique_ptr<SharedMemory> CreateSharedMemory(size_t size) {
21 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); 21 std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
22 bool rv = shared_memory->CreateAnonymous(size); 22 bool rv = shared_memory->CreateAnonymous(size);
23 DCHECK(rv); 23 DCHECK(rv);
24 base::SharedMemoryHandle handle = 24 base::SharedMemoryHandle handle =
25 base::SharedMemory::DuplicateHandle(shared_memory->handle()); 25 base::SharedMemory::DuplicateHandle(shared_memory->handle());
26 DCHECK(base::SharedMemory::IsHandleValid(handle)); 26 DCHECK(base::SharedMemory::IsHandleValid(handle));
27 return base::WrapUnique(new SharedMemory(handle)); 27 return base::MakeUnique<SharedMemory>(handle);
28 } 28 }
29 29
30 TEST_F(SharedMemoryTest, CreateBuffer) { 30 TEST_F(SharedMemoryTest, CreateBuffer) {
31 const gfx::Size buffer_size(256, 256); 31 const gfx::Size buffer_size(256, 256);
32 const gfx::BufferFormat format = gfx::BufferFormat::RGBA_8888; 32 const gfx::BufferFormat format = gfx::BufferFormat::RGBA_8888;
33 33
34 std::unique_ptr<SharedMemory> shared_memory = 34 std::unique_ptr<SharedMemory> shared_memory =
35 CreateSharedMemory(gfx::BufferSizeForBufferFormat(buffer_size, format)); 35 CreateSharedMemory(gfx::BufferSizeForBufferFormat(buffer_size, format));
36 ASSERT_TRUE(shared_memory); 36 ASSERT_TRUE(shared_memory);
37 37
(...skipping 16 matching lines...) Expand all
54 bottom_right_buffer_size, format, 54 bottom_right_buffer_size, format,
55 (buffer_size.height() - bottom_right_buffer_size.height()) * 55 (buffer_size.height() - bottom_right_buffer_size.height()) *
56 gfx::RowSizeForBufferFormat(buffer_size.width(), format, 0) + 56 gfx::RowSizeForBufferFormat(buffer_size.width(), format, 0) +
57 (buffer_size.width() - bottom_right_buffer_size.width()) * 4, 57 (buffer_size.width() - bottom_right_buffer_size.width()) * 4,
58 gfx::RowSizeForBufferFormat(buffer_size.width(), format, 0)); 58 gfx::RowSizeForBufferFormat(buffer_size.width(), format, 0));
59 EXPECT_TRUE(bottom_right_buffer); 59 EXPECT_TRUE(bottom_right_buffer);
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 } // namespace exo 63 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shared_memory.cc ('k') | components/exo/sub_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698