| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/dom_distiller/core/dom_distiller_service.h" | 5 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 scoped_ptr<DistilledArticleProto> CreateDefaultArticle() { | 73 scoped_ptr<DistilledArticleProto> CreateDefaultArticle() { |
| 74 return CreateArticleWithURL("http://www.example.com/default_article_page1") | 74 return CreateArticleWithURL("http://www.example.com/default_article_page1") |
| 75 .Pass(); | 75 .Pass(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace | 78 } // namespace |
| 79 | 79 |
| 80 class DomDistillerServiceTest : public testing::Test { | 80 class DomDistillerServiceTest : public testing::Test { |
| 81 public: | 81 public: |
| 82 virtual void SetUp() { | 82 void SetUp() override { |
| 83 main_loop_.reset(new base::MessageLoop()); | 83 main_loop_.reset(new base::MessageLoop()); |
| 84 FakeDB<ArticleEntry>* fake_db = new FakeDB<ArticleEntry>(&db_model_); | 84 FakeDB<ArticleEntry>* fake_db = new FakeDB<ArticleEntry>(&db_model_); |
| 85 FakeDB<ArticleEntry>::EntryMap store_model; | 85 FakeDB<ArticleEntry>::EntryMap store_model; |
| 86 store_ = | 86 store_ = |
| 87 test::util::CreateStoreWithFakeDB(fake_db, store_model); | 87 test::util::CreateStoreWithFakeDB(fake_db, store_model); |
| 88 distiller_factory_ = new MockDistillerFactory(); | 88 distiller_factory_ = new MockDistillerFactory(); |
| 89 distiller_page_factory_ = new MockDistillerPageFactory(); | 89 distiller_page_factory_ = new MockDistillerPageFactory(); |
| 90 service_.reset(new DomDistillerService( | 90 service_.reset(new DomDistillerService( |
| 91 scoped_ptr<DomDistillerStoreInterface>(store_), | 91 scoped_ptr<DomDistillerStoreInterface>(store_), |
| 92 scoped_ptr<DistillerFactory>(distiller_factory_), | 92 scoped_ptr<DistillerFactory>(distiller_factory_), |
| 93 scoped_ptr<DistillerPageFactory>(distiller_page_factory_), | 93 scoped_ptr<DistillerPageFactory>(distiller_page_factory_), |
| 94 scoped_ptr<DistilledPagePrefs>())); | 94 scoped_ptr<DistilledPagePrefs>())); |
| 95 fake_db->InitCallback(true); | 95 fake_db->InitCallback(true); |
| 96 fake_db->LoadCallback(true); | 96 fake_db->LoadCallback(true); |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void TearDown() { | 99 void TearDown() override { |
| 100 base::RunLoop().RunUntilIdle(); | 100 base::RunLoop().RunUntilIdle(); |
| 101 store_ = NULL; | 101 store_ = NULL; |
| 102 distiller_factory_ = NULL; | 102 distiller_factory_ = NULL; |
| 103 service_.reset(); | 103 service_.reset(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 // store is owned by service_. | 107 // store is owned by service_. |
| 108 DomDistillerStoreInterface* store_; | 108 DomDistillerStoreInterface* store_; |
| 109 MockDistillerFactory* distiller_factory_; | 109 MockDistillerFactory* distiller_factory_; |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 565 |
| 566 // Remove the article and check that no URL can be retrieved for the entry. | 566 // Remove the article and check that no URL can be retrieved for the entry. |
| 567 service_->RemoveEntry(entry_id); | 567 service_->RemoveEntry(entry_id); |
| 568 base::RunLoop().RunUntilIdle(); | 568 base::RunLoop().RunUntilIdle(); |
| 569 EXPECT_EQ(0u, store_->GetEntries().size()); | 569 EXPECT_EQ(0u, store_->GetEntries().size()); |
| 570 EXPECT_EQ("", service_->GetUrlForEntry(entry_id)); | 570 EXPECT_EQ("", service_->GetUrlForEntry(entry_id)); |
| 571 } | 571 } |
| 572 | 572 |
| 573 } // namespace test | 573 } // namespace test |
| 574 } // namespace dom_distiller | 574 } // namespace dom_distiller |
| OLD | NEW |