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

Side by Side Diff: minidump/minidump_module_crashpad_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_module_crashpad_info_writer.cc ('k') | minidump/minidump_module_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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 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_module_crashpad_info_writer.h" 15 #include "minidump/minidump_module_crashpad_info_writer.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 19
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 21 #include "minidump/minidump_extensions.h"
22 #include "minidump/minidump_simple_string_dictionary_writer.h" 22 #include "minidump/minidump_simple_string_dictionary_writer.h"
23 #include "minidump/test/minidump_file_writer_test_util.h" 23 #include "minidump/test/minidump_file_writer_test_util.h"
24 #include "minidump/test/minidump_string_writer_test_util.h" 24 #include "minidump/test/minidump_string_writer_test_util.h"
25 #include "minidump/test/minidump_writable_test_util.h" 25 #include "minidump/test/minidump_writable_test_util.h"
26 #include "snapshot/test/test_module_snapshot.h" 26 #include "snapshot/test/test_module_snapshot.h"
27 #include "util/file/string_file.h" 27 #include "util/file/string_file.h"
28 #include "util/stdlib/move.h"
28 29
29 namespace crashpad { 30 namespace crashpad {
30 namespace test { 31 namespace test {
31 namespace { 32 namespace {
32 33
33 const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart( 34 const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart(
34 const std::string& file_contents, 35 const std::string& file_contents,
35 size_t count) { 36 size_t count) {
36 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; 37 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
37 location_descriptor.DataSize = 38 location_descriptor.DataSize =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ASSERT_TRUE(module_list); 71 ASSERT_TRUE(module_list);
71 } 72 }
72 73
73 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { 74 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) {
74 StringFile string_file; 75 StringFile string_file;
75 76
76 auto module_list_writer = 77 auto module_list_writer =
77 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 78 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
78 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 79 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
79 EXPECT_FALSE(module_writer->IsUseful()); 80 EXPECT_FALSE(module_writer->IsUseful());
80 module_list_writer->AddModule(module_writer.Pass(), 0); 81 module_list_writer->AddModule(crashpad::move(module_writer), 0);
81 82
82 EXPECT_TRUE(module_list_writer->IsUseful()); 83 EXPECT_TRUE(module_list_writer->IsUseful());
83 84
84 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 85 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
85 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 86 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
86 sizeof(MinidumpModuleCrashpadInfoLink) + 87 sizeof(MinidumpModuleCrashpadInfoLink) +
87 sizeof(MinidumpModuleCrashpadInfo), 88 sizeof(MinidumpModuleCrashpadInfo),
88 string_file.string().size()); 89 string_file.string().size());
89 90
90 const MinidumpModuleCrashpadInfoList* module_list = 91 const MinidumpModuleCrashpadInfoList* module_list =
(...skipping 21 matching lines...) Expand all
112 std::vector<std::string> vector(1, std::string(kEntry)); 113 std::vector<std::string> vector(1, std::string(kEntry));
113 114
114 StringFile string_file; 115 StringFile string_file;
115 116
116 auto module_list_writer = 117 auto module_list_writer =
117 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 118 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
118 119
119 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 120 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
120 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter()); 121 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter());
121 string_list_writer->InitializeFromVector(vector); 122 string_list_writer->InitializeFromVector(vector);
122 module_writer->SetListAnnotations(string_list_writer.Pass()); 123 module_writer->SetListAnnotations(crashpad::move(string_list_writer));
123 auto simple_string_dictionary_writer = 124 auto simple_string_dictionary_writer =
124 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 125 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
125 auto simple_string_dictionary_entry_writer = 126 auto simple_string_dictionary_entry_writer =
126 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 127 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
127 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue); 128 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue);
128 simple_string_dictionary_writer->AddEntry( 129 simple_string_dictionary_writer->AddEntry(
129 simple_string_dictionary_entry_writer.Pass()); 130 crashpad::move(simple_string_dictionary_entry_writer));
130 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass()); 131 module_writer->SetSimpleAnnotations(
132 crashpad::move(simple_string_dictionary_writer));
131 EXPECT_TRUE(module_writer->IsUseful()); 133 EXPECT_TRUE(module_writer->IsUseful());
132 module_list_writer->AddModule(module_writer.Pass(), kMinidumpModuleListIndex); 134 module_list_writer->AddModule(crashpad::move(module_writer),
135 kMinidumpModuleListIndex);
133 136
134 EXPECT_TRUE(module_list_writer->IsUseful()); 137 EXPECT_TRUE(module_list_writer->IsUseful());
135 138
136 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 139 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
137 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 140 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
138 sizeof(MinidumpModuleCrashpadInfoLink) + 141 sizeof(MinidumpModuleCrashpadInfoLink) +
139 sizeof(MinidumpModuleCrashpadInfo) + 142 sizeof(MinidumpModuleCrashpadInfo) +
140 sizeof(MinidumpRVAList) + 143 sizeof(MinidumpRVAList) +
141 sizeof(RVA) + 144 sizeof(RVA) +
142 sizeof(MinidumpSimpleStringDictionary) + 145 sizeof(MinidumpSimpleStringDictionary) +
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 207 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
205 208
206 auto module_writer_0 = 209 auto module_writer_0 =
207 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 210 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
208 auto simple_string_dictionary_writer_0 = 211 auto simple_string_dictionary_writer_0 =
209 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 212 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
210 auto simple_string_dictionary_entry_writer_0 = 213 auto simple_string_dictionary_entry_writer_0 =
211 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 214 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
212 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0); 215 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0);
213 simple_string_dictionary_writer_0->AddEntry( 216 simple_string_dictionary_writer_0->AddEntry(
214 simple_string_dictionary_entry_writer_0.Pass()); 217 crashpad::move(simple_string_dictionary_entry_writer_0));
215 module_writer_0->SetSimpleAnnotations( 218 module_writer_0->SetSimpleAnnotations(
216 simple_string_dictionary_writer_0.Pass()); 219 crashpad::move(simple_string_dictionary_writer_0));
217 EXPECT_TRUE(module_writer_0->IsUseful()); 220 EXPECT_TRUE(module_writer_0->IsUseful());
218 module_list_writer->AddModule(module_writer_0.Pass(), 221 module_list_writer->AddModule(crashpad::move(module_writer_0),
219 kMinidumpModuleListIndex0); 222 kMinidumpModuleListIndex0);
220 223
221 auto module_writer_1 = 224 auto module_writer_1 =
222 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 225 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
223 EXPECT_FALSE(module_writer_1->IsUseful()); 226 EXPECT_FALSE(module_writer_1->IsUseful());
224 module_list_writer->AddModule(module_writer_1.Pass(), 227 module_list_writer->AddModule(crashpad::move(module_writer_1),
225 kMinidumpModuleListIndex1); 228 kMinidumpModuleListIndex1);
226 229
227 auto module_writer_2 = 230 auto module_writer_2 =
228 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 231 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
229 auto simple_string_dictionary_writer_2 = 232 auto simple_string_dictionary_writer_2 =
230 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 233 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
231 auto simple_string_dictionary_entry_writer_2a = 234 auto simple_string_dictionary_entry_writer_2a =
232 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 235 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
233 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A); 236 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A);
234 simple_string_dictionary_writer_2->AddEntry( 237 simple_string_dictionary_writer_2->AddEntry(
235 simple_string_dictionary_entry_writer_2a.Pass()); 238 crashpad::move(simple_string_dictionary_entry_writer_2a));
236 auto simple_string_dictionary_entry_writer_2b = 239 auto simple_string_dictionary_entry_writer_2b =
237 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 240 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
238 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B); 241 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B);
239 simple_string_dictionary_writer_2->AddEntry( 242 simple_string_dictionary_writer_2->AddEntry(
240 simple_string_dictionary_entry_writer_2b.Pass()); 243 crashpad::move(simple_string_dictionary_entry_writer_2b));
241 module_writer_2->SetSimpleAnnotations( 244 module_writer_2->SetSimpleAnnotations(
242 simple_string_dictionary_writer_2.Pass()); 245 crashpad::move(simple_string_dictionary_writer_2));
243 EXPECT_TRUE(module_writer_2->IsUseful()); 246 EXPECT_TRUE(module_writer_2->IsUseful());
244 module_list_writer->AddModule(module_writer_2.Pass(), 247 module_list_writer->AddModule(crashpad::move(module_writer_2),
245 kMinidumpModuleListIndex2); 248 kMinidumpModuleListIndex2);
246 249
247 EXPECT_TRUE(module_list_writer->IsUseful()); 250 EXPECT_TRUE(module_list_writer->IsUseful());
248 251
249 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 252 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
250 253
251 const MinidumpModuleCrashpadInfoList* module_list = 254 const MinidumpModuleCrashpadInfoList* module_list =
252 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3); 255 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3);
253 ASSERT_TRUE(module_list); 256 ASSERT_TRUE(module_list);
254 257
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 465
463 const MinidumpSimpleStringDictionary* simple_annotations_3 = 466 const MinidumpSimpleStringDictionary* simple_annotations_3 =
464 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 467 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
465 string_file.string(), module_3->simple_annotations); 468 string_file.string(), module_3->simple_annotations);
466 EXPECT_FALSE(simple_annotations_3); 469 EXPECT_FALSE(simple_annotations_3);
467 } 470 }
468 471
469 } // namespace 472 } // namespace
470 } // namespace test 473 } // namespace test
471 } // namespace crashpad 474 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_module_crashpad_info_writer.cc ('k') | minidump/minidump_module_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698