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/content/web_contents_main_frame_observer.h" | 10 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 210 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
211 run_loop.Run(); | 211 run_loop.Run(); |
212 | 212 |
213 // A relative link should've been updated. | 213 // A relative link should've been updated. |
214 EXPECT_THAT(page_info_.get()->html, | 214 EXPECT_THAT(page_info_.get()->html, |
215 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); | 215 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); |
216 EXPECT_THAT(page_info_.get()->html, | 216 EXPECT_THAT(page_info_.get()->html, |
217 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); | 217 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); |
218 } | 218 } |
219 | 219 |
| 220 |
| 221 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) { |
| 222 DistillerPageWebContents distiller_page( |
| 223 shell()->web_contents()->GetBrowserContext(), |
| 224 scoped_ptr<SourcePageHandleWebContents>()); |
| 225 distiller_page_ = &distiller_page; |
| 226 |
| 227 base::RunLoop run_loop; |
| 228 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 229 run_loop.Run(); |
| 230 |
| 231 // A relative source/track should've been updated. |
| 232 EXPECT_THAT( |
| 233 page_info_.get()->html, |
| 234 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.mp4\"")); |
| 235 EXPECT_THAT( |
| 236 page_info_.get()->html, |
| 237 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); |
| 238 EXPECT_THAT( |
| 239 page_info_.get()->html, |
| 240 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); |
| 241 EXPECT_THAT( |
| 242 page_info_.get()->html, |
| 243 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); |
| 244 } |
| 245 |
220 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { | 246 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { |
221 DistillerPageWebContents distiller_page( | 247 DistillerPageWebContents distiller_page( |
222 shell()->web_contents()->GetBrowserContext(), | 248 shell()->web_contents()->GetBrowserContext(), |
223 scoped_ptr<SourcePageHandleWebContents>()); | 249 scoped_ptr<SourcePageHandleWebContents>()); |
224 distiller_page_ = &distiller_page; | 250 distiller_page_ = &distiller_page; |
225 | 251 |
226 // visble_style.html and invisible_style.html only differ by the visibility | 252 // visble_style.html and invisible_style.html only differ by the visibility |
227 // internal stylesheet. | 253 // internal stylesheet. |
228 | 254 |
229 { | 255 { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 base::RunLoop run_loop; | 349 base::RunLoop run_loop; |
324 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 350 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
325 run_loop.Run(); | 351 run_loop.Run(); |
326 | 352 |
327 // Sanity check of distillation process. | 353 // Sanity check of distillation process. |
328 EXPECT_EQ(expect_new_web_contents, distiller_page.new_web_contents_created()); | 354 EXPECT_EQ(expect_new_web_contents, distiller_page.new_web_contents_created()); |
329 EXPECT_EQ("Test Page Title", page_info_.get()->title); | 355 EXPECT_EQ("Test Page Title", page_info_.get()->title); |
330 } | 356 } |
331 | 357 |
332 } // namespace dom_distiller | 358 } // namespace dom_distiller |
OLD | NEW |