Index: client/crash_report_database_test.cc |
diff --git a/client/crash_report_database_test.cc b/client/crash_report_database_test.cc |
index 60bcf43bd0812f0c38bb2adc212420239e627ccb..db0b7d1eb7458c4dc97566dfc98a938bb848ea8f 100644 |
--- a/client/crash_report_database_test.cc |
+++ b/client/crash_report_database_test.cc |
@@ -30,7 +30,7 @@ bool FileExistsAtPath(const base::FilePath& path) { |
return lstat(path.value().c_str(), &st) == 0; |
#elif defined(OS_WIN) |
struct _stat st; |
- return _wstat(path.value().c_str(), &st); |
+ return _wstat(path.value().c_str(), &st) == 0; |
#else |
#error "Not implemented" |
#endif |
@@ -107,6 +107,12 @@ class CrashReportDatabaseTest : public testing::Test { |
EXPECT_EQ(0, report.upload_attempts); |
} |
+ void RelocateDatabase() { |
+ ResetDatabase(); |
+ temp_dir_.Rename(); |
+ SetUp(); |
+ } |
+ |
private: |
ScopedTempDir temp_dir_; |
scoped_ptr<CrashReportDatabase> db_; |
@@ -434,6 +440,24 @@ TEST_F(CrashReportDatabaseTest, DuelingUploads) { |
db()->RecordUploadAttempt(upload_report, true, "")); |
} |
+TEST_F(CrashReportDatabaseTest, MoveDatabase) { |
+ CrashReportDatabase::NewReport* new_report; |
+ EXPECT_EQ(CrashReportDatabase::kNoError, |
+ db()->PrepareNewCrashReport(&new_report)); |
+ EXPECT_TRUE(FileExistsAtPath(new_report->path)) << new_report->path.value(); |
+ UUID uuid; |
+ EXPECT_EQ(CrashReportDatabase::kNoError, |
+ db()->FinishedWritingCrashReport(new_report, &uuid)); |
+ |
+ RelocateDatabase(); |
+ |
+ CrashReportDatabase::Report report; |
+ EXPECT_EQ(CrashReportDatabase::kNoError, |
+ db()->LookUpCrashReport(uuid, &report)); |
+ ExpectPreparedCrashReport(report); |
+ EXPECT_TRUE(FileExistsAtPath(report.file_path)) << report.file_path.value(); |
+} |
+ |
} // namespace |
} // namespace test |
} // namespace crashpad |