| 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/content/browser/distiller_page_web_contents.h
" | 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void DistillPage(const base::Closure& quit_closure, const std::string& url) { | 97 void DistillPage(const base::Closure& quit_closure, const std::string& url) { |
| 98 distiller_page_->DistillPage( | 98 distiller_page_->DistillPage( |
| 99 embedded_test_server()->GetURL(url), | 99 embedded_test_server()->GetURL(url), |
| 100 dom_distiller::proto::DomDistillerOptions(), | 100 dom_distiller::proto::DomDistillerOptions(), |
| 101 base::Bind(&DistillerPageWebContentsTest::OnPageDistillationFinished, | 101 base::Bind(&DistillerPageWebContentsTest::OnPageDistillationFinished, |
| 102 this, quit_closure)); | 102 this, quit_closure)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void OnPageDistillationFinished( | 105 void OnPageDistillationFinished( |
| 106 base::Closure quit_closure, | 106 base::Closure quit_closure, |
| 107 scoped_ptr<proto::DomDistillerResult> distiller_result, | 107 std::unique_ptr<proto::DomDistillerResult> distiller_result, |
| 108 bool distillation_successful) { | 108 bool distillation_successful) { |
| 109 distiller_result_ = std::move(distiller_result); | 109 distiller_result_ = std::move(distiller_result); |
| 110 quit_closure.Run(); | 110 quit_closure.Run(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void OnJsExecutionDone(base::Closure callback, const base::Value* value) { | 113 void OnJsExecutionDone(base::Closure callback, const base::Value* value) { |
| 114 js_result_.reset(value->DeepCopy()); | 114 js_result_.reset(value->DeepCopy()); |
| 115 callback.Run(); | 115 callback.Run(); |
| 116 } | 116 } |
| 117 | 117 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 141 ASSERT_TRUE(embedded_test_server()->Start()); | 141 ASSERT_TRUE(embedded_test_server()->Start()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 protected: | 144 protected: |
| 145 void RunUseCurrentWebContentsTest(const std::string& url, | 145 void RunUseCurrentWebContentsTest(const std::string& url, |
| 146 bool expect_new_web_contents, | 146 bool expect_new_web_contents, |
| 147 bool setup_main_frame_observer, | 147 bool setup_main_frame_observer, |
| 148 bool wait_for_document_loaded); | 148 bool wait_for_document_loaded); |
| 149 | 149 |
| 150 DistillerPageWebContents* distiller_page_; | 150 DistillerPageWebContents* distiller_page_; |
| 151 scoped_ptr<proto::DomDistillerResult> distiller_result_; | 151 std::unique_ptr<proto::DomDistillerResult> distiller_result_; |
| 152 scoped_ptr<base::Value> js_result_; | 152 std::unique_ptr<base::Value> js_result_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Use this class to be able to leak the WebContents, which is needed for when | 155 // Use this class to be able to leak the WebContents, which is needed for when |
| 156 // the current WebContents is used for distillation. | 156 // the current WebContents is used for distillation. |
| 157 class TestDistillerPageWebContents : public DistillerPageWebContents { | 157 class TestDistillerPageWebContents : public DistillerPageWebContents { |
| 158 public: | 158 public: |
| 159 TestDistillerPageWebContents( | 159 TestDistillerPageWebContents( |
| 160 content::BrowserContext* browser_context, | 160 content::BrowserContext* browser_context, |
| 161 const gfx::Size& render_view_size, | 161 const gfx::Size& render_view_size, |
| 162 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle, | 162 std::unique_ptr<SourcePageHandleWebContents> optional_web_contents_handle, |
| 163 bool expect_new_web_contents) | 163 bool expect_new_web_contents) |
| 164 : DistillerPageWebContents(browser_context, | 164 : DistillerPageWebContents(browser_context, |
| 165 render_view_size, | 165 render_view_size, |
| 166 std::move(optional_web_contents_handle)), | 166 std::move(optional_web_contents_handle)), |
| 167 expect_new_web_contents_(expect_new_web_contents), | 167 expect_new_web_contents_(expect_new_web_contents), |
| 168 new_web_contents_created_(false) {} | 168 new_web_contents_created_(false) {} |
| 169 | 169 |
| 170 void CreateNewWebContents(const GURL& url) override { | 170 void CreateNewWebContents(const GURL& url) override { |
| 171 ASSERT_EQ(true, expect_new_web_contents_); | 171 ASSERT_EQ(true, expect_new_web_contents_); |
| 172 new_web_contents_created_ = true; | 172 new_web_contents_created_ = true; |
| 173 DistillerPageWebContents::CreateNewWebContents(url); | 173 DistillerPageWebContents::CreateNewWebContents(url); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool new_web_contents_created() { return new_web_contents_created_; } | 176 bool new_web_contents_created() { return new_web_contents_created_; } |
| 177 | 177 |
| 178 private: | 178 private: |
| 179 bool expect_new_web_contents_; | 179 bool expect_new_web_contents_; |
| 180 bool new_web_contents_created_; | 180 bool new_web_contents_created_; |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) { | 183 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, BasicDistillationWorks) { |
| 184 DistillerPageWebContents distiller_page( | 184 DistillerPageWebContents distiller_page( |
| 185 shell()->web_contents()->GetBrowserContext(), | 185 shell()->web_contents()->GetBrowserContext(), |
| 186 shell()->web_contents()->GetContainerBounds().size(), | 186 shell()->web_contents()->GetContainerBounds().size(), |
| 187 scoped_ptr<SourcePageHandleWebContents>()); | 187 std::unique_ptr<SourcePageHandleWebContents>()); |
| 188 distiller_page_ = &distiller_page; | 188 distiller_page_ = &distiller_page; |
| 189 | 189 |
| 190 base::RunLoop run_loop; | 190 base::RunLoop run_loop; |
| 191 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 191 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 192 run_loop.Run(); | 192 run_loop.Run(); |
| 193 | 193 |
| 194 EXPECT_EQ("Test Page Title", distiller_result_->title()); | 194 EXPECT_EQ("Test Page Title", distiller_result_->title()); |
| 195 EXPECT_THAT(distiller_result_->distilled_content().html(), | 195 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 196 HasSubstr("Lorem ipsum")); | 196 HasSubstr("Lorem ipsum")); |
| 197 EXPECT_THAT(distiller_result_->distilled_content().html(), | 197 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 198 Not(HasSubstr("questionable content"))); | 198 Not(HasSubstr("questionable content"))); |
| 199 EXPECT_EQ("", distiller_result_->pagination_info().next_page()); | 199 EXPECT_EQ("", distiller_result_->pagination_info().next_page()); |
| 200 EXPECT_EQ("", distiller_result_->pagination_info().prev_page()); | 200 EXPECT_EQ("", distiller_result_->pagination_info().prev_page()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { | 203 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { |
| 204 DistillerPageWebContents distiller_page( | 204 DistillerPageWebContents distiller_page( |
| 205 shell()->web_contents()->GetBrowserContext(), | 205 shell()->web_contents()->GetBrowserContext(), |
| 206 shell()->web_contents()->GetContainerBounds().size(), | 206 shell()->web_contents()->GetContainerBounds().size(), |
| 207 scoped_ptr<SourcePageHandleWebContents>()); | 207 std::unique_ptr<SourcePageHandleWebContents>()); |
| 208 distiller_page_ = &distiller_page; | 208 distiller_page_ = &distiller_page; |
| 209 | 209 |
| 210 base::RunLoop run_loop; | 210 base::RunLoop run_loop; |
| 211 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 211 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 212 run_loop.Run(); | 212 run_loop.Run(); |
| 213 | 213 |
| 214 // A relative link should've been updated. | 214 // A relative link should've been updated. |
| 215 EXPECT_THAT(distiller_result_->distilled_content().html(), | 215 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 216 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); | 216 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); |
| 217 EXPECT_THAT(distiller_result_->distilled_content().html(), | 217 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 218 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); | 218 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); |
| 219 } | 219 } |
| 220 | 220 |
| 221 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { | 221 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { |
| 222 DistillerPageWebContents distiller_page( | 222 DistillerPageWebContents distiller_page( |
| 223 shell()->web_contents()->GetBrowserContext(), | 223 shell()->web_contents()->GetBrowserContext(), |
| 224 shell()->web_contents()->GetContainerBounds().size(), | 224 shell()->web_contents()->GetContainerBounds().size(), |
| 225 scoped_ptr<SourcePageHandleWebContents>()); | 225 std::unique_ptr<SourcePageHandleWebContents>()); |
| 226 distiller_page_ = &distiller_page; | 226 distiller_page_ = &distiller_page; |
| 227 | 227 |
| 228 base::RunLoop run_loop; | 228 base::RunLoop run_loop; |
| 229 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 229 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 230 run_loop.Run(); | 230 run_loop.Run(); |
| 231 | 231 |
| 232 // A relative link should've been updated. | 232 // A relative link should've been updated. |
| 233 EXPECT_THAT(distiller_result_->distilled_content().html(), | 233 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 234 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); | 234 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); |
| 235 EXPECT_THAT(distiller_result_->distilled_content().html(), | 235 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 236 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); | 236 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) { | 240 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) { |
| 241 DistillerPageWebContents distiller_page( | 241 DistillerPageWebContents distiller_page( |
| 242 shell()->web_contents()->GetBrowserContext(), | 242 shell()->web_contents()->GetBrowserContext(), |
| 243 shell()->web_contents()->GetContainerBounds().size(), | 243 shell()->web_contents()->GetContainerBounds().size(), |
| 244 scoped_ptr<SourcePageHandleWebContents>()); | 244 std::unique_ptr<SourcePageHandleWebContents>()); |
| 245 distiller_page_ = &distiller_page; | 245 distiller_page_ = &distiller_page; |
| 246 | 246 |
| 247 base::RunLoop run_loop; | 247 base::RunLoop run_loop; |
| 248 DistillPage(run_loop.QuitClosure(), kVideoArticlePath); | 248 DistillPage(run_loop.QuitClosure(), kVideoArticlePath); |
| 249 run_loop.Run(); | 249 run_loop.Run(); |
| 250 | 250 |
| 251 // A relative source/track should've been updated. | 251 // A relative source/track should've been updated. |
| 252 EXPECT_THAT(distiller_result_->distilled_content().html(), | 252 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 253 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.webm\"")); | 253 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.webm\"")); |
| 254 EXPECT_THAT( | 254 EXPECT_THAT( |
| 255 distiller_result_->distilled_content().html(), | 255 distiller_result_->distilled_content().html(), |
| 256 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); | 256 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); |
| 257 EXPECT_THAT(distiller_result_->distilled_content().html(), | 257 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 258 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); | 258 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); |
| 259 EXPECT_THAT(distiller_result_->distilled_content().html(), | 259 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 260 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); | 260 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); |
| 261 } | 261 } |
| 262 | 262 |
| 263 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { | 263 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { |
| 264 DistillerPageWebContents distiller_page( | 264 DistillerPageWebContents distiller_page( |
| 265 shell()->web_contents()->GetBrowserContext(), | 265 shell()->web_contents()->GetBrowserContext(), |
| 266 shell()->web_contents()->GetContainerBounds().size(), | 266 shell()->web_contents()->GetContainerBounds().size(), |
| 267 scoped_ptr<SourcePageHandleWebContents>()); | 267 std::unique_ptr<SourcePageHandleWebContents>()); |
| 268 distiller_page_ = &distiller_page; | 268 distiller_page_ = &distiller_page; |
| 269 | 269 |
| 270 // visble_style.html and invisible_style.html only differ by the visibility | 270 // visble_style.html and invisible_style.html only differ by the visibility |
| 271 // internal stylesheet. | 271 // internal stylesheet. |
| 272 | 272 |
| 273 { | 273 { |
| 274 base::RunLoop run_loop; | 274 base::RunLoop run_loop; |
| 275 DistillPage(run_loop.QuitClosure(), "/visible_style.html"); | 275 DistillPage(run_loop.QuitClosure(), "/visible_style.html"); |
| 276 run_loop.Run(); | 276 run_loop.Run(); |
| 277 EXPECT_THAT(distiller_result_->distilled_content().html(), | 277 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, | 349 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, |
| 350 url_loaded_runner.QuitClosure(), | 350 url_loaded_runner.QuitClosure(), |
| 351 wait_for_document_loaded); | 351 wait_for_document_loaded); |
| 352 current_web_contents->GetController().LoadURL( | 352 current_web_contents->GetController().LoadURL( |
| 353 embedded_test_server()->GetURL(url), | 353 embedded_test_server()->GetURL(url), |
| 354 content::Referrer(), | 354 content::Referrer(), |
| 355 ui::PAGE_TRANSITION_TYPED, | 355 ui::PAGE_TRANSITION_TYPED, |
| 356 std::string()); | 356 std::string()); |
| 357 url_loaded_runner.Run(); | 357 url_loaded_runner.Run(); |
| 358 | 358 |
| 359 scoped_ptr<SourcePageHandleWebContents> source_page_handle( | 359 std::unique_ptr<SourcePageHandleWebContents> source_page_handle( |
| 360 new SourcePageHandleWebContents(current_web_contents, false)); | 360 new SourcePageHandleWebContents(current_web_contents, false)); |
| 361 | 361 |
| 362 TestDistillerPageWebContents distiller_page( | 362 TestDistillerPageWebContents distiller_page( |
| 363 shell()->web_contents()->GetBrowserContext(), | 363 shell()->web_contents()->GetBrowserContext(), |
| 364 shell()->web_contents()->GetContainerBounds().size(), | 364 shell()->web_contents()->GetContainerBounds().size(), |
| 365 std::move(source_page_handle), expect_new_web_contents); | 365 std::move(source_page_handle), expect_new_web_contents); |
| 366 distiller_page_ = &distiller_page; | 366 distiller_page_ = &distiller_page; |
| 367 | 367 |
| 368 base::RunLoop run_loop; | 368 base::RunLoop run_loop; |
| 369 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 369 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 386 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, | 386 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, |
| 387 url_loaded_runner.QuitClosure(), | 387 url_loaded_runner.QuitClosure(), |
| 388 true); | 388 true); |
| 389 current_web_contents->GetController().LoadURL( | 389 current_web_contents->GetController().LoadURL( |
| 390 embedded_test_server()->GetURL(kSimpleArticlePath), | 390 embedded_test_server()->GetURL(kSimpleArticlePath), |
| 391 content::Referrer(), | 391 content::Referrer(), |
| 392 ui::PAGE_TRANSITION_TYPED, | 392 ui::PAGE_TRANSITION_TYPED, |
| 393 std::string()); | 393 std::string()); |
| 394 url_loaded_runner.Run(); | 394 url_loaded_runner.Run(); |
| 395 | 395 |
| 396 scoped_ptr<SourcePageHandleWebContents> source_page_handle( | 396 std::unique_ptr<SourcePageHandleWebContents> source_page_handle( |
| 397 new SourcePageHandleWebContents(current_web_contents, false)); | 397 new SourcePageHandleWebContents(current_web_contents, false)); |
| 398 | 398 |
| 399 TestDistillerPageWebContents* distiller_page(new TestDistillerPageWebContents( | 399 TestDistillerPageWebContents* distiller_page(new TestDistillerPageWebContents( |
| 400 current_web_contents->GetBrowserContext(), | 400 current_web_contents->GetBrowserContext(), |
| 401 current_web_contents->GetContainerBounds().size(), | 401 current_web_contents->GetContainerBounds().size(), |
| 402 std::move(source_page_handle), false)); | 402 std::move(source_page_handle), false)); |
| 403 distiller_page_ = distiller_page; | 403 distiller_page_ = distiller_page; |
| 404 | 404 |
| 405 base::RunLoop run_loop; | 405 base::RunLoop run_loop; |
| 406 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 406 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 407 | 407 |
| 408 // It can not crash the loop when returning the result. | 408 // It can not crash the loop when returning the result. |
| 409 delete distiller_page_; | 409 delete distiller_page_; |
| 410 | 410 |
| 411 // Make sure the test ends when it does not crash. | 411 // Make sure the test ends when it does not crash. |
| 412 base::MessageLoop::current()->PostDelayedTask( | 412 base::MessageLoop::current()->PostDelayedTask( |
| 413 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2)); | 413 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(2)); |
| 414 | 414 |
| 415 run_loop.Run(); | 415 run_loop.Run(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { | 418 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { |
| 419 DistillerPageWebContents distiller_page( | 419 DistillerPageWebContents distiller_page( |
| 420 shell()->web_contents()->GetBrowserContext(), | 420 shell()->web_contents()->GetBrowserContext(), |
| 421 shell()->web_contents()->GetContainerBounds().size(), | 421 shell()->web_contents()->GetContainerBounds().size(), |
| 422 scoped_ptr<SourcePageHandleWebContents>()); | 422 std::unique_ptr<SourcePageHandleWebContents>()); |
| 423 distiller_page_ = &distiller_page; | 423 distiller_page_ = &distiller_page; |
| 424 | 424 |
| 425 base::RunLoop run_loop; | 425 base::RunLoop run_loop; |
| 426 DistillPage(run_loop.QuitClosure(), "/markup_article.html"); | 426 DistillPage(run_loop.QuitClosure(), "/markup_article.html"); |
| 427 run_loop.Run(); | 427 run_loop.Run(); |
| 428 | 428 |
| 429 EXPECT_THAT(distiller_result_->distilled_content().html(), | 429 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 430 HasSubstr("Lorem ipsum")); | 430 HasSubstr("Lorem ipsum")); |
| 431 EXPECT_EQ("Marked-up Markup Test Page Title", distiller_result_->title()); | 431 EXPECT_EQ("Marked-up Markup Test Page Title", distiller_result_->title()); |
| 432 | 432 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 EXPECT_EQ(1000, markup_image2.width()); | 465 EXPECT_EQ(1000, markup_image2.width()); |
| 466 EXPECT_EQ(600, markup_image2.height()); | 466 EXPECT_EQ(600, markup_image2.height()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, | 469 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, |
| 470 TestNoContentDoesNotCrash) { | 470 TestNoContentDoesNotCrash) { |
| 471 const std::string no_content = | 471 const std::string no_content = |
| 472 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); | 472 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); |
| 473 | 473 |
| 474 { // Test zero pages. | 474 { // Test zero pages. |
| 475 scoped_ptr<DistilledArticleProto> article_proto( | 475 std::unique_ptr<DistilledArticleProto> article_proto( |
| 476 new DistilledArticleProto()); | 476 new DistilledArticleProto()); |
| 477 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); | 477 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); |
| 478 EXPECT_THAT(js, HasSubstr(no_content)); | 478 EXPECT_THAT(js, HasSubstr(no_content)); |
| 479 } | 479 } |
| 480 | 480 |
| 481 { // Test empty content. | 481 { // Test empty content. |
| 482 scoped_ptr<DistilledArticleProto> article_proto( | 482 std::unique_ptr<DistilledArticleProto> article_proto( |
| 483 new DistilledArticleProto()); | 483 new DistilledArticleProto()); |
| 484 (*(article_proto->add_pages())).set_html(""); | 484 (*(article_proto->add_pages())).set_html(""); |
| 485 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); | 485 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); |
| 486 EXPECT_THAT(js, HasSubstr(no_content)); | 486 EXPECT_THAT(js, HasSubstr(no_content)); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, | 490 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, |
| 491 TestPinch) { | 491 TestPinch) { |
| 492 // Load the test file in content shell and wait until it has fully loaded. | 492 // Load the test file in content shell and wait until it has fully loaded. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 517 ASSERT_TRUE(js_result_); | 517 ASSERT_TRUE(js_result_); |
| 518 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); | 518 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); |
| 519 | 519 |
| 520 ASSERT_TRUE(dict->HasKey("success")); | 520 ASSERT_TRUE(dict->HasKey("success")); |
| 521 bool success; | 521 bool success; |
| 522 ASSERT_TRUE(dict->GetBoolean("success", &success)); | 522 ASSERT_TRUE(dict->GetBoolean("success", &success)); |
| 523 EXPECT_TRUE(success); | 523 EXPECT_TRUE(success); |
| 524 } | 524 } |
| 525 | 525 |
| 526 } // namespace dom_distiller | 526 } // namespace dom_distiller |
| OLD | NEW |