Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: components/dom_distiller/content/distiller_page_web_contents_browsertest.cc

Issue 1015463004: Consistent content placement method for dom-distiller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ios code Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 const proto::MarkupImage markup_image2 = markup_info.images(1); 407 const proto::MarkupImage markup_image2 = markup_info.images(1);
408 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); 408 EXPECT_EQ("http://test/markup2.gif", markup_image2.url());
409 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); 409 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url());
410 EXPECT_EQ("gif", markup_image2.type()); 410 EXPECT_EQ("gif", markup_image2.type());
411 EXPECT_EQ("", markup_image2.caption()); 411 EXPECT_EQ("", markup_image2.caption());
412 EXPECT_EQ(1000, markup_image2.width()); 412 EXPECT_EQ(1000, markup_image2.width());
413 EXPECT_EQ(600, markup_image2.height()); 413 EXPECT_EQ(600, markup_image2.height());
414 } 414 }
415 415
416 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, 416 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, TestTitleNeverEmpty) {
417 TestTitleAndContentAreNeverEmpty) {
418 const std::string some_title = "some title"; 417 const std::string some_title = "some title";
419 const std::string some_content = "some content";
420 const std::string no_title = 418 const std::string no_title =
421 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); 419 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE);
422 const std::string no_content =
423 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT);
424 420
425 { // Test non-empty title and content for article. 421 { // Test empty title for article.
426 scoped_ptr<DistilledArticleProto> article_proto(
427 new DistilledArticleProto());
428 article_proto->set_title(some_title);
429 (*(article_proto->add_pages())).set_html(some_content);
430 std::string html = viewer::GetUnsafeArticleHtml(article_proto.get(),
431 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
432 EXPECT_THAT(html, HasSubstr(some_title));
433 EXPECT_THAT(html, HasSubstr(some_content));
434 EXPECT_THAT(html, Not(HasSubstr(no_title)));
435 EXPECT_THAT(html, Not(HasSubstr(no_content)));
436 }
437
438 { // Test empty title and content for article.
439 scoped_ptr<DistilledArticleProto> article_proto( 422 scoped_ptr<DistilledArticleProto> article_proto(
440 new DistilledArticleProto()); 423 new DistilledArticleProto());
441 article_proto->set_title(""); 424 article_proto->set_title("");
442 (*(article_proto->add_pages())).set_html(""); 425 (*(article_proto->add_pages())).set_html("");
443 std::string html = viewer::GetUnsafeArticleHtml(article_proto.get(), 426 std::string html = viewer::GetUnsafeArticleTemplateHtml(
444 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF); 427 &article_proto.get()->pages(0), DistilledPagePrefs::LIGHT,
428 DistilledPagePrefs::SERIF);
445 EXPECT_THAT(html, HasSubstr(no_title)); 429 EXPECT_THAT(html, HasSubstr(no_title));
446 EXPECT_THAT(html, HasSubstr(no_content));
447 EXPECT_THAT(html, Not(HasSubstr(some_title))); 430 EXPECT_THAT(html, Not(HasSubstr(some_title)));
448 EXPECT_THAT(html, Not(HasSubstr(some_content)));
449 } 431 }
450 432
451 { // Test missing title and non-empty content for article. 433 { // Test empty title for page.
452 scoped_ptr<DistilledArticleProto> article_proto(
453 new DistilledArticleProto());
454 (*(article_proto->add_pages())).set_html(some_content);
455 std::string html = viewer::GetUnsafeArticleHtml(article_proto.get(),
456 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
457 EXPECT_THAT(html, HasSubstr(no_title));
458 EXPECT_THAT(html, HasSubstr(no_content));
459 EXPECT_THAT(html, Not(HasSubstr(some_title)));
460 EXPECT_THAT(html, Not(HasSubstr(some_content)));
461 }
462
463 { // Test non-empty title and missing content for article.
464 scoped_ptr<DistilledArticleProto> article_proto(
465 new DistilledArticleProto());
466 article_proto->set_title(some_title);
467 std::string html = viewer::GetUnsafeArticleHtml(article_proto.get(),
468 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
469 EXPECT_THAT(html, HasSubstr(no_title));
470 EXPECT_THAT(html, HasSubstr(no_content));
471 EXPECT_THAT(html, Not(HasSubstr(some_title)));
472 EXPECT_THAT(html, Not(HasSubstr(some_content)));
473 }
474
475 { // Test non-empty title and content for page.
476 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
477 page_proto->set_title(some_title);
478 page_proto->set_html(some_content);
479 std::string html = viewer::GetUnsafePartialArticleHtml(page_proto.get(),
480 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
481 EXPECT_THAT(html, HasSubstr(some_title));
482 EXPECT_THAT(html, HasSubstr(some_content));
483 EXPECT_THAT(html, Not(HasSubstr(no_title)));
484 EXPECT_THAT(html, Not(HasSubstr(no_content)));
485 }
486
487 { // Test empty title and content for page.
488 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto()); 434 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
489 page_proto->set_title(""); 435 page_proto->set_title("");
490 page_proto->set_html(""); 436 page_proto->set_html("");
491 std::string html = viewer::GetUnsafePartialArticleHtml(page_proto.get(), 437 std::string html = viewer::GetUnsafeArticleTemplateHtml(
492 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF); 438 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
493 EXPECT_THAT(html, HasSubstr(no_title)); 439 EXPECT_THAT(html, HasSubstr(no_title));
494 EXPECT_THAT(html, HasSubstr(no_content));
495 EXPECT_THAT(html, Not(HasSubstr(some_title))); 440 EXPECT_THAT(html, Not(HasSubstr(some_title)));
496 EXPECT_THAT(html, Not(HasSubstr(some_content)));
497 } 441 }
498 442
499 { // Test missing title and non-empty content for page. 443 { // Test missing title for page.
500 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto()); 444 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
501 page_proto->set_html(some_content); 445 std::string html = viewer::GetUnsafeArticleTemplateHtml(
502 std::string html = viewer::GetUnsafePartialArticleHtml(page_proto.get(), 446 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
503 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
504 EXPECT_THAT(html, HasSubstr(no_title)); 447 EXPECT_THAT(html, HasSubstr(no_title));
505 EXPECT_THAT(html, HasSubstr(some_content));
506 EXPECT_THAT(html, Not(HasSubstr(some_title))); 448 EXPECT_THAT(html, Not(HasSubstr(some_title)));
507 EXPECT_THAT(html, Not(HasSubstr(no_content)));
508 }
509
510 { // Test non-empty title and missing content for page.
511 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
512 page_proto->set_title(some_title);
513 std::string html = viewer::GetUnsafePartialArticleHtml(page_proto.get(),
514 DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
515 EXPECT_THAT(html, HasSubstr(some_title));
516 EXPECT_THAT(html, HasSubstr(no_content));
517 EXPECT_THAT(html, Not(HasSubstr(no_title)));
518 EXPECT_THAT(html, Not(HasSubstr(some_content)));
519 } 449 }
520 } 450 }
521 451
522 } // namespace dom_distiller 452 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698