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

Side by Side Diff: minidump/minidump_memory_info_writer_test.cc

Issue 1483073004: Replace use of .Pass() with crashpad::move(). (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: pass: . Created 5 years 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 | « minidump/minidump_handle_writer_test.cc ('k') | minidump/minidump_memory_writer.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 Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_memory_info_writer.h" 15 #include "minidump/minidump_memory_info_writer.h"
16 16
17 #include <string> 17 #include <string>
18 18
19 #include "gtest/gtest.h" 19 #include "gtest/gtest.h"
20 #include "minidump/minidump_file_writer.h" 20 #include "minidump/minidump_file_writer.h"
21 #include "minidump/test/minidump_file_writer_test_util.h" 21 #include "minidump/test/minidump_file_writer_test_util.h"
22 #include "minidump/test/minidump_writable_test_util.h" 22 #include "minidump/test/minidump_writable_test_util.h"
23 #include "snapshot/test/test_memory_map_region_snapshot.h" 23 #include "snapshot/test/test_memory_map_region_snapshot.h"
24 #include "util/file/string_file.h" 24 #include "util/file/string_file.h"
25 #include "util/stdlib/move.h"
25 26
26 namespace crashpad { 27 namespace crashpad {
27 namespace test { 28 namespace test {
28 namespace { 29 namespace {
29 30
30 // The memory info list is expected to be the only stream. 31 // The memory info list is expected to be the only stream.
31 void GetMemoryInfoListStream( 32 void GetMemoryInfoListStream(
32 const std::string& file_contents, 33 const std::string& file_contents,
33 const MINIDUMP_MEMORY_INFO_LIST** memory_info_list) { 34 const MINIDUMP_MEMORY_INFO_LIST** memory_info_list) {
34 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 35 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
(...skipping 16 matching lines...) Expand all
51 *memory_info_list = 52 *memory_info_list =
52 MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_INFO_LIST>( 53 MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_INFO_LIST>(
53 file_contents, directory[kDirectoryIndex].Location); 54 file_contents, directory[kDirectoryIndex].Location);
54 ASSERT_TRUE(*memory_info_list); 55 ASSERT_TRUE(*memory_info_list);
55 } 56 }
56 57
57 TEST(MinidumpMemoryInfoWriter, Empty) { 58 TEST(MinidumpMemoryInfoWriter, Empty) {
58 MinidumpFileWriter minidump_file_writer; 59 MinidumpFileWriter minidump_file_writer;
59 auto memory_info_list_writer = 60 auto memory_info_list_writer =
60 make_scoped_ptr(new MinidumpMemoryInfoListWriter()); 61 make_scoped_ptr(new MinidumpMemoryInfoListWriter());
61 minidump_file_writer.AddStream(memory_info_list_writer.Pass()); 62 minidump_file_writer.AddStream(crashpad::move(memory_info_list_writer));
62 63
63 StringFile string_file; 64 StringFile string_file;
64 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 65 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
65 66
66 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 67 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
67 sizeof(MINIDUMP_MEMORY_INFO_LIST), 68 sizeof(MINIDUMP_MEMORY_INFO_LIST),
68 string_file.string().size()); 69 string_file.string().size());
69 70
70 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr; 71 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr;
71 ASSERT_NO_FATAL_FAILURE( 72 ASSERT_NO_FATAL_FAILURE(
(...skipping 16 matching lines...) Expand all
88 mmi.RegionSize = 0x6000; 89 mmi.RegionSize = 0x6000;
89 mmi.State = MEM_COMMIT; 90 mmi.State = MEM_COMMIT;
90 mmi.Protect = PAGE_NOACCESS; 91 mmi.Protect = PAGE_NOACCESS;
91 mmi.Type = MEM_PRIVATE; 92 mmi.Type = MEM_PRIVATE;
92 memory_map_region->SetMindumpMemoryInfo(mmi); 93 memory_map_region->SetMindumpMemoryInfo(mmi);
93 94
94 std::vector<const MemoryMapRegionSnapshot*> memory_map; 95 std::vector<const MemoryMapRegionSnapshot*> memory_map;
95 memory_map.push_back(memory_map_region.get()); 96 memory_map.push_back(memory_map_region.get());
96 memory_info_list_writer->InitializeFromSnapshot(memory_map); 97 memory_info_list_writer->InitializeFromSnapshot(memory_map);
97 98
98 minidump_file_writer.AddStream(memory_info_list_writer.Pass()); 99 minidump_file_writer.AddStream(crashpad::move(memory_info_list_writer));
99 100
100 StringFile string_file; 101 StringFile string_file;
101 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 102 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
102 103
103 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 104 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
104 sizeof(MINIDUMP_MEMORY_INFO_LIST) + 105 sizeof(MINIDUMP_MEMORY_INFO_LIST) +
105 sizeof(MINIDUMP_MEMORY_INFO), 106 sizeof(MINIDUMP_MEMORY_INFO),
106 string_file.string().size()); 107 string_file.string().size());
107 108
108 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr; 109 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr;
109 ASSERT_NO_FATAL_FAILURE( 110 ASSERT_NO_FATAL_FAILURE(
110 GetMemoryInfoListStream(string_file.string(), &memory_info_list)); 111 GetMemoryInfoListStream(string_file.string(), &memory_info_list));
111 112
112 EXPECT_EQ(1u, memory_info_list->NumberOfEntries); 113 EXPECT_EQ(1u, memory_info_list->NumberOfEntries);
113 const MINIDUMP_MEMORY_INFO* memory_info = 114 const MINIDUMP_MEMORY_INFO* memory_info =
114 reinterpret_cast<const MINIDUMP_MEMORY_INFO*>(&memory_info_list[1]); 115 reinterpret_cast<const MINIDUMP_MEMORY_INFO*>(&memory_info_list[1]);
115 EXPECT_EQ(mmi.BaseAddress, memory_info->BaseAddress); 116 EXPECT_EQ(mmi.BaseAddress, memory_info->BaseAddress);
116 EXPECT_EQ(mmi.AllocationBase, memory_info->AllocationBase); 117 EXPECT_EQ(mmi.AllocationBase, memory_info->AllocationBase);
117 EXPECT_EQ(mmi.AllocationProtect, memory_info->AllocationProtect); 118 EXPECT_EQ(mmi.AllocationProtect, memory_info->AllocationProtect);
118 EXPECT_EQ(mmi.RegionSize, memory_info->RegionSize); 119 EXPECT_EQ(mmi.RegionSize, memory_info->RegionSize);
119 EXPECT_EQ(mmi.State, memory_info->State); 120 EXPECT_EQ(mmi.State, memory_info->State);
120 EXPECT_EQ(mmi.Protect, memory_info->Protect); 121 EXPECT_EQ(mmi.Protect, memory_info->Protect);
121 EXPECT_EQ(mmi.Type, memory_info->Type); 122 EXPECT_EQ(mmi.Type, memory_info->Type);
122 } 123 }
123 124
124 } // namespace 125 } // namespace
125 } // namespace test 126 } // namespace test
126 } // namespace crashpad 127 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_handle_writer_test.cc ('k') | minidump/minidump_memory_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698