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

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

Issue 293143002: Add AttachmentDownloader interface, change signature of AttachmentStore::Read (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes after feedback from Nick Created 6 years, 7 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
« no previous file with comments | « sync/internal_api/attachments/fake_attachment_store.cc ('k') | sync/sync_api.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/attachments/fake_attachment_store_unittest.cc
diff --git a/sync/internal_api/attachments/fake_attachment_store_unittest.cc b/sync/internal_api/attachments/fake_attachment_store_unittest.cc
index dffe3cf6a95c3f2aea7895f6b35242f8f5ffa356..e6fd41e7c561f5942f01fff0cfe8fbda9ec24167 100644
--- a/sync/internal_api/attachments/fake_attachment_store_unittest.cc
+++ b/sync/internal_api/attachments/fake_attachment_store_unittest.cc
@@ -23,6 +23,7 @@ class FakeAttachmentStoreTest : public testing::Test {
FakeAttachmentStore store;
AttachmentStore::Result result;
scoped_ptr<AttachmentMap> attachments;
+ scoped_ptr<AttachmentIdList> failed_attachment_ids;
AttachmentStore::ReadCallback read_callback;
AttachmentStore::WriteCallback write_callback;
@@ -38,7 +39,8 @@ class FakeAttachmentStoreTest : public testing::Test {
read_callback = base::Bind(&FakeAttachmentStoreTest::CopyResultAttachments,
base::Unretained(this),
&result,
- &attachments);
+ &attachments,
+ &failed_attachment_ids);
write_callback = base::Bind(
&FakeAttachmentStoreTest::CopyResult, base::Unretained(this), &result);
drop_callback = write_callback;
@@ -59,6 +61,7 @@ class FakeAttachmentStoreTest : public testing::Test {
void Clear() {
result = AttachmentStore::UNSPECIFIED_ERROR;
attachments.reset();
+ failed_attachment_ids.reset();
}
void CopyResult(AttachmentStore::Result* destination_result,
@@ -66,12 +69,16 @@ class FakeAttachmentStoreTest : public testing::Test {
*destination_result = source_result;
}
- void CopyResultAttachments(AttachmentStore::Result* destination_result,
- scoped_ptr<AttachmentMap>* destination_attachments,
- const AttachmentStore::Result& source_result,
- scoped_ptr<AttachmentMap> source_attachments) {
+ void CopyResultAttachments(
+ AttachmentStore::Result* destination_result,
+ scoped_ptr<AttachmentMap>* destination_attachments,
+ scoped_ptr<AttachmentIdList>* destination_failed_attachment_ids,
+ const AttachmentStore::Result& source_result,
+ scoped_ptr<AttachmentMap> source_attachments,
+ scoped_ptr<AttachmentIdList> source_failed_attachment_ids) {
CopyResult(destination_result, source_result);
*destination_attachments = source_attachments.Pass();
+ *destination_failed_attachment_ids = source_failed_attachment_ids.Pass();
}
};
@@ -104,6 +111,7 @@ TEST_F(FakeAttachmentStoreTest, Write_NoOverwriteNoError) {
ClearAndPumpLoop();
EXPECT_EQ(result, AttachmentStore::SUCCESS);
EXPECT_EQ(attachments->size(), 1U);
+ EXPECT_EQ(failed_attachment_ids->size(), 0U);
AttachmentMap::const_iterator a1 = attachments->find(attachment1.GetId());
EXPECT_TRUE(a1 != attachments->end());
EXPECT_TRUE(attachment1.GetData()->Equals(a1->second.GetData()));
@@ -128,6 +136,7 @@ TEST_F(FakeAttachmentStoreTest, Write_RoundTrip) {
ClearAndPumpLoop();
EXPECT_EQ(result, AttachmentStore::SUCCESS);
EXPECT_EQ(attachments->size(), 2U);
+ EXPECT_EQ(failed_attachment_ids->size(), 0U);
AttachmentMap::const_iterator a1 = attachments->find(attachment1.GetId());
EXPECT_TRUE(a1 != attachments->end());
@@ -160,6 +169,7 @@ TEST_F(FakeAttachmentStoreTest, Read_OneNotFound) {
// See that only attachment1 was read.
EXPECT_EQ(result, AttachmentStore::UNSPECIFIED_ERROR);
EXPECT_EQ(attachments->size(), 1U);
+ EXPECT_EQ(failed_attachment_ids->size(), 1U);
}
// Try to drop two attachments when only one exists. Verify that no error occurs
@@ -187,6 +197,8 @@ TEST_F(FakeAttachmentStoreTest, Drop_DropTwoButOnlyOneExists) {
ClearAndPumpLoop();
EXPECT_EQ(result, AttachmentStore::UNSPECIFIED_ERROR);
EXPECT_EQ(attachments->size(), 0U);
+ EXPECT_EQ(failed_attachment_ids->size(), 1U);
+ EXPECT_EQ((*failed_attachment_ids)[0], attachment1.GetId());
// Drop both attachment1 and attachment2.
ids.clear();
@@ -203,6 +215,8 @@ TEST_F(FakeAttachmentStoreTest, Drop_DropTwoButOnlyOneExists) {
ClearAndPumpLoop();
EXPECT_EQ(result, AttachmentStore::UNSPECIFIED_ERROR);
EXPECT_EQ(attachments->size(), 0U);
+ EXPECT_EQ(failed_attachment_ids->size(), 1U);
+ EXPECT_EQ((*failed_attachment_ids)[0], attachment2.GetId());
}
// Verify that attempting to drop an attachment that does not exist is not an
@@ -227,6 +241,8 @@ TEST_F(FakeAttachmentStoreTest, Drop_DoesNotExist) {
ClearAndPumpLoop();
EXPECT_EQ(result, AttachmentStore::UNSPECIFIED_ERROR);
EXPECT_EQ(attachments->size(), 0U);
+ EXPECT_EQ(failed_attachment_ids->size(), 1U);
+ EXPECT_EQ((*failed_attachment_ids)[0], attachment1.GetId());
// Drop again, see that no error occurs.
ids.clear();
« no previous file with comments | « sync/internal_api/attachments/fake_attachment_store.cc ('k') | sync/sync_api.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698