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

Unified Diff: components/dom_distiller/core/dom_distiller_store_unittest.cc

Issue 717793007: Add attachments support to DomDistillerStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « components/dom_distiller/core/dom_distiller_store.cc ('k') | sync/protocol/article_specifics.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
« no previous file with comments | « components/dom_distiller/core/dom_distiller_store.cc ('k') | sync/protocol/article_specifics.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698