OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 5 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
6 #include "chrome/browser/extensions/api/reading_list_private/reading_list_privat
e_api.h" | 6 #include "chrome/browser/extensions/api/reading_list_private/reading_list_privat
e_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "components/dom_distiller/core/dom_distiller_service.h" | 9 #include "components/dom_distiller/core/dom_distiller_service.h" |
10 #include "components/dom_distiller/core/dom_distiller_store.h" | 10 #include "components/dom_distiller/core/dom_distiller_store.h" |
11 #include "components/dom_distiller/core/dom_distiller_test_util.h" | 11 #include "components/dom_distiller/core/dom_distiller_test_util.h" |
12 #include "components/dom_distiller/core/fake_db.h" | 12 #include "components/dom_distiller/core/fake_db.h" |
13 #include "components/dom_distiller/core/fake_distiller.h" | 13 #include "components/dom_distiller/core/fake_distiller.h" |
| 14 #include "components/dom_distiller/core/fake_distiller_page.h" |
14 | 15 |
15 using dom_distiller::test::FakeDB; | 16 using dom_distiller::test::FakeDB; |
16 using dom_distiller::test::FakeDistiller; | 17 using dom_distiller::test::FakeDistiller; |
17 using dom_distiller::test::util::CreateStoreWithFakeDB; | 18 using dom_distiller::test::util::CreateStoreWithFakeDB; |
18 using dom_distiller::DomDistillerContextKeyedService; | 19 using dom_distiller::DomDistillerContextKeyedService; |
19 using dom_distiller::DomDistillerService; | 20 using dom_distiller::DomDistillerService; |
20 using dom_distiller::DistillerFactory; | 21 using dom_distiller::DistillerFactory; |
| 22 using dom_distiller::DistillerPageFactory; |
21 using dom_distiller::DomDistillerStoreInterface; | 23 using dom_distiller::DomDistillerStoreInterface; |
22 using dom_distiller::test::MockDistillerFactory; | 24 using dom_distiller::test::MockDistillerFactory; |
| 25 using dom_distiller::test::MockDistillerPage; |
| 26 using dom_distiller::test::MockDistillerPageFactory; |
23 | 27 |
24 class ReadingListPrivateApiTest : public ExtensionApiTest { | 28 class ReadingListPrivateApiTest : public ExtensionApiTest { |
25 public: | 29 public: |
26 static KeyedService* Build(content::BrowserContext* context) { | 30 static KeyedService* Build(content::BrowserContext* context) { |
27 FakeDB* fake_db = new FakeDB(new FakeDB::EntryMap); | 31 FakeDB* fake_db = new FakeDB(new FakeDB::EntryMap); |
28 FakeDistiller* distiller = new FakeDistiller(true); | 32 FakeDistiller* distiller = new FakeDistiller(true); |
29 MockDistillerFactory* factory = new MockDistillerFactory(); | 33 MockDistillerPage* distiller_page = new MockDistillerPage(); |
| 34 MockDistillerFactory* distiller_factory = new MockDistillerFactory(); |
| 35 MockDistillerPageFactory* distiller_page_factory = |
| 36 new MockDistillerPageFactory(); |
30 DomDistillerContextKeyedService* service = | 37 DomDistillerContextKeyedService* service = |
31 new DomDistillerContextKeyedService( | 38 new DomDistillerContextKeyedService( |
32 scoped_ptr<DomDistillerStoreInterface>( | 39 scoped_ptr<DomDistillerStoreInterface>( |
33 CreateStoreWithFakeDB(fake_db, FakeDB::EntryMap())), | 40 CreateStoreWithFakeDB(fake_db, FakeDB::EntryMap())), |
34 scoped_ptr<DistillerFactory>(factory)); | 41 scoped_ptr<DistillerFactory>(distiller_factory), |
| 42 scoped_ptr<DistillerPageFactory>(distiller_page_factory)); |
35 fake_db->InitCallback(true); | 43 fake_db->InitCallback(true); |
36 fake_db->LoadCallback(true); | 44 fake_db->LoadCallback(true); |
37 EXPECT_CALL(*factory, CreateDistillerImpl()) | 45 EXPECT_CALL(*distiller_factory, CreateDistillerImpl()) |
38 .WillOnce(testing::Return(distiller)); | 46 .WillOnce(testing::Return(distiller)); |
| 47 EXPECT_CALL(*distiller_page_factory, CreateDistillerPageImpl()) |
| 48 .WillOnce(testing::Return(distiller_page)); |
39 return service; | 49 return service; |
40 } | 50 } |
41 }; | 51 }; |
42 | 52 |
43 IN_PROC_BROWSER_TEST_F(ReadingListPrivateApiTest, ReadingListPrivate) { | 53 IN_PROC_BROWSER_TEST_F(ReadingListPrivateApiTest, ReadingListPrivate) { |
44 dom_distiller::DomDistillerServiceFactory::GetInstance()->SetTestingFactory( | 54 dom_distiller::DomDistillerServiceFactory::GetInstance()->SetTestingFactory( |
45 profile(), &ReadingListPrivateApiTest::Build); | 55 profile(), &ReadingListPrivateApiTest::Build); |
46 ASSERT_TRUE(RunComponentExtensionTest("reading_list_private")) << message_; | 56 ASSERT_TRUE(RunComponentExtensionTest("reading_list_private")) << message_; |
47 } | 57 } |
OLD | NEW |