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

Side by Side Diff: client/crash_report_database_test.cc

Issue 1391993002: win: Set last-upload-attempt time in CrashReportDatabaseWin (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 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 | « no previous file | client/crash_report_database_win.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,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 EXPECT_EQ(CrashReportDatabase::kNoError, 58 EXPECT_EQ(CrashReportDatabase::kNoError,
59 db_->FinishedWritingCrashReport(new_report, &uuid)); 59 db_->FinishedWritingCrashReport(new_report, &uuid));
60 60
61 EXPECT_EQ(CrashReportDatabase::kNoError, 61 EXPECT_EQ(CrashReportDatabase::kNoError,
62 db_->LookUpCrashReport(uuid, report)); 62 db_->LookUpCrashReport(uuid, report));
63 ExpectPreparedCrashReport(*report); 63 ExpectPreparedCrashReport(*report);
64 ASSERT_TRUE(FileExists(report->file_path)); 64 ASSERT_TRUE(FileExists(report->file_path));
65 } 65 }
66 66
67 void UploadReport(const UUID& uuid, bool successful, const std::string& id) { 67 void UploadReport(const UUID& uuid, bool successful, const std::string& id) {
68 #if !defined(OS_WIN)
69 // Enable when ported to Windows.
70 // https://code.google.com/p/crashpad/issues/detail?id=13
71 Settings* const settings = db_->GetSettings(); 68 Settings* const settings = db_->GetSettings();
72 ASSERT_TRUE(settings); 69 ASSERT_TRUE(settings);
73 time_t times[2]; 70 time_t times[2];
74 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&times[0])); 71 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&times[0]));
75 #endif
76 72
77 const CrashReportDatabase::Report* report = nullptr; 73 const CrashReportDatabase::Report* report = nullptr;
78 ASSERT_EQ(CrashReportDatabase::kNoError, 74 ASSERT_EQ(CrashReportDatabase::kNoError,
79 db_->GetReportForUploading(uuid, &report)); 75 db_->GetReportForUploading(uuid, &report));
80 EXPECT_NE(UUID(), report->uuid); 76 EXPECT_NE(UUID(), report->uuid);
81 EXPECT_FALSE(report->file_path.empty()); 77 EXPECT_FALSE(report->file_path.empty());
82 EXPECT_TRUE(FileExists(report->file_path)) 78 EXPECT_TRUE(FileExists(report->file_path))
83 << report->file_path.value(); 79 << report->file_path.value();
84 EXPECT_GT(report->creation_time, 0); 80 EXPECT_GT(report->creation_time, 0);
85 EXPECT_EQ(CrashReportDatabase::kNoError, 81 EXPECT_EQ(CrashReportDatabase::kNoError,
86 db_->RecordUploadAttempt(report, successful, id)); 82 db_->RecordUploadAttempt(report, successful, id));
87 83
88 #if !defined(OS_WIN)
89 // Enable when ported to Windows.
90 // https://code.google.com/p/crashpad/issues/detail?id=13
91 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&times[1])); 84 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&times[1]));
92 EXPECT_NE(times[1], 0); 85 EXPECT_NE(times[1], 0);
93 EXPECT_GE(times[1], times[0]); 86 EXPECT_GE(times[1], times[0]);
94 #endif
95 } 87 }
96 88
97 void ExpectPreparedCrashReport(const CrashReportDatabase::Report& report) { 89 void ExpectPreparedCrashReport(const CrashReportDatabase::Report& report) {
98 EXPECT_NE(UUID(), report.uuid); 90 EXPECT_NE(UUID(), report.uuid);
99 EXPECT_FALSE(report.file_path.empty()); 91 EXPECT_FALSE(report.file_path.empty());
100 EXPECT_TRUE(FileExists(report.file_path)) << report.file_path.value(); 92 EXPECT_TRUE(FileExists(report.file_path)) << report.file_path.value();
101 EXPECT_TRUE(report.id.empty()); 93 EXPECT_TRUE(report.id.empty());
102 EXPECT_GT(report.creation_time, 0); 94 EXPECT_GT(report.creation_time, 0);
103 EXPECT_FALSE(report.uploaded); 95 EXPECT_FALSE(report.uploaded);
104 EXPECT_EQ(0, report.last_upload_attempt_time); 96 EXPECT_EQ(0, report.last_upload_attempt_time);
(...skipping 10 matching lines...) Expand all
115 ScopedTempDir temp_dir_; 107 ScopedTempDir temp_dir_;
116 scoped_ptr<CrashReportDatabase> db_; 108 scoped_ptr<CrashReportDatabase> db_;
117 109
118 DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseTest); 110 DISALLOW_COPY_AND_ASSIGN(CrashReportDatabaseTest);
119 }; 111 };
120 112
121 TEST_F(CrashReportDatabaseTest, Initialize) { 113 TEST_F(CrashReportDatabaseTest, Initialize) {
122 // Initialize the database for the first time, creating it. 114 // Initialize the database for the first time, creating it.
123 ASSERT_TRUE(db()); 115 ASSERT_TRUE(db());
124 116
125 #if !defined(OS_WIN)
126 // Enable when ported to Windows.
127 // https://code.google.com/p/crashpad/issues/detail?id=13
128 Settings* settings = db()->GetSettings(); 117 Settings* settings = db()->GetSettings();
129 118
130 UUID client_ids[2]; 119 UUID client_ids[2];
131 ASSERT_TRUE(settings->GetClientID(&client_ids[0])); 120 ASSERT_TRUE(settings->GetClientID(&client_ids[0]));
132 EXPECT_NE(client_ids[0], UUID()); 121 EXPECT_NE(client_ids[0], UUID());
133 122
134 time_t last_upload_attempt_time; 123 time_t last_upload_attempt_time;
135 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time)); 124 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time));
136 EXPECT_EQ(0, last_upload_attempt_time); 125 EXPECT_EQ(0, last_upload_attempt_time);
137 #endif
138 126
139 // Close and reopen the database at the same path. 127 // Close and reopen the database at the same path.
140 ResetDatabase(); 128 ResetDatabase();
141 EXPECT_FALSE(db()); 129 EXPECT_FALSE(db());
142 auto db = CrashReportDatabase::Initialize(path()); 130 auto db = CrashReportDatabase::Initialize(path());
143 ASSERT_TRUE(db); 131 ASSERT_TRUE(db);
144 132
145 #if !defined(OS_WIN)
146 // Enable when ported to Windows.
147 // https://code.google.com/p/crashpad/issues/detail?id=13
148 settings = db->GetSettings(); 133 settings = db->GetSettings();
149 134
150 ASSERT_TRUE(settings->GetClientID(&client_ids[1])); 135 ASSERT_TRUE(settings->GetClientID(&client_ids[1]));
151 EXPECT_EQ(client_ids[0], client_ids[1]); 136 EXPECT_EQ(client_ids[0], client_ids[1]);
152 137
153 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time)); 138 ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time));
154 EXPECT_EQ(0, last_upload_attempt_time); 139 EXPECT_EQ(0, last_upload_attempt_time);
155 #endif
156 140
157 std::vector<CrashReportDatabase::Report> reports; 141 std::vector<CrashReportDatabase::Report> reports;
158 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetPendingReports(&reports)); 142 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetPendingReports(&reports));
159 EXPECT_TRUE(reports.empty()); 143 EXPECT_TRUE(reports.empty());
160 reports.clear(); 144 reports.clear();
161 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetCompletedReports(&reports)); 145 EXPECT_EQ(CrashReportDatabase::kNoError, db->GetCompletedReports(&reports));
162 EXPECT_TRUE(reports.empty()); 146 EXPECT_TRUE(reports.empty());
163 } 147 }
164 148
165 TEST_F(CrashReportDatabaseTest, NewCrashReport) { 149 TEST_F(CrashReportDatabaseTest, NewCrashReport) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 << ErrnoMessage("unlink"); 493 << ErrnoMessage("unlink");
510 #endif 494 #endif
511 495
512 EXPECT_EQ(CrashReportDatabase::kReportNotFound, 496 EXPECT_EQ(CrashReportDatabase::kReportNotFound,
513 db()->LookUpCrashReport(uuid, &report)); 497 db()->LookUpCrashReport(uuid, &report));
514 } 498 }
515 499
516 } // namespace 500 } // namespace
517 } // namespace test 501 } // namespace test
518 } // namespace crashpad 502 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | client/crash_report_database_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698