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

Side by Side Diff: minidump/minidump_handle_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_file_writer_test.cc ('k') | minidump/minidump_memory_info_writer_test.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_handle_writer.h" 15 #include "minidump/minidump_handle_writer.h"
16 16
17 #include <string> 17 #include <string>
18 #include <utility>
18 19
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "gtest/gtest.h" 21 #include "gtest/gtest.h"
21 #include "minidump/minidump_file_writer.h" 22 #include "minidump/minidump_file_writer.h"
22 #include "minidump/test/minidump_file_writer_test_util.h" 23 #include "minidump/test/minidump_file_writer_test_util.h"
23 #include "minidump/test/minidump_string_writer_test_util.h" 24 #include "minidump/test/minidump_string_writer_test_util.h"
24 #include "minidump/test/minidump_writable_test_util.h" 25 #include "minidump/test/minidump_writable_test_util.h"
25 #include "util/file/string_file.h" 26 #include "util/file/string_file.h"
26 #include "util/stdlib/move.h"
27 27
28 namespace crashpad { 28 namespace crashpad {
29 namespace test { 29 namespace test {
30 namespace { 30 namespace {
31 31
32 // The handle data stream is expected to be the only stream. 32 // The handle data stream is expected to be the only stream.
33 void GetHandleDataStream( 33 void GetHandleDataStream(
34 const std::string& file_contents, 34 const std::string& file_contents,
35 const MINIDUMP_HANDLE_DATA_STREAM** handle_data_stream) { 35 const MINIDUMP_HANDLE_DATA_STREAM** handle_data_stream) {
36 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 36 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
(...skipping 14 matching lines...) Expand all
51 51
52 *handle_data_stream = 52 *handle_data_stream =
53 MinidumpWritableAtLocationDescriptor<MINIDUMP_HANDLE_DATA_STREAM>( 53 MinidumpWritableAtLocationDescriptor<MINIDUMP_HANDLE_DATA_STREAM>(
54 file_contents, directory[kDirectoryIndex].Location); 54 file_contents, directory[kDirectoryIndex].Location);
55 ASSERT_TRUE(*handle_data_stream); 55 ASSERT_TRUE(*handle_data_stream);
56 } 56 }
57 57
58 TEST(MinidumpHandleDataWriter, Empty) { 58 TEST(MinidumpHandleDataWriter, Empty) {
59 MinidumpFileWriter minidump_file_writer; 59 MinidumpFileWriter minidump_file_writer;
60 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter()); 60 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter());
61 minidump_file_writer.AddStream(crashpad::move(handle_data_writer)); 61 minidump_file_writer.AddStream(std::move(handle_data_writer));
62 62
63 StringFile string_file; 63 StringFile string_file;
64 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 64 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
65 65
66 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 66 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
67 sizeof(MINIDUMP_HANDLE_DATA_STREAM), 67 sizeof(MINIDUMP_HANDLE_DATA_STREAM),
68 string_file.string().size()); 68 string_file.string().size());
69 69
70 const MINIDUMP_HANDLE_DATA_STREAM* handle_data_stream = nullptr; 70 const MINIDUMP_HANDLE_DATA_STREAM* handle_data_stream = nullptr;
71 ASSERT_NO_FATAL_FAILURE( 71 ASSERT_NO_FATAL_FAILURE(
(...skipping 12 matching lines...) Expand all
84 handle_snapshot.attributes = 0x12345678; 84 handle_snapshot.attributes = 0x12345678;
85 handle_snapshot.granted_access = 0x9abcdef0; 85 handle_snapshot.granted_access = 0x9abcdef0;
86 handle_snapshot.pointer_count = 4567; 86 handle_snapshot.pointer_count = 4567;
87 handle_snapshot.handle_count = 9876; 87 handle_snapshot.handle_count = 9876;
88 88
89 std::vector<HandleSnapshot> snapshot; 89 std::vector<HandleSnapshot> snapshot;
90 snapshot.push_back(handle_snapshot); 90 snapshot.push_back(handle_snapshot);
91 91
92 handle_data_writer->InitializeFromSnapshot(snapshot); 92 handle_data_writer->InitializeFromSnapshot(snapshot);
93 93
94 minidump_file_writer.AddStream(crashpad::move(handle_data_writer)); 94 minidump_file_writer.AddStream(std::move(handle_data_writer));
95 95
96 StringFile string_file; 96 StringFile string_file;
97 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 97 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
98 98
99 const size_t kTypeNameStringDataLength = 99 const size_t kTypeNameStringDataLength =
100 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16); 100 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
101 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 101 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
102 sizeof(MINIDUMP_HANDLE_DATA_STREAM) + 102 sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
103 sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) + 103 sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) +
104 kTypeNameStringDataLength, 104 kTypeNameStringDataLength,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 handle_snapshot2.granted_access = 0x0fedcba9; 142 handle_snapshot2.granted_access = 0x0fedcba9;
143 handle_snapshot2.pointer_count = 7654; 143 handle_snapshot2.pointer_count = 7654;
144 handle_snapshot2.handle_count = 6789; 144 handle_snapshot2.handle_count = 6789;
145 145
146 std::vector<HandleSnapshot> snapshot; 146 std::vector<HandleSnapshot> snapshot;
147 snapshot.push_back(handle_snapshot); 147 snapshot.push_back(handle_snapshot);
148 snapshot.push_back(handle_snapshot2); 148 snapshot.push_back(handle_snapshot2);
149 149
150 handle_data_writer->InitializeFromSnapshot(snapshot); 150 handle_data_writer->InitializeFromSnapshot(snapshot);
151 151
152 minidump_file_writer.AddStream(crashpad::move(handle_data_writer)); 152 minidump_file_writer.AddStream(std::move(handle_data_writer));
153 153
154 StringFile string_file; 154 StringFile string_file;
155 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 155 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
156 156
157 const size_t kTypeNameStringDataLength = 157 const size_t kTypeNameStringDataLength =
158 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16); 158 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
159 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 159 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
160 sizeof(MINIDUMP_HANDLE_DATA_STREAM) + 160 sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
161 (sizeof(MINIDUMP_HANDLE_DESCRIPTOR) * 2) + 161 (sizeof(MINIDUMP_HANDLE_DESCRIPTOR) * 2) +
162 sizeof(MINIDUMP_STRING) + kTypeNameStringDataLength, 162 sizeof(MINIDUMP_STRING) + kTypeNameStringDataLength,
(...skipping 30 matching lines...) Expand all
193 EXPECT_EQ(handle_snapshot2.granted_access, handle_descriptor2->GrantedAccess); 193 EXPECT_EQ(handle_snapshot2.granted_access, handle_descriptor2->GrantedAccess);
194 EXPECT_EQ(handle_snapshot2.handle_count, handle_descriptor2->HandleCount); 194 EXPECT_EQ(handle_snapshot2.handle_count, handle_descriptor2->HandleCount);
195 EXPECT_EQ(handle_snapshot2.pointer_count, handle_descriptor2->PointerCount); 195 EXPECT_EQ(handle_snapshot2.pointer_count, handle_descriptor2->PointerCount);
196 196
197 EXPECT_EQ(handle_descriptor->TypeNameRva, handle_descriptor2->TypeNameRva); 197 EXPECT_EQ(handle_descriptor->TypeNameRva, handle_descriptor2->TypeNameRva);
198 } 198 }
199 199
200 } // namespace 200 } // namespace
201 } // namespace test 201 } // namespace test
202 } // namespace crashpad 202 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_file_writer_test.cc ('k') | minidump/minidump_memory_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698