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

Side by Side Diff: client/crash_report_database_test.cc

Issue 904533002: Add CrashReportDatabase::ErrorWritingCrashReport() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 months 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 | « client/crash_report_database_mac.mm ('k') | no next file » | 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,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetPendingReports(&reports)); 126 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetPendingReports(&reports));
127 EXPECT_TRUE(reports.empty()); 127 EXPECT_TRUE(reports.empty());
128 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetCompletedReports(&reports)); 128 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetCompletedReports(&reports));
129 EXPECT_TRUE(reports.empty()); 129 EXPECT_TRUE(reports.empty());
130 } 130 }
131 131
132 TEST_F(CrashReportDatabaseTest, NewCrashReport) { 132 TEST_F(CrashReportDatabaseTest, NewCrashReport) {
133 CrashReportDatabase::NewReport* new_report; 133 CrashReportDatabase::NewReport* new_report;
134 EXPECT_EQ(CrashReportDatabase::kNoError, 134 EXPECT_EQ(CrashReportDatabase::kNoError,
135 db()->PrepareNewCrashReport(&new_report)); 135 db()->PrepareNewCrashReport(&new_report));
136 EXPECT_TRUE(FileExistsAtPath(new_report->path)) << new_report->path.value();
136 UUID uuid; 137 UUID uuid;
137 EXPECT_EQ(CrashReportDatabase::kNoError, 138 EXPECT_EQ(CrashReportDatabase::kNoError,
138 db()->FinishedWritingCrashReport(new_report, &uuid)); 139 db()->FinishedWritingCrashReport(new_report, &uuid));
139 140
140 CrashReportDatabase::Report report; 141 CrashReportDatabase::Report report;
141 EXPECT_EQ(CrashReportDatabase::kNoError, 142 EXPECT_EQ(CrashReportDatabase::kNoError,
142 db()->LookUpCrashReport(uuid, &report)); 143 db()->LookUpCrashReport(uuid, &report));
143 ExpectPreparedCrashReport(report); 144 ExpectPreparedCrashReport(report);
144 145
145 std::vector<const CrashReportDatabase::Report> reports; 146 std::vector<const CrashReportDatabase::Report> reports;
146 EXPECT_EQ(CrashReportDatabase::kNoError, 147 EXPECT_EQ(CrashReportDatabase::kNoError,
147 db()->GetPendingReports(&reports)); 148 db()->GetPendingReports(&reports));
148 ASSERT_EQ(1u, reports.size()); 149 ASSERT_EQ(1u, reports.size());
149 EXPECT_EQ(report.uuid, reports[0].uuid); 150 EXPECT_EQ(report.uuid, reports[0].uuid);
150 151
151 reports.clear(); 152 reports.clear();
152 EXPECT_EQ(CrashReportDatabase::kNoError, 153 EXPECT_EQ(CrashReportDatabase::kNoError,
153 db()->GetCompletedReports(&reports)); 154 db()->GetCompletedReports(&reports));
154 EXPECT_TRUE(reports.empty()); 155 EXPECT_TRUE(reports.empty());
155 } 156 }
156 157
158 TEST_F(CrashReportDatabaseTest, ErrorWritingCrashReport) {
159 CrashReportDatabase::NewReport* new_report;
160 EXPECT_EQ(CrashReportDatabase::kNoError,
161 db()->PrepareNewCrashReport(&new_report));
162 base::FilePath new_report_path = new_report->path;
163 EXPECT_TRUE(FileExistsAtPath(new_report_path)) << new_report_path.value();
164 EXPECT_EQ(CrashReportDatabase::kNoError,
165 db()->ErrorWritingCrashReport(new_report));
166 EXPECT_FALSE(FileExistsAtPath(new_report_path)) << new_report_path.value();
167 }
168
157 TEST_F(CrashReportDatabaseTest, LookUpCrashReport) { 169 TEST_F(CrashReportDatabaseTest, LookUpCrashReport) {
158 UUID uuid; 170 UUID uuid;
159 171
160 { 172 {
161 CrashReportDatabase::Report report; 173 CrashReportDatabase::Report report;
162 CreateCrashReport(&report); 174 CreateCrashReport(&report);
163 uuid = report.uuid; 175 uuid = report.uuid;
164 } 176 }
165 177
166 { 178 {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 db()->GetReportForUploading(report.uuid, &upload_report_2)); 430 db()->GetReportForUploading(report.uuid, &upload_report_2));
419 EXPECT_FALSE(upload_report_2); 431 EXPECT_FALSE(upload_report_2);
420 432
421 EXPECT_EQ(CrashReportDatabase::kNoError, 433 EXPECT_EQ(CrashReportDatabase::kNoError,
422 db()->RecordUploadAttempt(upload_report, true, "")); 434 db()->RecordUploadAttempt(upload_report, true, ""));
423 } 435 }
424 436
425 } // namespace 437 } // namespace
426 } // namespace test 438 } // namespace test
427 } // namespace crashpad 439 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crash_report_database_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698