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 "components/dom_distiller/core/viewer.h" | 5 #include "components/dom_distiller/core/viewer.h" |
6 | 6 |
7 #include "components/dom_distiller/core/distilled_page_prefs.h" | 7 #include "components/dom_distiller/core/distilled_page_prefs.h" |
8 #include "components/dom_distiller/core/dom_distiller_service.h" | 8 #include "components/dom_distiller/core/dom_distiller_service.h" |
9 #include "components/dom_distiller/core/dom_distiller_test_util.h" | 9 #include "components/dom_distiller/core/dom_distiller_test_util.h" |
10 #include "components/dom_distiller/core/task_tracker.h" | 10 #include "components/dom_distiller/core/task_tracker.h" |
11 #include "components/dom_distiller/core/url_constants.h" | 11 #include "components/dom_distiller/core/url_constants.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace dom_distiller { | 14 namespace dom_distiller { |
15 | 15 |
16 const char kTestScheme[] = "myscheme"; | 16 const char kTestScheme[] = "myscheme"; |
17 | 17 |
18 class FakeViewRequestDelegate : public ViewRequestDelegate { | 18 class FakeViewRequestDelegate : public ViewRequestDelegate { |
19 public: | 19 public: |
20 virtual ~FakeViewRequestDelegate() {} | 20 ~FakeViewRequestDelegate() override {} |
21 MOCK_METHOD1(OnArticleReady, void(const DistilledArticleProto* proto)); | 21 MOCK_METHOD1(OnArticleReady, void(const DistilledArticleProto* proto)); |
22 MOCK_METHOD1(OnArticleUpdated, | 22 MOCK_METHOD1(OnArticleUpdated, |
23 void(ArticleDistillationUpdate article_update)); | 23 void(ArticleDistillationUpdate article_update)); |
24 }; | 24 }; |
25 | 25 |
26 class TestDomDistillerService : public DomDistillerServiceInterface { | 26 class TestDomDistillerService : public DomDistillerServiceInterface { |
27 public: | 27 public: |
28 TestDomDistillerService() {} | 28 TestDomDistillerService() {} |
29 virtual ~TestDomDistillerService() {} | 29 ~TestDomDistillerService() override {} |
30 | 30 |
31 MOCK_CONST_METHOD0(GetSyncableService, syncer::SyncableService*()); | 31 MOCK_CONST_METHOD0(GetSyncableService, syncer::SyncableService*()); |
32 MOCK_METHOD3(AddToList, | 32 MOCK_METHOD3(AddToList, |
33 const std::string(const GURL&, | 33 const std::string(const GURL&, |
34 DistillerPage*, | 34 DistillerPage*, |
35 const ArticleAvailableCallback&)); | 35 const ArticleAvailableCallback&)); |
36 virtual const std::string AddToList( | 36 const std::string AddToList( |
37 const GURL& url, | 37 const GURL& url, |
38 scoped_ptr<DistillerPage> distiller_page, | 38 scoped_ptr<DistillerPage> distiller_page, |
39 const ArticleAvailableCallback& article_cb) { | 39 const ArticleAvailableCallback& article_cb) override { |
40 return AddToList(url, distiller_page.get(), article_cb); | 40 return AddToList(url, distiller_page.get(), article_cb); |
41 } | 41 } |
42 MOCK_METHOD1(HasEntry, bool(const std::string&)); | 42 MOCK_METHOD1(HasEntry, bool(const std::string&)); |
43 MOCK_METHOD1(GetUrlForEntry, std::string(const std::string&)); | 43 MOCK_METHOD1(GetUrlForEntry, std::string(const std::string&)); |
44 MOCK_CONST_METHOD0(GetEntries, std::vector<ArticleEntry>()); | 44 MOCK_CONST_METHOD0(GetEntries, std::vector<ArticleEntry>()); |
45 MOCK_METHOD1(AddObserver, void(DomDistillerObserver*)); | 45 MOCK_METHOD1(AddObserver, void(DomDistillerObserver*)); |
46 MOCK_METHOD1(RemoveObserver, void(DomDistillerObserver*)); | 46 MOCK_METHOD1(RemoveObserver, void(DomDistillerObserver*)); |
47 MOCK_METHOD0(ViewUrlImpl, ViewerHandle*()); | 47 MOCK_METHOD0(ViewUrlImpl, ViewerHandle*()); |
48 virtual scoped_ptr<ViewerHandle> ViewUrl( | 48 scoped_ptr<ViewerHandle> ViewUrl( |
49 ViewRequestDelegate*, | 49 ViewRequestDelegate*, |
50 scoped_ptr<DistillerPage> distiller_page, | 50 scoped_ptr<DistillerPage> distiller_page, |
51 const GURL&) { | 51 const GURL&) override { |
52 return scoped_ptr<ViewerHandle>(ViewUrlImpl()); | 52 return scoped_ptr<ViewerHandle>(ViewUrlImpl()); |
53 } | 53 } |
54 MOCK_METHOD0(ViewEntryImpl, ViewerHandle*()); | 54 MOCK_METHOD0(ViewEntryImpl, ViewerHandle*()); |
55 virtual scoped_ptr<ViewerHandle> ViewEntry( | 55 scoped_ptr<ViewerHandle> ViewEntry( |
56 ViewRequestDelegate*, | 56 ViewRequestDelegate*, |
57 scoped_ptr<DistillerPage> distiller_page, | 57 scoped_ptr<DistillerPage> distiller_page, |
58 const std::string&) { | 58 const std::string&) override { |
59 return scoped_ptr<ViewerHandle>(ViewEntryImpl()); | 59 return scoped_ptr<ViewerHandle>(ViewEntryImpl()); |
60 } | 60 } |
61 MOCK_METHOD0(RemoveEntryImpl, ArticleEntry*()); | 61 MOCK_METHOD0(RemoveEntryImpl, ArticleEntry*()); |
62 virtual scoped_ptr<ArticleEntry> RemoveEntry(const std::string&) { | 62 scoped_ptr<ArticleEntry> RemoveEntry(const std::string&) override { |
63 return scoped_ptr<ArticleEntry>(RemoveEntryImpl()); | 63 return scoped_ptr<ArticleEntry>(RemoveEntryImpl()); |
64 } | 64 } |
65 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage( | 65 scoped_ptr<DistillerPage> CreateDefaultDistillerPage( |
66 const gfx::Size& render_view_size) { | 66 const gfx::Size& render_view_size) override { |
67 return scoped_ptr<DistillerPage>(); | 67 return scoped_ptr<DistillerPage>(); |
68 } | 68 } |
69 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( | 69 scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
70 scoped_ptr<SourcePageHandle> handle) { | 70 scoped_ptr<SourcePageHandle> handle) override { |
71 return scoped_ptr<DistillerPage>(); | 71 return scoped_ptr<DistillerPage>(); |
72 } | 72 } |
73 virtual DistilledPagePrefs* GetDistilledPagePrefs() override; | 73 DistilledPagePrefs* GetDistilledPagePrefs() override; |
74 }; | 74 }; |
75 | 75 |
76 class DomDistillerViewerTest : public testing::Test { | 76 class DomDistillerViewerTest : public testing::Test { |
77 public: | 77 public: |
78 void SetUp() override { service_.reset(new TestDomDistillerService()); } | 78 void SetUp() override { service_.reset(new TestDomDistillerService()); } |
79 | 79 |
80 protected: | 80 protected: |
81 scoped_ptr<ViewerHandle> CreateViewRequest( | 81 scoped_ptr<ViewerHandle> CreateViewRequest( |
82 const std::string& path, | 82 const std::string& path, |
83 ViewRequestDelegate* view_request_delegate) { | 83 ViewRequestDelegate* view_request_delegate) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 0); | 160 0); |
161 EXPECT_EQ(kMonospaceJsFontFamily.compare(viewer::GetDistilledPageFontFamilyJs( | 161 EXPECT_EQ(kMonospaceJsFontFamily.compare(viewer::GetDistilledPageFontFamilyJs( |
162 DistilledPagePrefs::MONOSPACE)), | 162 DistilledPagePrefs::MONOSPACE)), |
163 0); | 163 0); |
164 EXPECT_EQ(kSansSerifJsFontFamily.compare(viewer::GetDistilledPageFontFamilyJs( | 164 EXPECT_EQ(kSansSerifJsFontFamily.compare(viewer::GetDistilledPageFontFamilyJs( |
165 DistilledPagePrefs::SANS_SERIF)), | 165 DistilledPagePrefs::SANS_SERIF)), |
166 0); | 166 0); |
167 } | 167 } |
168 | 168 |
169 } // namespace dom_distiller | 169 } // namespace dom_distiller |
OLD | NEW |