OLD | NEW |
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, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 0); | 52 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 0); |
53 ASSERT_TRUE(module_list); | 53 ASSERT_TRUE(module_list); |
54 | 54 |
55 EXPECT_EQ(0u, module_list->count); | 55 EXPECT_EQ(0u, module_list->count); |
56 } | 56 } |
57 | 57 |
58 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { | 58 TEST(MinidumpModuleCrashpadInfoWriter, EmptyModule) { |
59 StringFileWriter file_writer; | 59 StringFileWriter file_writer; |
60 | 60 |
61 MinidumpModuleCrashpadInfoListWriter module_list_writer; | 61 MinidumpModuleCrashpadInfoListWriter module_list_writer; |
62 MinidumpModuleCrashpadInfoWriter module_writer; | 62 auto module_writer = |
63 module_list_writer.AddModule(&module_writer); | 63 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
| 64 module_list_writer.AddModule(module_writer.Pass()); |
64 | 65 |
65 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); | 66 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); |
66 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + | 67 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + |
67 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + | 68 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + |
68 sizeof(MinidumpModuleCrashpadInfo), | 69 sizeof(MinidumpModuleCrashpadInfo), |
69 file_writer.string().size()); | 70 file_writer.string().size()); |
70 | 71 |
71 const MinidumpModuleCrashpadInfoList* module_list = | 72 const MinidumpModuleCrashpadInfoList* module_list = |
72 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 1); | 73 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 1); |
73 ASSERT_TRUE(module_list); | 74 ASSERT_TRUE(module_list); |
(...skipping 13 matching lines...) Expand all Loading... |
87 | 88 |
88 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) { | 89 TEST(MinidumpModuleCrashpadInfoWriter, FullModule) { |
89 const uint32_t kMinidumpModuleListIndex = 1; | 90 const uint32_t kMinidumpModuleListIndex = 1; |
90 const char kKey[] = "key"; | 91 const char kKey[] = "key"; |
91 const char kValue[] = "value"; | 92 const char kValue[] = "value"; |
92 | 93 |
93 StringFileWriter file_writer; | 94 StringFileWriter file_writer; |
94 | 95 |
95 MinidumpModuleCrashpadInfoListWriter module_list_writer; | 96 MinidumpModuleCrashpadInfoListWriter module_list_writer; |
96 | 97 |
97 MinidumpModuleCrashpadInfoWriter module_writer; | 98 auto module_writer = |
98 module_writer.SetMinidumpModuleListIndex(kMinidumpModuleListIndex); | 99 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
99 MinidumpSimpleStringDictionaryWriter simple_string_dictionary_writer; | 100 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex); |
100 MinidumpSimpleStringDictionaryEntryWriter | 101 auto simple_string_dictionary_writer = |
101 simple_string_dictionary_entry_writer; | 102 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); |
102 simple_string_dictionary_entry_writer.SetKeyValue(kKey, kValue); | 103 auto simple_string_dictionary_entry_writer = |
103 simple_string_dictionary_writer.AddEntry( | 104 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); |
104 &simple_string_dictionary_entry_writer); | 105 simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue); |
105 module_writer.SetSimpleAnnotations(&simple_string_dictionary_writer); | 106 simple_string_dictionary_writer->AddEntry( |
106 module_list_writer.AddModule(&module_writer); | 107 simple_string_dictionary_entry_writer.Pass()); |
| 108 module_writer->SetSimpleAnnotations(simple_string_dictionary_writer.Pass()); |
| 109 module_list_writer.AddModule(module_writer.Pass()); |
107 | 110 |
108 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); | 111 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); |
109 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + | 112 ASSERT_EQ(sizeof(MinidumpModuleCrashpadInfoList) + |
110 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + | 113 sizeof(MINIDUMP_LOCATION_DESCRIPTOR) + |
111 sizeof(MinidumpModuleCrashpadInfo) + | 114 sizeof(MinidumpModuleCrashpadInfo) + |
112 sizeof(MinidumpSimpleStringDictionary) + | 115 sizeof(MinidumpSimpleStringDictionary) + |
113 sizeof(MinidumpSimpleStringDictionaryEntry) + | 116 sizeof(MinidumpSimpleStringDictionaryEntry) + |
114 sizeof(MinidumpUTF8String) + arraysize(kKey) + | 117 sizeof(MinidumpUTF8String) + arraysize(kKey) + |
115 sizeof(MinidumpUTF8String) + arraysize(kValue), | 118 sizeof(MinidumpUTF8String) + arraysize(kValue), |
116 file_writer.string().size()); | 119 file_writer.string().size()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 const uint32_t kMinidumpModuleListIndex2 = 5; | 156 const uint32_t kMinidumpModuleListIndex2 = 5; |
154 const char kKey2A[] = "K"; | 157 const char kKey2A[] = "K"; |
155 const char kValue2A[] = "VVV"; | 158 const char kValue2A[] = "VVV"; |
156 const char kKey2B[] = "river"; | 159 const char kKey2B[] = "river"; |
157 const char kValue2B[] = "hudson"; | 160 const char kValue2B[] = "hudson"; |
158 | 161 |
159 StringFileWriter file_writer; | 162 StringFileWriter file_writer; |
160 | 163 |
161 MinidumpModuleCrashpadInfoListWriter module_list_writer; | 164 MinidumpModuleCrashpadInfoListWriter module_list_writer; |
162 | 165 |
163 MinidumpModuleCrashpadInfoWriter module_writer_0; | 166 auto module_writer_0 = |
164 module_writer_0.SetMinidumpModuleListIndex(kMinidumpModuleListIndex0); | 167 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
165 MinidumpSimpleStringDictionaryWriter simple_string_dictionary_writer_0; | 168 module_writer_0->SetMinidumpModuleListIndex(kMinidumpModuleListIndex0); |
166 MinidumpSimpleStringDictionaryEntryWriter | 169 auto simple_string_dictionary_writer_0 = |
167 simple_string_dictionary_entry_writer_0; | 170 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); |
168 simple_string_dictionary_entry_writer_0.SetKeyValue(kKey0, kValue0); | 171 auto simple_string_dictionary_entry_writer_0 = |
169 simple_string_dictionary_writer_0.AddEntry( | 172 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); |
170 &simple_string_dictionary_entry_writer_0); | 173 simple_string_dictionary_entry_writer_0->SetKeyValue(kKey0, kValue0); |
171 module_writer_0.SetSimpleAnnotations(&simple_string_dictionary_writer_0); | 174 simple_string_dictionary_writer_0->AddEntry( |
172 module_list_writer.AddModule(&module_writer_0); | 175 simple_string_dictionary_entry_writer_0.Pass()); |
| 176 module_writer_0->SetSimpleAnnotations( |
| 177 simple_string_dictionary_writer_0.Pass()); |
| 178 module_list_writer.AddModule(module_writer_0.Pass()); |
173 | 179 |
174 MinidumpModuleCrashpadInfoWriter module_writer_1; | 180 auto module_writer_1 = |
175 module_writer_1.SetMinidumpModuleListIndex(kMinidumpModuleListIndex1); | 181 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
176 module_list_writer.AddModule(&module_writer_1); | 182 module_writer_1->SetMinidumpModuleListIndex(kMinidumpModuleListIndex1); |
| 183 module_list_writer.AddModule(module_writer_1.Pass()); |
177 | 184 |
178 MinidumpModuleCrashpadInfoWriter module_writer_2; | 185 auto module_writer_2 = |
179 module_writer_2.SetMinidumpModuleListIndex(kMinidumpModuleListIndex2); | 186 make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
180 MinidumpSimpleStringDictionaryWriter simple_string_dictionary_writer_2; | 187 module_writer_2->SetMinidumpModuleListIndex(kMinidumpModuleListIndex2); |
181 MinidumpSimpleStringDictionaryEntryWriter | 188 auto simple_string_dictionary_writer_2 = |
182 simple_string_dictionary_entry_writer_2a; | 189 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); |
183 simple_string_dictionary_entry_writer_2a.SetKeyValue(kKey2A, kValue2A); | 190 auto simple_string_dictionary_entry_writer_2a = |
184 simple_string_dictionary_writer_2.AddEntry( | 191 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); |
185 &simple_string_dictionary_entry_writer_2a); | 192 simple_string_dictionary_entry_writer_2a->SetKeyValue(kKey2A, kValue2A); |
186 MinidumpSimpleStringDictionaryEntryWriter | 193 simple_string_dictionary_writer_2->AddEntry( |
187 simple_string_dictionary_entry_writer_2b; | 194 simple_string_dictionary_entry_writer_2a.Pass()); |
188 simple_string_dictionary_entry_writer_2b.SetKeyValue(kKey2B, kValue2B); | 195 auto simple_string_dictionary_entry_writer_2b = |
189 simple_string_dictionary_writer_2.AddEntry( | 196 make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter()); |
190 &simple_string_dictionary_entry_writer_2b); | 197 simple_string_dictionary_entry_writer_2b->SetKeyValue(kKey2B, kValue2B); |
191 module_writer_2.SetSimpleAnnotations(&simple_string_dictionary_writer_2); | 198 simple_string_dictionary_writer_2->AddEntry( |
192 module_list_writer.AddModule(&module_writer_2); | 199 simple_string_dictionary_entry_writer_2b.Pass()); |
| 200 module_writer_2->SetSimpleAnnotations( |
| 201 simple_string_dictionary_writer_2.Pass()); |
| 202 module_list_writer.AddModule(module_writer_2.Pass()); |
193 | 203 |
194 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); | 204 EXPECT_TRUE(module_list_writer.WriteEverything(&file_writer)); |
195 | 205 |
196 const MinidumpModuleCrashpadInfoList* module_list = | 206 const MinidumpModuleCrashpadInfoList* module_list = |
197 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 3); | 207 MinidumpModuleCrashpadInfoListAtStart(file_writer.string(), 3); |
198 ASSERT_TRUE(module_list); | 208 ASSERT_TRUE(module_list); |
199 | 209 |
200 ASSERT_EQ(3u, module_list->count); | 210 ASSERT_EQ(3u, module_list->count); |
201 | 211 |
202 const MinidumpModuleCrashpadInfo* module_0 = | 212 const MinidumpModuleCrashpadInfo* module_0 = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 MinidumpUTF8StringAtRVAAsString( | 267 MinidumpUTF8StringAtRVAAsString( |
258 file_writer.string(), simple_annotations_2->entries[1].key)); | 268 file_writer.string(), simple_annotations_2->entries[1].key)); |
259 EXPECT_EQ(kValue2B, | 269 EXPECT_EQ(kValue2B, |
260 MinidumpUTF8StringAtRVAAsString( | 270 MinidumpUTF8StringAtRVAAsString( |
261 file_writer.string(), simple_annotations_2->entries[1].value)); | 271 file_writer.string(), simple_annotations_2->entries[1].value)); |
262 } | 272 } |
263 | 273 |
264 } // namespace | 274 } // namespace |
265 } // namespace test | 275 } // namespace test |
266 } // namespace crashpad | 276 } // namespace crashpad |
OLD | NEW |