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

Unified Diff: javatests/org/chromium/distiller/webdocument/WebTableTest.java

Issue 2638823002: Support <picture> in image extraction (Closed)
Patch Set: support lazy loading in <picture> Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « javatests/org/chromium/distiller/webdocument/WebImageTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: javatests/org/chromium/distiller/webdocument/WebTableTest.java
diff --git a/javatests/org/chromium/distiller/webdocument/WebTableTest.java b/javatests/org/chromium/distiller/webdocument/WebTableTest.java
index 0b3e460bf8f7026b4b348cd093fc3454080d3b7c..c7dd0548610e5c3fff476020335d4371a82a1c7d 100644
--- a/javatests/org/chromium/distiller/webdocument/WebTableTest.java
+++ b/javatests/org/chromium/distiller/webdocument/WebTableTest.java
@@ -13,12 +13,44 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
public class WebTableTest extends DomDistillerJsTestCase {
+ public void testGetImageUrlList() {
+ mHead.setInnerHTML("<base href=\"http://example.com/\">");
+ Element table = Document.get().createTableElement();
+
+ String html =
+ "<tbody>" +
+ "<tr>" +
+ "<td><img src=\"http://example.com/table.png\" " +
+ "srcset=\"image100 100w, //example.org/image300 300w\"></td>" +
+ "<td>" +
+ "<picture>" +
+ "<source srcset=\"image200 200w, //example.org/image400 400w\">" +
+ "<img>" +
+ "</picture>" +
+ "</td>" +
+ "</tr>" +
+ "</tbody>";
+
+ table.setInnerHTML(html);
+ mBody.appendChild(table);
+
+ WebTable webTable = new WebTable(table);
+ List<String> urls = webTable.getImageUrlList();
+ assertEquals(5, urls.size());
+ assertEquals("http://example.com/table.png", urls.get(0));
+ assertEquals("http://example.com/image100", urls.get(1));
+ assertEquals("http://example.org/image300", urls.get(2));
+ assertEquals("http://example.com/image200", urls.get(3));
+ assertEquals("http://example.org/image400", urls.get(4));
+ }
+
public void testGenerateOutput() {
Element table = Document.get().createTableElement();
String html = "<tbody>" +
"<tr>" +
"<td>row1col1</td>" +
"<td><img src=\"http://example.com/table.png\"></td>" +
+ "<td><picture><img></picture></td>" +
"</tr>" +
"</tbody>";
table.setInnerHTML(html);
@@ -29,6 +61,8 @@ public class WebTableTest extends DomDistillerJsTestCase {
// Output should be the same as the input in this case.
assertEquals("<table>" + html + "</table>", TestUtil.removeAllDirAttributes(got));
+
+ // Test getImageUrlList() as well.
List<String> imgUrls = webTable.getImageUrlList();
assertEquals(1, imgUrls.size());
assertEquals("http://example.com/table.png", imgUrls.get(0));
« no previous file with comments | « javatests/org/chromium/distiller/webdocument/WebImageTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698