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

Side by Side Diff: minidump/minidump_module_crashpad_info_writer_test.cc

Issue 1513573005: Provide std::move() in compat instead of using crashpad::move() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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 <utility>
21
20 #include "gtest/gtest.h" 22 #include "gtest/gtest.h"
21 #include "minidump/minidump_extensions.h" 23 #include "minidump/minidump_extensions.h"
22 #include "minidump/minidump_simple_string_dictionary_writer.h" 24 #include "minidump/minidump_simple_string_dictionary_writer.h"
23 #include "minidump/test/minidump_file_writer_test_util.h" 25 #include "minidump/test/minidump_file_writer_test_util.h"
24 #include "minidump/test/minidump_string_writer_test_util.h" 26 #include "minidump/test/minidump_string_writer_test_util.h"
25 #include "minidump/test/minidump_writable_test_util.h" 27 #include "minidump/test/minidump_writable_test_util.h"
26 #include "snapshot/test/test_module_snapshot.h" 28 #include "snapshot/test/test_module_snapshot.h"
27 #include "util/file/string_file.h" 29 #include "util/file/string_file.h"
28 #include "util/stdlib/move.h"
29 30
30 namespace crashpad { 31 namespace crashpad {
31 namespace test { 32 namespace test {
32 namespace { 33 namespace {
33 34
34 const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart( 35 const MinidumpModuleCrashpadInfoList* MinidumpModuleCrashpadInfoListAtStart(
35 const std::string& file_contents, 36 const std::string& file_contents,
36 size_t count) { 37 size_t count) {
37 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor; 38 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
38 location_descriptor.DataSize = 39 location_descriptor.DataSize =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ASSERT_TRUE(module_list); 72 ASSERT_TRUE(module_list);
72 } 73 }
73 74
74 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { 75 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) {
75 StringFile string_file; 76 StringFile string_file;
76 77
77 auto module_list_writer = 78 auto module_list_writer =
78 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 79 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
79 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 80 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
80 EXPECT_FALSE(module_writer->IsUseful()); 81 EXPECT_FALSE(module_writer->IsUseful());
81 module_list_writer->AddModule(crashpad::move(module_writer), 0); 82 module_list_writer->AddModule(std::move(module_writer), 0);
82 83
83 EXPECT_TRUE(module_list_writer->IsUseful()); 84 EXPECT_TRUE(module_list_writer->IsUseful());
84 85
85 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 86 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
86 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 87 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
87 sizeof(MinidumpModuleCrashpadInfoLink) + 88 sizeof(MinidumpModuleCrashpadInfoLink) +
88 sizeof(MinidumpModuleCrashpadInfo), 89 sizeof(MinidumpModuleCrashpadInfo),
89 string_file.string().size()); 90 string_file.string().size());
90 91
91 const MinidumpModuleCrashpadInfoList* module_list = 92 const MinidumpModuleCrashpadInfoList* module_list =
(...skipping 21 matching lines...) Expand all
113 std::vector<std::string> vector(1, std::string(kEntry)); 114 std::vector<std::string> vector(1, std::string(kEntry));
114 115
115 StringFile string_file; 116 StringFile string_file;
116 117
117 auto module_list_writer = 118 auto module_list_writer =
118 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 119 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
119 120
120 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 121 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
121 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter()); 122 auto string_list_writer = make_scoped_ptr(new MinidumpUTF8StringListWriter());
122 string_list_writer->InitializeFromVector(vector); 123 string_list_writer->InitializeFromVector(vector);
123 module_writer->SetListAnnotations(crashpad::move(string_list_writer)); 124 module_writer->SetListAnnotations(std::move(string_list_writer));
124 auto simple_string_dictionary_writer = 125 auto simple_string_dictionary_writer =
125 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 126 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
126 auto simple_string_dictionary_entry_writer = 127 auto simple_string_dictionary_entry_writer =
127 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 128 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
128 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue); 129 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue);
129 simple_string_dictionary_writer->AddEntry( 130 simple_string_dictionary_writer->AddEntry(
130 crashpad::move(simple_string_dictionary_entry_writer)); 131 std::move(simple_string_dictionary_entry_writer));
131 module_writer->SetSimpleAnnotations( 132 module_writer->SetSimpleAnnotations(
132 crashpad::move(simple_string_dictionary_writer)); 133 std::move(simple_string_dictionary_writer));
133 EXPECT_TRUE(module_writer->IsUseful()); 134 EXPECT_TRUE(module_writer->IsUseful());
134 module_list_writer->AddModule(crashpad::move(module_writer), 135 module_list_writer->AddModule(std::move(module_writer),
135 kMinidumpModuleListIndex); 136 kMinidumpModuleListIndex);
136 137
137 EXPECT_TRUE(module_list_writer->IsUseful()); 138 EXPECT_TRUE(module_list_writer->IsUseful());
138 139
139 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 140 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
140 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + 141 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) +
141 sizeof(MinidumpModuleCrashpadInfoLink) + 142 sizeof(MinidumpModuleCrashpadInfoLink) +
142 sizeof(MinidumpModuleCrashpadInfo) + 143 sizeof(MinidumpModuleCrashpadInfo) +
143 sizeof(MinidumpRVAList) + 144 sizeof(MinidumpRVAList) +
144 sizeof(RVA) + 145 sizeof(RVA) +
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 208 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
208 209
209 auto module_writer_0 = 210 auto module_writer_0 =
210 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 211 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
211 auto simple_string_dictionary_writer_0 = 212 auto simple_string_dictionary_writer_0 =
212 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 213 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
213 auto simple_string_dictionary_entry_writer_0 = 214 auto simple_string_dictionary_entry_writer_0 =
214 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 215 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
215 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0); 216 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0);
216 simple_string_dictionary_writer_0->AddEntry( 217 simple_string_dictionary_writer_0->AddEntry(
217 crashpad::move(simple_string_dictionary_entry_writer_0)); 218 std::move(simple_string_dictionary_entry_writer_0));
218 module_writer_0->SetSimpleAnnotations( 219 module_writer_0->SetSimpleAnnotations(
219 crashpad::move(simple_string_dictionary_writer_0)); 220 std::move(simple_string_dictionary_writer_0));
220 EXPECT_TRUE(module_writer_0->IsUseful()); 221 EXPECT_TRUE(module_writer_0->IsUseful());
221 module_list_writer->AddModule(crashpad::move(module_writer_0), 222 module_list_writer->AddModule(std::move(module_writer_0),
222 kMinidumpModuleListIndex0); 223 kMinidumpModuleListIndex0);
223 224
224 auto module_writer_1 = 225 auto module_writer_1 =
225 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 226 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
226 EXPECT_FALSE(module_writer_1->IsUseful()); 227 EXPECT_FALSE(module_writer_1->IsUseful());
227 module_list_writer->AddModule(crashpad::move(module_writer_1), 228 module_list_writer->AddModule(std::move(module_writer_1),
228 kMinidumpModuleListIndex1); 229 kMinidumpModuleListIndex1);
229 230
230 auto module_writer_2 = 231 auto module_writer_2 =
231 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 232 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
232 auto simple_string_dictionary_writer_2 = 233 auto simple_string_dictionary_writer_2 =
233 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 234 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
234 auto simple_string_dictionary_entry_writer_2a = 235 auto simple_string_dictionary_entry_writer_2a =
235 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 236 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
236 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A); 237 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A);
237 simple_string_dictionary_writer_2->AddEntry( 238 simple_string_dictionary_writer_2->AddEntry(
238 crashpad::move(simple_string_dictionary_entry_writer_2a)); 239 std::move(simple_string_dictionary_entry_writer_2a));
239 auto simple_string_dictionary_entry_writer_2b = 240 auto simple_string_dictionary_entry_writer_2b =
240 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); 241 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
241 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B); 242 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B);
242 simple_string_dictionary_writer_2->AddEntry( 243 simple_string_dictionary_writer_2->AddEntry(
243 crashpad::move(simple_string_dictionary_entry_writer_2b)); 244 std::move(simple_string_dictionary_entry_writer_2b));
244 module_writer_2->SetSimpleAnnotations( 245 module_writer_2->SetSimpleAnnotations(
245 crashpad::move(simple_string_dictionary_writer_2)); 246 std::move(simple_string_dictionary_writer_2));
246 EXPECT_TRUE(module_writer_2->IsUseful()); 247 EXPECT_TRUE(module_writer_2->IsUseful());
247 module_list_writer->AddModule(crashpad::move(module_writer_2), 248 module_list_writer->AddModule(std::move(module_writer_2),
248 kMinidumpModuleListIndex2); 249 kMinidumpModuleListIndex2);
249 250
250 EXPECT_TRUE(module_list_writer->IsUseful()); 251 EXPECT_TRUE(module_list_writer->IsUseful());
251 252
252 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file)); 253 EXPECT_TRUE(module_list_writer->WriteEverything(&string_file));
253 254
254 const MinidumpModuleCrashpadInfoList* module_list = 255 const MinidumpModuleCrashpadInfoList* module_list =
255 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3); 256 MinidumpModuleCrashpadInfoListAtStart(string_file.string(), 3);
256 ASSERT_TRUE(module_list); 257 ASSERT_TRUE(module_list);
257 258
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 466
466 const MinidumpSimpleStringDictionary* simple_annotations_3 = 467 const MinidumpSimpleStringDictionary* simple_annotations_3 =
467 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 468 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
468 string_file.string(), module_3->simple_annotations); 469 string_file.string(), module_3->simple_annotations);
469 EXPECT_FALSE(simple_annotations_3); 470 EXPECT_FALSE(simple_annotations_3);
470 } 471 }
471 472
472 } // namespace 473 } // namespace
473 } // namespace test 474 } // namespace test
474 } // namespace crashpad 475 } // 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