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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 9 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
10 #include "components/dom_distiller/core/distiller_page.h" | 10 #include "components/dom_distiller/core/distiller_page.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 protected: | 67 protected: |
68 DistillerPageWebContents* distiller_page_; | 68 DistillerPageWebContents* distiller_page_; |
69 base::Closure quit_closure_; | 69 base::Closure quit_closure_; |
70 scoped_ptr<DistilledPageInfo> page_info_; | 70 scoped_ptr<DistilledPageInfo> page_info_; |
71 }; | 71 }; |
72 | 72 |
73 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) { | 73 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) { |
74 DistillerPageWebContents distiller_page( | 74 DistillerPageWebContents distiller_page( |
75 shell()->web_contents()->GetBrowserContext()); | 75 shell()->web_contents()->GetBrowserContext(), |
| 76 scoped_ptr<SourcePageHandleWebContents>()); |
76 distiller_page_ = &distiller_page; | 77 distiller_page_ = &distiller_page; |
77 | 78 |
78 base::RunLoop run_loop; | 79 base::RunLoop run_loop; |
79 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); | 80 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); |
80 run_loop.Run(); | 81 run_loop.Run(); |
81 | 82 |
82 EXPECT_EQ("Test Page Title", page_info_.get()->title); | 83 EXPECT_EQ("Test Page Title", page_info_.get()->title); |
83 EXPECT_THAT(page_info_.get()->html, HasSubstr("Lorem ipsum")); | 84 EXPECT_THAT(page_info_.get()->html, HasSubstr("Lorem ipsum")); |
84 EXPECT_THAT(page_info_.get()->html, Not(HasSubstr("questionable content"))); | 85 EXPECT_THAT(page_info_.get()->html, Not(HasSubstr("questionable content"))); |
85 EXPECT_EQ("", page_info_.get()->next_page_url); | 86 EXPECT_EQ("", page_info_.get()->next_page_url); |
86 EXPECT_EQ("", page_info_.get()->prev_page_url); | 87 EXPECT_EQ("", page_info_.get()->prev_page_url); |
87 } | 88 } |
88 | 89 |
89 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { | 90 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { |
90 DistillerPageWebContents distiller_page( | 91 DistillerPageWebContents distiller_page( |
91 shell()->web_contents()->GetBrowserContext()); | 92 shell()->web_contents()->GetBrowserContext(), |
| 93 scoped_ptr<SourcePageHandleWebContents>()); |
92 distiller_page_ = &distiller_page; | 94 distiller_page_ = &distiller_page; |
93 | 95 |
94 base::RunLoop run_loop; | 96 base::RunLoop run_loop; |
95 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); | 97 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); |
96 run_loop.Run(); | 98 run_loop.Run(); |
97 | 99 |
98 // A relative link should've been updated. | 100 // A relative link should've been updated. |
99 EXPECT_THAT(page_info_.get()->html, | 101 EXPECT_THAT(page_info_.get()->html, |
100 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); | 102 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); |
101 EXPECT_THAT(page_info_.get()->html, | 103 EXPECT_THAT(page_info_.get()->html, |
102 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); | 104 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); |
103 } | 105 } |
104 | 106 |
105 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { | 107 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { |
106 DistillerPageWebContents distiller_page( | 108 DistillerPageWebContents distiller_page( |
107 shell()->web_contents()->GetBrowserContext()); | 109 shell()->web_contents()->GetBrowserContext(), |
| 110 scoped_ptr<SourcePageHandleWebContents>()); |
108 distiller_page_ = &distiller_page; | 111 distiller_page_ = &distiller_page; |
109 | 112 |
110 base::RunLoop run_loop; | 113 base::RunLoop run_loop; |
111 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); | 114 DistillPage(run_loop.QuitClosure(), "/simple_article.html"); |
112 run_loop.Run(); | 115 run_loop.Run(); |
113 | 116 |
114 // A relative link should've been updated. | 117 // A relative link should've been updated. |
115 EXPECT_THAT(page_info_.get()->html, | 118 EXPECT_THAT(page_info_.get()->html, |
116 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); | 119 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); |
117 EXPECT_THAT(page_info_.get()->html, | 120 EXPECT_THAT(page_info_.get()->html, |
118 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); | 121 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); |
119 } | 122 } |
120 | 123 |
121 } // namespace dom_distiller | 124 } // namespace dom_distiller |
OLD | NEW |