| OLD | NEW |
| 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 "chrome/installer/util/lzma_file_allocator.h" | 5 #include "chrome/installer/util/lzma_file_allocator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 TEST_F(LzmaFileAllocatorTest, SizeIsZeroTest) { | 57 TEST_F(LzmaFileAllocatorTest, SizeIsZeroTest) { |
| 58 LzmaFileAllocator allocator(temp_dir_.path()); | 58 LzmaFileAllocator allocator(temp_dir_.path()); |
| 59 char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, 0)); | 59 char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, 0)); |
| 60 EXPECT_EQ(s, nullptr); | 60 EXPECT_EQ(s, nullptr); |
| 61 | 61 |
| 62 IAlloc_Free(&allocator, s); | 62 IAlloc_Free(&allocator, s); |
| 63 } | 63 } |
| 64 | 64 |
| 65 TEST_F(LzmaFileAllocatorTest, DeleteAfterCloseTest) { | 65 TEST_F(LzmaFileAllocatorTest, DeleteAfterCloseTest) { |
| 66 std::unique_ptr<LzmaFileAllocator> allocator = | 66 std::unique_ptr<LzmaFileAllocator> allocator = |
| 67 base::WrapUnique(new LzmaFileAllocator(temp_dir_.path())); | 67 base::MakeUnique<LzmaFileAllocator>(temp_dir_.path()); |
| 68 base::FilePath file_path = allocator->mapped_file_path_; | 68 base::FilePath file_path = allocator->mapped_file_path_; |
| 69 ASSERT_TRUE(base::PathExists(file_path)); | 69 ASSERT_TRUE(base::PathExists(file_path)); |
| 70 allocator.reset(); | 70 allocator.reset(); |
| 71 ASSERT_FALSE(base::PathExists(file_path)); | 71 ASSERT_FALSE(base::PathExists(file_path)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST_F(LzmaFileAllocatorTest, ErrorAndFallbackTest) { | 74 TEST_F(LzmaFileAllocatorTest, ErrorAndFallbackTest) { |
| 75 LzmaFileAllocator allocator(temp_dir_.path()); | 75 LzmaFileAllocator allocator(temp_dir_.path()); |
| 76 allocator.mapped_file_.Close(); | 76 allocator.mapped_file_.Close(); |
| 77 char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, 10)); | 77 char* s = reinterpret_cast<char*>(IAlloc_Alloc(&allocator, 10)); |
| 78 EXPECT_NE(nullptr, s); | 78 EXPECT_NE(nullptr, s); |
| 79 ASSERT_FALSE(allocator.file_mapping_handle_.IsValid()); | 79 ASSERT_FALSE(allocator.file_mapping_handle_.IsValid()); |
| 80 EXPECT_EQ(static_cast<DWORD>(MEM_PRIVATE), GetMemoryType(s)); | 80 EXPECT_EQ(static_cast<DWORD>(MEM_PRIVATE), GetMemoryType(s)); |
| 81 | 81 |
| 82 IAlloc_Free(&allocator, s); | 82 IAlloc_Free(&allocator, s); |
| 83 } | 83 } |
| OLD | NEW |