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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 10 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 const proto::MarkupImage markup_image2 = markup_info.images(1); | 425 const proto::MarkupImage markup_image2 = markup_info.images(1); |
426 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); | 426 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); |
427 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); | 427 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); |
428 EXPECT_EQ("gif", markup_image2.type()); | 428 EXPECT_EQ("gif", markup_image2.type()); |
429 EXPECT_EQ("", markup_image2.caption()); | 429 EXPECT_EQ("", markup_image2.caption()); |
430 EXPECT_EQ(1000, markup_image2.width()); | 430 EXPECT_EQ(1000, markup_image2.width()); |
431 EXPECT_EQ(600, markup_image2.height()); | 431 EXPECT_EQ(600, markup_image2.height()); |
432 } | 432 } |
433 | 433 |
434 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, TestTitleNeverEmpty) { | |
435 const std::string some_title = "some title"; | |
436 const std::string no_title = | |
437 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); | |
438 | |
439 { // Test empty title for article. | |
440 scoped_ptr<DistilledArticleProto> article_proto( | |
441 new DistilledArticleProto()); | |
442 article_proto->set_title(""); | |
443 (*(article_proto->add_pages())).set_html(""); | |
444 std::string html = viewer::GetUnsafeArticleTemplateHtml( | |
445 &article_proto.get()->pages(0), DistilledPagePrefs::LIGHT, | |
446 DistilledPagePrefs::SERIF); | |
447 EXPECT_THAT(html, HasSubstr(no_title)); | |
448 EXPECT_THAT(html, Not(HasSubstr(some_title))); | |
449 } | |
450 | |
451 { // Test empty title for page. | |
452 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto()); | |
453 page_proto->set_title(""); | |
454 page_proto->set_html(""); | |
455 std::string html = viewer::GetUnsafeArticleTemplateHtml( | |
456 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF); | |
457 EXPECT_THAT(html, HasSubstr(no_title)); | |
458 EXPECT_THAT(html, Not(HasSubstr(some_title))); | |
459 } | |
460 | |
461 { // Test missing title for page. | |
462 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto()); | |
463 std::string html = viewer::GetUnsafeArticleTemplateHtml( | |
464 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF); | |
465 EXPECT_THAT(html, HasSubstr(no_title)); | |
466 EXPECT_THAT(html, Not(HasSubstr(some_title))); | |
467 } | |
468 } | |
469 | |
470 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, | 434 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, |
471 TestNoContentDoesNotCrash) { | 435 TestNoContentDoesNotCrash) { |
472 const std::string no_content = | 436 const std::string no_content = |
473 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); | 437 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); |
474 | 438 |
475 { // Test zero pages. | 439 { // Test zero pages. |
476 scoped_ptr<DistilledArticleProto> article_proto( | 440 scoped_ptr<DistilledArticleProto> article_proto( |
477 new DistilledArticleProto()); | 441 new DistilledArticleProto()); |
478 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); | 442 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); |
479 EXPECT_THAT(js, HasSubstr(no_content)); | 443 EXPECT_THAT(js, HasSubstr(no_content)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 ASSERT_TRUE(js_result_); | 482 ASSERT_TRUE(js_result_); |
519 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); | 483 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); |
520 | 484 |
521 ASSERT_TRUE(dict->HasKey("success")); | 485 ASSERT_TRUE(dict->HasKey("success")); |
522 bool success; | 486 bool success; |
523 ASSERT_TRUE(dict->GetBoolean("success", &success)); | 487 ASSERT_TRUE(dict->GetBoolean("success", &success)); |
524 EXPECT_TRUE(success); | 488 EXPECT_TRUE(success); |
525 } | 489 } |
526 | 490 |
527 } // namespace dom_distiller | 491 } // namespace dom_distiller |
OLD | NEW |