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

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

Issue 995683002: Revert of [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 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 2f45b20860bcab8e865342e08ac53b6f3e1cecfc..4dcc8f86c6ba02b0fba55dd340a6c09963fefe78 100644
--- a/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
+++ b/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc
@@ -311,9 +311,8 @@
VerifyAttachmentRecordsPresent(attachments[1].GetId(), true);
}
-// Ensure that attachment store fails to load attachment if the crc in the store
-// does not match the data.
-TEST_F(OnDiskAttachmentStoreSpecificTest, MismatchedCrcInStore) {
+// Ensure that attachment store fails to load attachment with mismatched crc.
+TEST_F(OnDiskAttachmentStoreSpecificTest, MismatchedCrc) {
// Create attachment store.
AttachmentStore::Result create_result = AttachmentStore::UNSPECIFIED_ERROR;
store_ = AttachmentStore::CreateOnDiskStore(
@@ -323,12 +322,10 @@
// Write attachment with incorrect crc32c.
AttachmentStore::Result write_result = AttachmentStore::UNSPECIFIED_ERROR;
const uint32_t intentionally_wrong_crc32c = 0;
-
- scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString());
- some_data->data() = "data1";
+ std::string some_data("data1");
Attachment attachment = Attachment::CreateFromParts(
- AttachmentId::Create(some_data->size(), intentionally_wrong_crc32c),
- some_data);
+ AttachmentId::Create(), base::RefCountedString::TakeString(&some_data),
+ intentionally_wrong_crc32c);
AttachmentList attachments;
attachments.push_back(attachment);
store_->Write(attachments,
@@ -351,44 +348,6 @@
EXPECT_THAT(failed_attachment_ids, testing::ElementsAre(attachment.GetId()));
}
-// Ensure that attachment store fails to load attachment if the crc in the id
-// does not match the data.
-TEST_F(OnDiskAttachmentStoreSpecificTest, MismatchedCrcInId) {
- // Create attachment store.
- AttachmentStore::Result create_result = AttachmentStore::UNSPECIFIED_ERROR;
- store_ = AttachmentStore::CreateOnDiskStore(
- temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
- base::Bind(&AttachmentStoreCreated, &create_result));
-
- AttachmentStore::Result write_result = AttachmentStore::UNSPECIFIED_ERROR;
- scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString());
- some_data->data() = "data1";
- Attachment attachment = Attachment::Create(some_data);
- AttachmentList attachments;
- attachments.push_back(attachment);
- store_->Write(attachments,
- base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResult,
- base::Unretained(this), &write_result));
-
- // Read, but with the wrong crc32c in the id.
- AttachmentStore::Result read_result = AttachmentStore::SUCCESS;
-
- AttachmentId id_with_bad_crc32c =
- AttachmentId::Create(attachment.GetId().GetSize(), 12345);
- AttachmentIdList attachment_ids;
- attachment_ids.push_back(id_with_bad_crc32c);
- AttachmentIdList failed_attachment_ids;
- store_->Read(
- attachment_ids,
- base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultAttachments,
- base::Unretained(this), &read_result, &failed_attachment_ids));
- RunLoop();
- EXPECT_EQ(AttachmentStore::SUCCESS, create_result);
- EXPECT_EQ(AttachmentStore::SUCCESS, write_result);
- EXPECT_EQ(AttachmentStore::UNSPECIFIED_ERROR, read_result);
- EXPECT_THAT(failed_attachment_ids, testing::ElementsAre(id_with_bad_crc32c));
-}
-
// Ensure that after store initialization failure ReadWrite/Drop operations fail
// with correct error.
TEST_F(OnDiskAttachmentStoreSpecificTest, OpsAfterInitializationFailed) {
@@ -406,10 +365,7 @@
// STORE_INITIALIZATION_FAILED.
AttachmentStore::Result read_result = AttachmentStore::SUCCESS;
AttachmentIdList attachment_ids;
- std::string some_data("data1");
- Attachment attachment =
- Attachment::Create(base::RefCountedString::TakeString(&some_data));
- attachment_ids.push_back(attachment.GetId());
+ attachment_ids.push_back(AttachmentId::Create());
AttachmentIdList failed_attachment_ids;
store_->Read(
attachment_ids,
@@ -426,8 +382,11 @@
// Writing to uninitialized store should result in
// STORE_INITIALIZATION_FAILED.
AttachmentStore::Result write_result = AttachmentStore::SUCCESS;
+ std::string some_data;
AttachmentList attachments;
- attachments.push_back(attachment);
+ some_data = "data1";
+ attachments.push_back(
+ Attachment::Create(base::RefCountedString::TakeString(&some_data)));
store_->Write(attachments,
base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResult,
base::Unretained(this), &write_result));

Powered by Google App Engine
This is Rietveld 408576698