| 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" |
| 11 #include "components/dom_distiller/core/distiller_page.h" | 11 #include "components/dom_distiller/core/distiller_page.h" |
| 12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
| 17 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 18 #include "grit/component_resources.h" | 18 #include "grit/component_resources.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 22 | 23 |
| 23 using content::ContentBrowserTest; | 24 using content::ContentBrowserTest; |
| 24 using testing::ContainsRegex; | 25 using testing::ContainsRegex; |
| 25 using testing::HasSubstr; | 26 using testing::HasSubstr; |
| 26 using testing::Not; | 27 using testing::Not; |
| 27 | 28 |
| 28 namespace dom_distiller { | 29 namespace dom_distiller { |
| 29 | 30 |
| 30 const char* kSimpleArticlePath = "/simple_article.html"; | 31 const char* kSimpleArticlePath = "/simple_article.html"; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 void DistillPage(const base::Closure& quit_closure, const std::string& url) { | 43 void DistillPage(const base::Closure& quit_closure, const std::string& url) { |
| 43 quit_closure_ = quit_closure; | 44 quit_closure_ = quit_closure; |
| 44 distiller_page_->DistillPage( | 45 distiller_page_->DistillPage( |
| 45 embedded_test_server()->GetURL(url), | 46 embedded_test_server()->GetURL(url), |
| 46 dom_distiller::proto::DomDistillerOptions(), | 47 dom_distiller::proto::DomDistillerOptions(), |
| 47 base::Bind(&DistillerPageWebContentsTest::OnPageDistillationFinished, | 48 base::Bind(&DistillerPageWebContentsTest::OnPageDistillationFinished, |
| 48 this)); | 49 this)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void OnPageDistillationFinished(scoped_ptr<DistilledPageInfo> distilled_page, | 52 void OnPageDistillationFinished( |
| 52 bool distillation_successful) { | 53 scoped_ptr<proto::DomDistillerResult> distiller_result, |
| 53 page_info_ = distilled_page.Pass(); | 54 bool distillation_successful) { |
| 55 distiller_result_ = distiller_result.Pass(); |
| 54 quit_closure_.Run(); | 56 quit_closure_.Run(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 private: | 59 private: |
| 58 void AddComponentsResources() { | 60 void AddComponentsResources() { |
| 59 base::FilePath pak_file; | 61 base::FilePath pak_file; |
| 60 base::FilePath pak_dir; | 62 base::FilePath pak_dir; |
| 61 PathService::Get(base::DIR_MODULE, &pak_dir); | 63 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 62 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); | 64 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak")); |
| 63 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 65 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 64 pak_file, ui::SCALE_FACTOR_NONE); | 66 pak_file, ui::SCALE_FACTOR_NONE); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void SetUpTestServer() { | 69 void SetUpTestServer() { |
| 68 base::FilePath path; | 70 base::FilePath path; |
| 69 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 71 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 70 path = path.AppendASCII("components/test/data/dom_distiller"); | 72 path = path.AppendASCII("components/test/data/dom_distiller"); |
| 71 embedded_test_server()->ServeFilesFromDirectory(path); | 73 embedded_test_server()->ServeFilesFromDirectory(path); |
| 72 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 74 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 73 } | 75 } |
| 74 | 76 |
| 75 protected: | 77 protected: |
| 76 void RunUseCurrentWebContentsTest(const std::string& url, | 78 void RunUseCurrentWebContentsTest(const std::string& url, |
| 77 bool expect_new_web_contents, | 79 bool expect_new_web_contents, |
| 78 bool setup_main_frame_observer, | 80 bool setup_main_frame_observer, |
| 79 bool wait_for_document_loaded); | 81 bool wait_for_document_loaded); |
| 80 | 82 |
| 81 DistillerPageWebContents* distiller_page_; | 83 DistillerPageWebContents* distiller_page_; |
| 82 base::Closure quit_closure_; | 84 base::Closure quit_closure_; |
| 83 scoped_ptr<DistilledPageInfo> page_info_; | 85 scoped_ptr<proto::DomDistillerResult> distiller_result_; |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 // Use this class to be able to leak the WebContents, which is needed for when | 88 // Use this class to be able to leak the WebContents, which is needed for when |
| 87 // the current WebContents is used for distillation. | 89 // the current WebContents is used for distillation. |
| 88 class TestDistillerPageWebContents : public DistillerPageWebContents { | 90 class TestDistillerPageWebContents : public DistillerPageWebContents { |
| 89 public: | 91 public: |
| 90 TestDistillerPageWebContents( | 92 TestDistillerPageWebContents( |
| 91 content::BrowserContext* browser_context, | 93 content::BrowserContext* browser_context, |
| 92 const gfx::Size& render_view_size, | 94 const gfx::Size& render_view_size, |
| 93 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle, | 95 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 DistillerPageWebContents distiller_page( | 165 DistillerPageWebContents distiller_page( |
| 164 shell()->web_contents()->GetBrowserContext(), | 166 shell()->web_contents()->GetBrowserContext(), |
| 165 shell()->web_contents()->GetContainerBounds().size(), | 167 shell()->web_contents()->GetContainerBounds().size(), |
| 166 scoped_ptr<SourcePageHandleWebContents>()); | 168 scoped_ptr<SourcePageHandleWebContents>()); |
| 167 distiller_page_ = &distiller_page; | 169 distiller_page_ = &distiller_page; |
| 168 | 170 |
| 169 base::RunLoop run_loop; | 171 base::RunLoop run_loop; |
| 170 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 172 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 171 run_loop.Run(); | 173 run_loop.Run(); |
| 172 | 174 |
| 173 EXPECT_EQ("Test Page Title", page_info_.get()->title); | 175 EXPECT_EQ("Test Page Title", distiller_result_->title()); |
| 174 EXPECT_THAT(page_info_.get()->html, HasSubstr("Lorem ipsum")); | 176 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 175 EXPECT_THAT(page_info_.get()->html, Not(HasSubstr("questionable content"))); | 177 HasSubstr("Lorem ipsum")); |
| 176 EXPECT_EQ("", page_info_.get()->next_page_url); | 178 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 177 EXPECT_EQ("", page_info_.get()->prev_page_url); | 179 Not(HasSubstr("questionable content"))); |
| 180 EXPECT_EQ("", distiller_result_->pagination_info().next_page()); |
| 181 EXPECT_EQ("", distiller_result_->pagination_info().prev_page()); |
| 178 } | 182 } |
| 179 | 183 |
| 180 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { | 184 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeLinks) { |
| 181 DistillerPageWebContents distiller_page( | 185 DistillerPageWebContents distiller_page( |
| 182 shell()->web_contents()->GetBrowserContext(), | 186 shell()->web_contents()->GetBrowserContext(), |
| 183 shell()->web_contents()->GetContainerBounds().size(), | 187 shell()->web_contents()->GetContainerBounds().size(), |
| 184 scoped_ptr<SourcePageHandleWebContents>()); | 188 scoped_ptr<SourcePageHandleWebContents>()); |
| 185 distiller_page_ = &distiller_page; | 189 distiller_page_ = &distiller_page; |
| 186 | 190 |
| 187 base::RunLoop run_loop; | 191 base::RunLoop run_loop; |
| 188 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 192 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 189 run_loop.Run(); | 193 run_loop.Run(); |
| 190 | 194 |
| 191 // A relative link should've been updated. | 195 // A relative link should've been updated. |
| 192 EXPECT_THAT(page_info_.get()->html, | 196 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 193 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); | 197 ContainsRegex("href=\"http://127.0.0.1:.*/relativelink.html\"")); |
| 194 EXPECT_THAT(page_info_.get()->html, | 198 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 195 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); | 199 HasSubstr("href=\"http://www.google.com/absolutelink.html\"")); |
| 196 } | 200 } |
| 197 | 201 |
| 198 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { | 202 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeImages) { |
| 199 DistillerPageWebContents distiller_page( | 203 DistillerPageWebContents distiller_page( |
| 200 shell()->web_contents()->GetBrowserContext(), | 204 shell()->web_contents()->GetBrowserContext(), |
| 201 shell()->web_contents()->GetContainerBounds().size(), | 205 shell()->web_contents()->GetContainerBounds().size(), |
| 202 scoped_ptr<SourcePageHandleWebContents>()); | 206 scoped_ptr<SourcePageHandleWebContents>()); |
| 203 distiller_page_ = &distiller_page; | 207 distiller_page_ = &distiller_page; |
| 204 | 208 |
| 205 base::RunLoop run_loop; | 209 base::RunLoop run_loop; |
| 206 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 210 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 207 run_loop.Run(); | 211 run_loop.Run(); |
| 208 | 212 |
| 209 // A relative link should've been updated. | 213 // A relative link should've been updated. |
| 210 EXPECT_THAT(page_info_.get()->html, | 214 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 211 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); | 215 ContainsRegex("src=\"http://127.0.0.1:.*/relativeimage.png\"")); |
| 212 EXPECT_THAT(page_info_.get()->html, | 216 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 213 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); | 217 HasSubstr("src=\"http://www.google.com/absoluteimage.png\"")); |
| 214 } | 218 } |
| 215 | 219 |
| 216 | 220 |
| 217 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) { | 221 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, HandlesRelativeVideos) { |
| 218 DistillerPageWebContents distiller_page( | 222 DistillerPageWebContents distiller_page( |
| 219 shell()->web_contents()->GetBrowserContext(), | 223 shell()->web_contents()->GetBrowserContext(), |
| 220 shell()->web_contents()->GetContainerBounds().size(), | 224 shell()->web_contents()->GetContainerBounds().size(), |
| 221 scoped_ptr<SourcePageHandleWebContents>()); | 225 scoped_ptr<SourcePageHandleWebContents>()); |
| 222 distiller_page_ = &distiller_page; | 226 distiller_page_ = &distiller_page; |
| 223 | 227 |
| 224 base::RunLoop run_loop; | 228 base::RunLoop run_loop; |
| 225 DistillPage(run_loop.QuitClosure(), kVideoArticlePath); | 229 DistillPage(run_loop.QuitClosure(), kVideoArticlePath); |
| 226 run_loop.Run(); | 230 run_loop.Run(); |
| 227 | 231 |
| 228 // A relative source/track should've been updated. | 232 // A relative source/track should've been updated. |
| 233 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 234 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.mp4\"")); |
| 229 EXPECT_THAT( | 235 EXPECT_THAT( |
| 230 page_info_.get()->html, | 236 distiller_result_->distilled_content().html(), |
| 231 ContainsRegex("src=\"http://127.0.0.1:.*/relative_video.mp4\"")); | |
| 232 EXPECT_THAT( | |
| 233 page_info_.get()->html, | |
| 234 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); | 237 ContainsRegex("src=\"http://127.0.0.1:.*/relative_track_en.vtt\"")); |
| 235 EXPECT_THAT( | 238 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 236 page_info_.get()->html, | 239 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); |
| 237 HasSubstr("src=\"http://www.google.com/absolute_video.ogg\"")); | 240 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 238 EXPECT_THAT( | 241 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); |
| 239 page_info_.get()->html, | |
| 240 HasSubstr("src=\"http://www.google.com/absolute_track_fr.vtt\"")); | |
| 241 } | 242 } |
| 242 | 243 |
| 243 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { | 244 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, VisibilityDetection) { |
| 244 DistillerPageWebContents distiller_page( | 245 DistillerPageWebContents distiller_page( |
| 245 shell()->web_contents()->GetBrowserContext(), | 246 shell()->web_contents()->GetBrowserContext(), |
| 246 shell()->web_contents()->GetContainerBounds().size(), | 247 shell()->web_contents()->GetContainerBounds().size(), |
| 247 scoped_ptr<SourcePageHandleWebContents>()); | 248 scoped_ptr<SourcePageHandleWebContents>()); |
| 248 distiller_page_ = &distiller_page; | 249 distiller_page_ = &distiller_page; |
| 249 | 250 |
| 250 // visble_style.html and invisible_style.html only differ by the visibility | 251 // visble_style.html and invisible_style.html only differ by the visibility |
| 251 // internal stylesheet. | 252 // internal stylesheet. |
| 252 | 253 |
| 253 { | 254 { |
| 254 base::RunLoop run_loop; | 255 base::RunLoop run_loop; |
| 255 DistillPage(run_loop.QuitClosure(), "/visible_style.html"); | 256 DistillPage(run_loop.QuitClosure(), "/visible_style.html"); |
| 256 run_loop.Run(); | 257 run_loop.Run(); |
| 257 EXPECT_THAT(page_info_.get()->html, HasSubstr("Lorem ipsum")); | 258 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 259 HasSubstr("Lorem ipsum")); |
| 258 } | 260 } |
| 259 | 261 |
| 260 { | 262 { |
| 261 base::RunLoop run_loop; | 263 base::RunLoop run_loop; |
| 262 DistillPage(run_loop.QuitClosure(), "/invisible_style.html"); | 264 DistillPage(run_loop.QuitClosure(), "/invisible_style.html"); |
| 263 run_loop.Run(); | 265 run_loop.Run(); |
| 264 EXPECT_THAT(page_info_.get()->html, Not(HasSubstr("Lorem ipsum"))); | 266 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 267 Not(HasSubstr("Lorem ipsum"))); |
| 265 } | 268 } |
| 266 } | 269 } |
| 267 | 270 |
| 268 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, | 271 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, |
| 269 UsingCurrentWebContentsWrongUrl) { | 272 UsingCurrentWebContentsWrongUrl) { |
| 270 std::string url("/bogus"); | 273 std::string url("/bogus"); |
| 271 bool expect_new_web_contents = true; | 274 bool expect_new_web_contents = true; |
| 272 bool setup_main_frame_observer = true; | 275 bool setup_main_frame_observer = true; |
| 273 bool wait_for_document_loaded = true; | 276 bool wait_for_document_loaded = true; |
| 274 RunUseCurrentWebContentsTest(url, | 277 RunUseCurrentWebContentsTest(url, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 source_page_handle.Pass(), | 347 source_page_handle.Pass(), |
| 345 expect_new_web_contents); | 348 expect_new_web_contents); |
| 346 distiller_page_ = &distiller_page; | 349 distiller_page_ = &distiller_page; |
| 347 | 350 |
| 348 base::RunLoop run_loop; | 351 base::RunLoop run_loop; |
| 349 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); | 352 DistillPage(run_loop.QuitClosure(), kSimpleArticlePath); |
| 350 run_loop.Run(); | 353 run_loop.Run(); |
| 351 | 354 |
| 352 // Sanity check of distillation process. | 355 // Sanity check of distillation process. |
| 353 EXPECT_EQ(expect_new_web_contents, distiller_page.new_web_contents_created()); | 356 EXPECT_EQ(expect_new_web_contents, distiller_page.new_web_contents_created()); |
| 354 EXPECT_EQ("Test Page Title", page_info_.get()->title); | 357 EXPECT_EQ("Test Page Title", distiller_result_->title()); |
| 355 } | 358 } |
| 356 | 359 |
| 357 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { | 360 IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MarkupInfo) { |
| 358 DistillerPageWebContents distiller_page( | 361 DistillerPageWebContents distiller_page( |
| 359 shell()->web_contents()->GetBrowserContext(), | 362 shell()->web_contents()->GetBrowserContext(), |
| 360 shell()->web_contents()->GetContainerBounds().size(), | 363 shell()->web_contents()->GetContainerBounds().size(), |
| 361 scoped_ptr<SourcePageHandleWebContents>()); | 364 scoped_ptr<SourcePageHandleWebContents>()); |
| 362 distiller_page_ = &distiller_page; | 365 distiller_page_ = &distiller_page; |
| 363 | 366 |
| 364 base::RunLoop run_loop; | 367 base::RunLoop run_loop; |
| 365 DistillPage(run_loop.QuitClosure(), "/markup_article.html"); | 368 DistillPage(run_loop.QuitClosure(), "/markup_article.html"); |
| 366 run_loop.Run(); | 369 run_loop.Run(); |
| 367 | 370 |
| 368 EXPECT_THAT(page_info_.get()->html, HasSubstr("Lorem ipsum")); | 371 EXPECT_THAT(distiller_result_->distilled_content().html(), |
| 369 EXPECT_EQ("Marked-up Markup Test Page Title", page_info_.get()->title); | 372 HasSubstr("Lorem ipsum")); |
| 373 EXPECT_EQ("Marked-up Markup Test Page Title", distiller_result_->title()); |
| 370 | 374 |
| 371 const DistilledPageInfo::MarkupInfo& markup_info = page_info_->markup_info; | 375 const proto::MarkupInfo markup_info = distiller_result_->markup_info(); |
| 372 EXPECT_EQ("Marked-up Markup Test Page Title", markup_info.title); | 376 EXPECT_EQ("Marked-up Markup Test Page Title", markup_info.title()); |
| 373 EXPECT_EQ("Article", markup_info.type); | 377 EXPECT_EQ("Article", markup_info.type()); |
| 374 EXPECT_EQ("http://test/markup.html", markup_info.url); | 378 EXPECT_EQ("http://test/markup.html", markup_info.url()); |
| 375 EXPECT_EQ("This page tests Markup Info.", markup_info.description); | 379 EXPECT_EQ("This page tests Markup Info.", markup_info.description()); |
| 376 EXPECT_EQ("Whoever Published", markup_info.publisher); | 380 EXPECT_EQ("Whoever Published", markup_info.publisher()); |
| 377 EXPECT_EQ("Copyright 2000-2014 Whoever Copyrighted", markup_info.copyright); | 381 EXPECT_EQ("Copyright 2000-2014 Whoever Copyrighted", markup_info.copyright()); |
| 378 EXPECT_EQ("Whoever Authored", markup_info.author); | 382 EXPECT_EQ("Whoever Authored", markup_info.author()); |
| 379 | 383 |
| 380 const DistilledPageInfo::MarkupArticle& markup_article = markup_info.article; | 384 const proto::MarkupArticle markup_article = markup_info.article(); |
| 381 EXPECT_EQ("Whatever Section", markup_article.section); | 385 EXPECT_EQ("Whatever Section", markup_article.section()); |
| 382 EXPECT_EQ("July 23, 2014", markup_article.published_time); | 386 EXPECT_EQ("July 23, 2014", markup_article.published_time()); |
| 383 EXPECT_EQ("2014-07-23T23:59", markup_article.modified_time); | 387 EXPECT_EQ("2014-07-23T23:59", markup_article.modified_time()); |
| 384 EXPECT_EQ("", markup_article.expiration_time); | 388 EXPECT_EQ("", markup_article.expiration_time()); |
| 385 ASSERT_EQ(1U, markup_article.authors.size()); | 389 ASSERT_EQ(1, markup_article.authors_size()); |
| 386 EXPECT_EQ("Whoever Authored", markup_article.authors[0]); | 390 EXPECT_EQ("Whoever Authored", markup_article.authors(0)); |
| 387 | 391 |
| 388 ASSERT_EQ(2U, markup_info.images.size()); | 392 ASSERT_EQ(2, markup_info.images_size()); |
| 389 | 393 |
| 390 const DistilledPageInfo::MarkupImage& markup_image1 = markup_info.images[0]; | 394 const proto::MarkupImage markup_image1 = markup_info.images(0); |
| 391 EXPECT_EQ("http://test/markup1.jpeg", markup_image1.url); | 395 EXPECT_EQ("http://test/markup1.jpeg", markup_image1.url()); |
| 392 EXPECT_EQ("https://test/markup1.jpeg", markup_image1.secure_url); | 396 EXPECT_EQ("https://test/markup1.jpeg", markup_image1.secure_url()); |
| 393 EXPECT_EQ("jpeg", markup_image1.type); | 397 EXPECT_EQ("jpeg", markup_image1.type()); |
| 394 EXPECT_EQ("", markup_image1.caption); | 398 EXPECT_EQ("", markup_image1.caption()); |
| 395 EXPECT_EQ(600, markup_image1.width); | 399 EXPECT_EQ(600, markup_image1.width()); |
| 396 EXPECT_EQ(400, markup_image1.height); | 400 EXPECT_EQ(400, markup_image1.height()); |
| 397 | 401 |
| 398 const DistilledPageInfo::MarkupImage& markup_image2 = markup_info.images[1]; | 402 const proto::MarkupImage markup_image2 = markup_info.images(1); |
| 399 EXPECT_EQ("http://test/markup2.gif", markup_image2.url); | 403 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); |
| 400 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url); | 404 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); |
| 401 EXPECT_EQ("gif", markup_image2.type); | 405 EXPECT_EQ("gif", markup_image2.type()); |
| 402 EXPECT_EQ("", markup_image2.caption); | 406 EXPECT_EQ("", markup_image2.caption()); |
| 403 EXPECT_EQ(1000, markup_image2.width); | 407 EXPECT_EQ(1000, markup_image2.width()); |
| 404 EXPECT_EQ(600, markup_image2.height); | 408 EXPECT_EQ(600, markup_image2.height()); |
| 405 } | 409 } |
| 406 | 410 |
| 407 } // namespace dom_distiller | 411 } // namespace dom_distiller |
| OLD | NEW |