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

Unified Diff: javatests/org/chromium/distiller/DomUtilTest.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
Index: javatests/org/chromium/distiller/DomUtilTest.java
diff --git a/javatests/org/chromium/distiller/DomUtilTest.java b/javatests/org/chromium/distiller/DomUtilTest.java
index bd73eecbac55c621adcec950bed1d78a85198759..5c9fe634ce8a4e5b003ecfc74cb13ded5c4b7290 100644
--- a/javatests/org/chromium/distiller/DomUtilTest.java
+++ b/javatests/org/chromium/distiller/DomUtilTest.java
@@ -250,7 +250,7 @@ public class DomUtilTest extends DomDistillerJsTestCase {
"<img src=\"image\" srcset=\"image200 200w, image400 400w\">" +
"<img src=\"image2\">" +
"<video src=\"video\" poster=\"poster\">" +
- "<source src=\"source\">" +
+ "<source src=\"source\" srcset=\"s2, s3\">" +
"<track src=\"track\">" +
"</video>";
@@ -260,7 +260,8 @@ public class DomUtilTest extends DomDistillerJsTestCase {
"srcset=\"http://example.com/image200 200w, http://example.com/image400 400w\">" +
"<img src=\"http://example.com/image2\">" +
"<video src=\"http://example.com/video\" poster=\"http://example.com/poster\">" +
- "<source src=\"http://example.com/source\">" +
+ "<source src=\"http://example.com/source\" " +
+ "srcset=\"http://example.com/s2, http://example.com/s3\">" +
"<track src=\"http://example.com/track\">" +
"</video>";
@@ -286,6 +287,23 @@ public class DomUtilTest extends DomDistillerJsTestCase {
assertEquals("http://example.com/image400", list.get(1));
}
+ public void testGetAllSrcSetUrls() {
+ String html =
+ "<picture>" +
+ "<source srcset=\"image200 200w, //example.org/image400 400w\">" +
+ "<source srcset=\"image100 100w, //example.org/image300 300w\">" +
+ "<img>" +
+ "</picture>";
+ Element container = Document.get().createDivElement();
+ container.setInnerHTML(html);
+ List<String> urls = DomUtil.getAllSrcSetUrls(container);
+ assertEquals(4, urls.size());
+ assertEquals("image200", urls.get(0));
+ assertEquals("//example.org/image400", urls.get(1));
+ assertEquals("image100", urls.get(2));
+ assertEquals("//example.org/image300", urls.get(3));
+ }
+
public void testStripTableBackgroundColorAttributes() {
String tableWithBGColorHTML =
"<table bgcolor=\"red\">" +

Powered by Google App Engine
This is Rietveld 408576698