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

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

Issue 1130703003: Show template before distiller finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-superclass
Patch Set: Fix flaky test Created 5 years, 6 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/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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 const proto::MarkupImage markup_image2 = markup_info.images(1); 411 const proto::MarkupImage markup_image2 = markup_info.images(1);
412 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); 412 EXPECT_EQ("http://test/markup2.gif", markup_image2.url());
413 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); 413 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url());
414 EXPECT_EQ("gif", markup_image2.type()); 414 EXPECT_EQ("gif", markup_image2.type());
415 EXPECT_EQ("", markup_image2.caption()); 415 EXPECT_EQ("", markup_image2.caption());
416 EXPECT_EQ(1000, markup_image2.width()); 416 EXPECT_EQ(1000, markup_image2.width());
417 EXPECT_EQ(600, markup_image2.height()); 417 EXPECT_EQ(600, markup_image2.height());
418 } 418 }
419 419
420 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, TestTitleNeverEmpty) {
421 const std::string some_title = "some title";
422 const std::string no_title =
423 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE);
424
425 { // Test empty title for article.
426 scoped_ptr<DistilledArticleProto> article_proto(
427 new DistilledArticleProto());
428 article_proto->set_title("");
429 (*(article_proto->add_pages())).set_html("");
430 std::string html = viewer::GetUnsafeArticleTemplateHtml(
431 &article_proto.get()->pages(0), DistilledPagePrefs::LIGHT,
432 DistilledPagePrefs::SERIF);
433 EXPECT_THAT(html, HasSubstr(no_title));
434 EXPECT_THAT(html, Not(HasSubstr(some_title)));
435 }
436
437 { // Test empty title for page.
438 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
439 page_proto->set_title("");
440 page_proto->set_html("");
441 std::string html = viewer::GetUnsafeArticleTemplateHtml(
442 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
443 EXPECT_THAT(html, HasSubstr(no_title));
444 EXPECT_THAT(html, Not(HasSubstr(some_title)));
445 }
446
447 { // Test missing title for page.
448 scoped_ptr<DistilledPageProto> page_proto(new DistilledPageProto());
449 std::string html = viewer::GetUnsafeArticleTemplateHtml(
450 page_proto.get(), DistilledPagePrefs::LIGHT, DistilledPagePrefs::SERIF);
451 EXPECT_THAT(html, HasSubstr(no_title));
452 EXPECT_THAT(html, Not(HasSubstr(some_title)));
453 }
454 }
455
456 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, 420 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
457 TestNoContentDoesNotCrash) { 421 TestNoContentDoesNotCrash) {
458 const std::string no_content = 422 const std::string no_content =
459 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); 423 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT);
460 424
461 { // Test zero pages. 425 { // Test zero pages.
462 scoped_ptr<DistilledArticleProto> article_proto( 426 scoped_ptr<DistilledArticleProto> article_proto(
463 new DistilledArticleProto()); 427 new DistilledArticleProto());
464 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get()); 428 std::string js = viewer::GetUnsafeArticleContentJs(article_proto.get());
465 EXPECT_THAT(js, HasSubstr(no_content)); 429 EXPECT_THAT(js, HasSubstr(no_content));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 ASSERT_TRUE(js_result_); 468 ASSERT_TRUE(js_result_);
505 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); 469 ASSERT_TRUE(js_result_->GetAsDictionary(&dict));
506 470
507 ASSERT_TRUE(dict->HasKey("success")); 471 ASSERT_TRUE(dict->HasKey("success"));
508 bool success; 472 bool success;
509 ASSERT_TRUE(dict->GetBoolean("success", &success)); 473 ASSERT_TRUE(dict->GetBoolean("success", &success));
510 EXPECT_TRUE(success); 474 EXPECT_TRUE(success);
511 } 475 }
512 476
513 } // namespace dom_distiller 477 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller.gypi ('k') | components/dom_distiller/content/dom_distiller_viewer_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698