#include "client/crash_report_database.h"
#include "build/build_config.h"
#include "client/settings.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/file.h"
#include "test/filesystem.h"
#include "test/scoped_temp_dir.h"
#include "util/file/file_io.h"
#include "util/file/filesystem.h"
#if BUILDFLAG(IS_IOS)
#include "util/mac/xattr.h"
#endif
namespace crashpad {
namespace test {
namespace {
class CrashReportDatabaseTest : public testing::Test { … };
TEST_F(CrashReportDatabaseTest, Initialize) { … }
TEST_F(CrashReportDatabaseTest, Settings) { … }
TEST_F(CrashReportDatabaseTest, NewCrashReport) { … }
TEST_F(CrashReportDatabaseTest, LookUpCrashReport) { … }
TEST_F(CrashReportDatabaseTest, RecordUploadAttempt) { … }
TEST_F(CrashReportDatabaseTest, GetCompletedAndNotUploadedReports) { … }
TEST_F(CrashReportDatabaseTest, DuelingUploads) { … }
#if BUILDFLAG(IS_IOS)
TEST_F(CrashReportDatabaseTest, InterruptedIOSUploads) {
CrashReportDatabase::Report report;
CreateCrashReport(&report);
std::unique_ptr<const CrashReportDatabase::UploadReport> upload_report;
EXPECT_EQ(db()->GetReportForUploading(report.uuid, &upload_report),
CrashReportDatabase::kNoError);
time_t ten_minutes_ago = time(nullptr) - 10 * 60;
ASSERT_TRUE(
WriteXattrTimeT(report.file_path,
"org.chromium.crashpad.database.upload_start_time",
ten_minutes_ago));
std::vector<CrashReportDatabase::Report> reports;
EXPECT_EQ(db()->GetPendingReports(&reports), CrashReportDatabase::kNoError);
ASSERT_EQ(reports.size(), 1u);
reports.clear();
EXPECT_EQ(db()->GetCompletedReports(&reports), CrashReportDatabase::kNoError);
EXPECT_TRUE(reports.empty());
std::unique_ptr<const CrashReportDatabase::UploadReport> upload_report_2;
EXPECT_EQ(db()->GetReportForUploading(report.uuid, &upload_report_2),
CrashReportDatabase::kReportNotFound);
EXPECT_FALSE(upload_report_2);
EXPECT_EQ(db()->GetPendingReports(&reports), CrashReportDatabase::kNoError);
EXPECT_TRUE(reports.empty());
EXPECT_EQ(db()->GetCompletedReports(&reports), CrashReportDatabase::kNoError);
ASSERT_EQ(reports.size(), 1u);
EXPECT_EQ(db()->RecordUploadComplete(std::move(upload_report), std::string()),
CrashReportDatabase::kReportNotFound);
}
#endif
TEST_F(CrashReportDatabaseTest, UploadAlreadyUploaded) { … }
TEST_F(CrashReportDatabaseTest, MoveDatabase) { … }
TEST_F(CrashReportDatabaseTest, ReportRemoved) { … }
TEST_F(CrashReportDatabaseTest, DeleteReport) { … }
TEST_F(CrashReportDatabaseTest, DeleteReportEmptyingDatabase) { … }
TEST_F(CrashReportDatabaseTest, ReadEmptyDatabase) { … }
TEST_F(CrashReportDatabaseTest, RequestUpload) { … }
TEST_F(CrashReportDatabaseTest, Attachments) { … }
TEST_F(CrashReportDatabaseTest, OrphanedAttachments) { … }
#if !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_WIN)
TEST_F(CrashReportDatabaseTest, CleanBrokenDatabase) { … }
#endif
TEST_F(CrashReportDatabaseTest, TotalSize_MainReportOnly) { … }
TEST_F(CrashReportDatabaseTest, GetReportSize_RightSizeWithAttachments) { … }
}
}
}