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

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

Issue 254483003: Start requiring DistillerPage for calls to DomDistillerService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fixes (full git cl format) Created 6 years, 8 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: components/dom_distiller/core/dom_distiller_service_unittest.cc
diff --git a/components/dom_distiller/core/dom_distiller_service_unittest.cc b/components/dom_distiller/core/dom_distiller_service_unittest.cc
index 72dabefe7f0ae672c86c3e84a903832975bf396f..abb803162571fa4cd425181a2245939fb49ba691 100644
--- a/components/dom_distiller/core/dom_distiller_service_unittest.cc
+++ b/components/dom_distiller/core/dom_distiller_service_unittest.cc
@@ -16,6 +16,7 @@
#include "components/dom_distiller/core/dom_distiller_test_util.h"
#include "components/dom_distiller/core/fake_db.h"
#include "components/dom_distiller/core/fake_distiller.h"
+#include "components/dom_distiller/core/fake_distiller_page.h"
#include "components/dom_distiller/core/task_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -82,9 +83,11 @@ class DomDistillerServiceTest : public testing::Test {
FakeDB::EntryMap store_model;
store_ = test::util::CreateStoreWithFakeDB(fake_db, store_model);
distiller_factory_ = new MockDistillerFactory();
+ distiller_page_factory_ = new MockDistillerPageFactory();
service_.reset(new DomDistillerService(
scoped_ptr<DomDistillerStoreInterface>(store_),
- scoped_ptr<DistillerFactory>(distiller_factory_)));
+ scoped_ptr<DistillerFactory>(distiller_factory_),
+ scoped_ptr<DistillerPageFactory>(distiller_page_factory_)));
fake_db->InitCallback(true);
fake_db->LoadCallback(true);
}
@@ -100,6 +103,7 @@ class DomDistillerServiceTest : public testing::Test {
// store is owned by service_.
DomDistillerStoreInterface* store_;
MockDistillerFactory* distiller_factory_;
+ MockDistillerPageFactory* distiller_page_factory_;
scoped_ptr<DomDistillerService> service_;
scoped_ptr<base::MessageLoop> main_loop_;
FakeDB::EntryMap db_model_;
@@ -119,8 +123,8 @@ TEST_F(DomDistillerServiceTest, TestViewEntry) {
store_->AddEntry(entry);
FakeViewRequestDelegate viewer_delegate;
- scoped_ptr<ViewerHandle> handle =
- service_->ViewEntry(&viewer_delegate, entry_id);
+ scoped_ptr<ViewerHandle> handle = service_->ViewEntry(
+ &viewer_delegate, service_->CreateDefaultDistillerPage(), entry_id);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
@@ -137,7 +141,8 @@ TEST_F(DomDistillerServiceTest, TestViewUrl) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(&viewer_delegate, url);
+ scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ &viewer_delegate, service_->CreateDefaultDistillerPage(), url);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
@@ -161,8 +166,10 @@ TEST_F(DomDistillerServiceTest, TestMultipleViewUrl) {
GURL url("http://www.example.com/p1");
GURL url2("http://www.example.com/a/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(&viewer_delegate, url);
- scoped_ptr<ViewerHandle> handle2 = service_->ViewUrl(&viewer_delegate2, url2);
+ scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ &viewer_delegate, service_->CreateDefaultDistillerPage(), url);
+ scoped_ptr<ViewerHandle> handle2 = service_->ViewUrl(
+ &viewer_delegate2, service_->CreateDefaultDistillerPage(), url2);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
@@ -192,7 +199,8 @@ TEST_F(DomDistillerServiceTest, TestViewUrlCancelled) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(&viewer_delegate, url);
+ scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ &viewer_delegate, service_->CreateDefaultDistillerPage(), url);
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
@@ -213,7 +221,8 @@ TEST_F(DomDistillerServiceTest, TestViewUrlDoesNotAddEntry) {
FakeViewRequestDelegate viewer_delegate;
GURL url("http://www.example.com/p1");
- scoped_ptr<ViewerHandle> handle = service_->ViewUrl(&viewer_delegate, url);
+ scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
+ &viewer_delegate, service_->CreateDefaultDistillerPage(), url);
scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
@@ -234,7 +243,10 @@ TEST_F(DomDistillerServiceTest, TestAddAndRemoveEntry) {
MockArticleAvailableCallback article_cb;
EXPECT_CALL(article_cb, DistillationCompleted(true));
- std::string entry_id = service_->AddToList(url, ArticleCallback(&article_cb));
+ std::string entry_id =
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb));
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
EXPECT_EQ(url, distiller->GetUrl());
@@ -263,7 +275,10 @@ TEST_F(DomDistillerServiceTest, TestCancellation) {
EXPECT_CALL(article_cb, DistillationCompleted(false));
GURL url("http://www.example.com/p1");
- std::string entry_id = service_->AddToList(url, ArticleCallback(&article_cb));
+ std::string entry_id =
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb));
// Remove entry will cause the |article_cb| to be called with false value.
service_->RemoveEntry(entry_id);
@@ -283,7 +298,8 @@ TEST_F(DomDistillerServiceTest, TestMultipleObservers) {
DomDistillerService::ArticleAvailableCallback article_cb;
GURL url("http://www.example.com/p1");
- std::string entry_id = service_->AddToList(url, article_cb);
+ std::string entry_id = service_->AddToList(
+ url, service_->CreateDefaultDistillerPage().Pass(), article_cb);
// Distillation should notify all observers that article is added.
std::vector<DomDistillerObserver::ArticleUpdate> expected_updates;
@@ -325,12 +341,16 @@ TEST_F(DomDistillerServiceTest, TestMultipleCallbacks) {
// Adding a URL and then distilling calls all clients.
GURL url("http://www.example.com/p1");
const std::string entry_id =
- service_->AddToList(url, ArticleCallback(&article_cb[0]));
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb[0]));
EXPECT_CALL(article_cb[0], DistillationCompleted(true));
for (int i = 1; i < kClientsCount; ++i) {
EXPECT_EQ(entry_id,
- service_->AddToList(url, ArticleCallback(&article_cb[i])));
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb[i])));
EXPECT_CALL(article_cb[i], DistillationCompleted(true));
}
@@ -341,7 +361,9 @@ TEST_F(DomDistillerServiceTest, TestMultipleCallbacks) {
for (int i = 0; i < kClientsCount; ++i) {
EXPECT_CALL(article_cb[i], DistillationCompleted(true));
EXPECT_EQ(entry_id,
- service_->AddToList(url, ArticleCallback(&article_cb[i])));
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb[i])));
}
base::RunLoop().RunUntilIdle();
@@ -358,12 +380,16 @@ TEST_F(DomDistillerServiceTest, TestMultipleCallbacksOnRemove) {
// called with false.
GURL url("http://www.example.com/p1");
const std::string entry_id =
- service_->AddToList(url, ArticleCallback(&article_cb[0]));
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb[0]));
EXPECT_CALL(article_cb[0], DistillationCompleted(false));
for (int i = 1; i < kClientsCount; ++i) {
EXPECT_EQ(entry_id,
- service_->AddToList(url, ArticleCallback(&article_cb[i])));
+ service_->AddToList(url,
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb[i])));
EXPECT_CALL(article_cb[i], DistillationCompleted(false));
}
@@ -388,7 +414,9 @@ TEST_F(DomDistillerServiceTest, TestMultiplePageArticle) {
EXPECT_CALL(article_cb, DistillationCompleted(true));
std::string entry_id =
- service_->AddToList(pages_url[0], ArticleCallback(&article_cb));
+ service_->AddToList(pages_url[0],
+ service_->CreateDefaultDistillerPage().Pass(),
+ ArticleCallback(&article_cb));
ArticleEntry entry;
ASSERT_FALSE(distiller->GetArticleCallback().is_null());
« no previous file with comments | « components/dom_distiller/core/dom_distiller_service.cc ('k') | components/dom_distiller/core/fake_distiller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698