OLD | NEW |
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, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 using ::testing::SetArgPointee; | 200 using ::testing::SetArgPointee; |
201 | 201 |
202 std::vector<CrashReportDatabase::Report> reports; | 202 std::vector<CrashReportDatabase::Report> reports; |
203 for (int i = 0; i < 10; ++i) { | 203 for (int i = 0; i < 10; ++i) { |
204 CrashReportDatabase::Report temp; | 204 CrashReportDatabase::Report temp; |
205 temp.uuid.data_1 = i; | 205 temp.uuid.data_1 = i; |
206 temp.creation_time = NDaysAgo(i * 10); | 206 temp.creation_time = NDaysAgo(i * 10); |
207 reports.push_back(temp); | 207 reports.push_back(temp); |
208 } | 208 } |
209 // The randomness from std::rand() is not, so use a better rand() instead. | 209 // The randomness from std::rand() is not, so use a better rand() instead. |
210 std::random_shuffle(reports.begin(), reports.end(), [](int rand_max) { | 210 const auto random_generator = [](int rand_max) { |
211 return base::RandUint64() % rand_max; | 211 return base::RandUint64() % rand_max; |
212 }); | 212 }; |
| 213 std::random_shuffle(reports.begin(), reports.end(), random_generator); |
213 std::vector<CrashReportDatabase::Report> pending_reports( | 214 std::vector<CrashReportDatabase::Report> pending_reports( |
214 reports.begin(), reports.begin() + 5); | 215 reports.begin(), reports.begin() + 5); |
215 std::vector<CrashReportDatabase::Report> completed_reports( | 216 std::vector<CrashReportDatabase::Report> completed_reports( |
216 reports.begin() + 5, reports.end()); | 217 reports.begin() + 5, reports.end()); |
217 | 218 |
218 MockDatabase db; | 219 MockDatabase db; |
219 EXPECT_CALL(db, GetPendingReports(_)).WillOnce(DoAll( | 220 EXPECT_CALL(db, GetPendingReports(_)).WillOnce(DoAll( |
220 SetArgPointee<0>(pending_reports), | 221 SetArgPointee<0>(pending_reports), |
221 Return(CrashReportDatabase::kNoError))); | 222 Return(CrashReportDatabase::kNoError))); |
222 EXPECT_CALL(db, GetCompletedReports(_)).WillOnce(DoAll( | 223 EXPECT_CALL(db, GetCompletedReports(_)).WillOnce(DoAll( |
223 SetArgPointee<0>(completed_reports), | 224 SetArgPointee<0>(completed_reports), |
224 Return(CrashReportDatabase::kNoError))); | 225 Return(CrashReportDatabase::kNoError))); |
225 for (size_t i = 0; i < reports.size(); ++i) { | 226 for (size_t i = 0; i < reports.size(); ++i) { |
226 EXPECT_CALL(db, DeleteReport(TestUUID(i))) | 227 EXPECT_CALL(db, DeleteReport(TestUUID(i))) |
227 .WillOnce(Return(CrashReportDatabase::kNoError)); | 228 .WillOnce(Return(CrashReportDatabase::kNoError)); |
228 } | 229 } |
229 | 230 |
230 StaticCondition delete_all(true); | 231 StaticCondition delete_all(true); |
231 PruneCrashReportDatabase(&db, &delete_all); | 232 PruneCrashReportDatabase(&db, &delete_all); |
232 } | 233 } |
233 | 234 |
234 } // namespace | 235 } // namespace |
235 } // namespace test | 236 } // namespace test |
236 } // namespace crashpad | 237 } // namespace crashpad |
OLD | NEW |