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

Side by Side Diff: javatests/org/chromium/distiller/ContentExtractorTest.java

Issue 2000093005: Support extraction of lazily-loaded images (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: fix comments Created 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 package org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.dom.client.Document; 7 import com.google.gwt.dom.client.Document;
8 import com.google.gwt.dom.client.Element; 8 import com.google.gwt.dom.client.Element;
9 9
10 public class ContentExtractorTest extends DomDistillerJsTestCase { 10 public class ContentExtractorTest extends DomDistillerJsTestCase {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 public void testImage() { 89 public void testImage() {
90 // Test the absolute and different kinds of relative URLs for image sour ces, 90 // Test the absolute and different kinds of relative URLs for image sour ces,
91 // and also add an extra comma (,) as malformed srcset syntax for robust ness. 91 // and also add an extra comma (,) as malformed srcset syntax for robust ness.
92 // Also test images in WebImage and WebTable. 92 // Also test images in WebImage and WebTable.
93 // TODO(wychen): add images in WebText when it is supported. 93 // TODO(wychen): add images in WebText when it is supported.
94 final String html = 94 final String html =
95 "<h1>" + CONTENT_TEXT + "</h1>" + 95 "<h1>" + CONTENT_TEXT + "</h1>" +
96 "<img id=\"a\" style=\"typo\" align=\"left\" src=\"image\" srcset=\" image200 200w, //example.org/image400 400w\">" + 96 "<img id=\"a\" style=\"typo\" align=\"left\" src=\"image\" srcset=\" image200 200w, //example.org/image400 400w\">" +
97 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" src= \"image2\">" + 97 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" data -src=\"image2\">" +
98 "<table role=\"grid\"><tbody><tr><td>" + 98 "<table role=\"grid\"><tbody><tr><td>" +
99 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt ps://example.com/image2x 2x, /image4x 4x,\">" + 99 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt ps://example.com/image2x 2x, /image4x 4x,\">" +
100 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" + 100 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" +
101 "</td></tr></tbody></table>" + 101 "</td></tr></tbody></table>" +
102 "<p>" + CONTENT_TEXT + "</p>"; 102 "<p>" + CONTENT_TEXT + "</p>";
103 103
104 final String expected = 104 final String expected =
105 "<h1>" + CONTENT_TEXT + "</h1>" + 105 "<h1>" + CONTENT_TEXT + "</h1>" +
106 "<img src=\"http://example.com/path/image\" " + 106 "<img src=\"http://example.com/path/image\" " +
107 "srcset=\"http://example.com/path/image200 200w, http://example .org/image400 400w\">" + 107 "srcset=\"http://example.com/path/image200 200w, http://example .org/image400 400w\">" +
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 public void testRemoveStyleAttributes() { 152 public void testRemoveStyleAttributes() {
153 String html = 153 String html =
154 "<h1 style=\"font-weight: folder\">" + 154 "<h1 style=\"font-weight: folder\">" +
155 CONTENT_TEXT + 155 CONTENT_TEXT +
156 "</h1>" + 156 "</h1>" +
157 "<p style=\"\">" + 157 "<p style=\"\">" +
158 CONTENT_TEXT + 158 CONTENT_TEXT +
159 "</p>" + 159 "</p>" +
160 "<img style=\"align: left\" src=\"/test.png\">" + 160 "<img style=\"align: left\" data-src=\"/test.png\">" +
161 "<table style=\"position: absolute\">" + 161 "<table style=\"position: absolute\">" +
162 "<tbody style=\"font-size: 2\">" + 162 "<tbody style=\"font-size: 2\">" +
163 "<tr style=\"z-index: 0\">" + 163 "<tr style=\"z-index: 0\">" +
164 "<th style=\"top: 0px\">" + CONTENT_TEXT + 164 "<th style=\"top: 0px\">" + CONTENT_TEXT +
165 "<img style=\"align: left\" src=\"/test.png\">" + 165 "<img style=\"align: left\" src=\"/test.png\">" +
166 "</th>" + 166 "</th>" +
167 "<th style=\"width: 20px\">" + CONTENT_TEXT + "</th>" + 167 "<th style=\"width: 20px\">" + CONTENT_TEXT + "</th>" +
168 "</tr><tr style=\"left: 0\">" + 168 "</tr><tr style=\"left: 0\">" +
169 "<td style=\"display: block\">" + CONTENT_TEXT + "</td>" + 169 "<td style=\"display: block\">" + CONTENT_TEXT + "</td>" +
170 "<td style=\"color: #123\">" + CONTENT_TEXT + "</td>" + 170 "<td style=\"color: #123\">" + CONTENT_TEXT + "</td>" +
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 "</p>"; 661 "</p>";
662 662
663 mBody.setInnerHTML(html); 663 mBody.setInnerHTML(html);
664 664
665 ContentExtractor extractor = new ContentExtractor(mRoot); 665 ContentExtractor extractor = new ContentExtractor(mRoot);
666 String extractedContent = extractor.extractContent(); 666 String extractedContent = extractor.extractContent();
667 assertEquals(expected, 667 assertEquals(expected,
668 TestUtil.removeAllDirAttributes(extractedContent)); 668 TestUtil.removeAllDirAttributes(extractedContent));
669 } 669 }
670 } 670 }
OLDNEW
« no previous file with comments | « java/org/chromium/distiller/webdocument/WebImage.java ('k') | javatests/org/chromium/distiller/EmbedExtractorTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698