| Index: components/dom_distiller/core/dom_distiller_store_unittest.cc
|
| diff --git a/components/dom_distiller/core/dom_distiller_store_unittest.cc b/components/dom_distiller/core/dom_distiller_store_unittest.cc
|
| index 86a4e10ff033780d44b4ac720cdcadc136c51558..0fec59746761fecd54bba47fd990a273bb22c710 100644
|
| --- a/components/dom_distiller/core/dom_distiller_store_unittest.cc
|
| +++ b/components/dom_distiller/core/dom_distiller_store_unittest.cc
|
| @@ -33,6 +33,8 @@ using syncer::SyncErrorFactory;
|
| using testing::AssertionFailure;
|
| using testing::AssertionResult;
|
| using testing::AssertionSuccess;
|
| +using testing::SaveArgPointee;
|
| +using testing::_;
|
|
|
| namespace dom_distiller {
|
|
|
| @@ -304,6 +306,60 @@ TEST_F(DomDistillerStoreTest, TestAddAndUpdateEntry) {
|
| EXPECT_FALSE(store_->UpdateEntry(GetSampleEntry(0)));
|
| }
|
|
|
| +class MockAttachmentsCallbacks {
|
| + public:
|
| + MOCK_METHOD2(Get, void(bool, ArticleAttachmentsData*));
|
| + MOCK_METHOD1(Update, void(bool));
|
| +
|
| + void GetImpl(bool success, scoped_ptr<ArticleAttachmentsData> attachments) {
|
| + Get(success, attachments.get());
|
| + }
|
| +
|
| + DomDistillerStore::UpdateAttachmentsCallback UpdateCallback() {
|
| + return base::Bind(&MockAttachmentsCallbacks::Update,
|
| + base::Unretained(this));
|
| + }
|
| +
|
| + DomDistillerStore::GetAttachmentsCallback GetCallback() {
|
| + return base::Bind(&MockAttachmentsCallbacks::GetImpl,
|
| + base::Unretained(this));
|
| + }
|
| +};
|
| +
|
| +TEST_F(DomDistillerStoreTest, TestAttachments) {
|
| + ArticleEntry entry(GetSampleEntry(0));
|
| + AddEntry(entry, &db_model_);
|
| + CreateStore();
|
| + fake_db_->InitCallback(true);
|
| + fake_db_->LoadCallback(true);
|
| + ASSERT_TRUE(AreEntriesEqual(store_->GetEntries(), db_model_));
|
| +
|
| + MockAttachmentsCallbacks callbacks;
|
| +
|
| + store_->GetAttachments(entry.entry_id(), callbacks.GetCallback());
|
| + EXPECT_CALL(callbacks, Get(false, _));
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + ArticleAttachmentsData attachments, got_attachments;
|
| + DistilledArticleProto article_proto;
|
| + article_proto.set_title("A title");
|
| + attachments.set_distilled_article(article_proto);
|
| + store_->UpdateAttachments(
|
| + entry.entry_id(),
|
| + make_scoped_ptr(new ArticleAttachmentsData(attachments)),
|
| + callbacks.UpdateCallback());
|
| + EXPECT_CALL(callbacks, Update(true));
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + store_->GetAttachments(entry.entry_id(), callbacks.GetCallback());
|
| + EXPECT_CALL(callbacks, Get(true, _))
|
| + .WillOnce(SaveArgPointee<1>(&got_attachments));
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + EXPECT_EQ(attachments.ToString(),
|
| + got_attachments.ToString());
|
| +}
|
| +
|
| TEST_F(DomDistillerStoreTest, TestSyncMergeWithEmptyDatabase) {
|
| AddEntry(GetSampleEntry(0), &sync_model_);
|
| AddEntry(GetSampleEntry(1), &sync_model_);
|
|
|