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

Unified Diff: sync/internal_api/attachments/on_disk_attachment_store_unittest.cc

Issue 710073003: Store attachment crc in AttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add comment in attachment_util.h. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
diff --git a/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc b/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
index 0b0bd5408ef353d4941b1e86a0a516a5f1dfc9f1..b33a9831914c9802a3476cca49ca65d34f8d5757 100644
--- a/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
+++ b/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
@@ -266,6 +266,8 @@ TEST_F(OnDiskAttachmentStoreSpecificTest, StoreMetadata) {
EXPECT_EQ(store_.get(), nullptr);
}
+// Ensure that attachment store correctly maintains metadata records for
+// attachments.
TEST_F(OnDiskAttachmentStoreSpecificTest, RecordMetadata) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
base::FilePath db_path =
@@ -313,4 +315,41 @@ TEST_F(OnDiskAttachmentStoreSpecificTest, RecordMetadata) {
VerifyAttachmentRecordsPresent(db_path, attachments[1].GetId(), true);
}
+// Ensure that attachment store fails to load attachment with mismatched crc.
+TEST_F(OnDiskAttachmentStoreSpecificTest, MismatchedCrc) {
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+
+ // Create attachment store.
+ AttachmentStore::Result result = AttachmentStore::UNSPECIFIED_ERROR;
+ AttachmentStore::CreateOnDiskStore(
+ temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
+ base::Bind(&AttachmentStoreCreated, &store_, &result));
+ RunLoop();
+ EXPECT_EQ(result, AttachmentStore::SUCCESS);
+
+ // Write attachment with incorrect crc32c.
+ const uint32_t intentionally_wrong_crc32c = 0;
+ std::string some_data("data1");
+ Attachment attachment = Attachment::CreateFromParts(
+ AttachmentId::Create(), base::RefCountedString::TakeString(&some_data),
+ intentionally_wrong_crc32c);
+ AttachmentList attachments;
+ attachments.push_back(attachment);
+ store_->Write(attachments,
+ base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResult,
+ base::Unretained(this), &result));
+ RunLoop();
+ EXPECT_EQ(result, AttachmentStore::SUCCESS);
+
+ // Read attachment.
+ AttachmentIdList attachment_ids;
+ attachment_ids.push_back(attachment.GetId());
+ store_->Read(
+ attachment_ids,
+ base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultAttachments,
+ base::Unretained(this), &result));
+ RunLoop();
+ EXPECT_EQ(result, AttachmentStore::UNSPECIFIED_ERROR);
+}
+
} // namespace syncer
« no previous file with comments | « sync/internal_api/attachments/on_disk_attachment_store.cc ('k') | sync/internal_api/attachments/proto/attachment_store.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698