| Index: javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| diff --git a/javatests/org/chromium/distiller/EmbedExtractorTest.java b/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| index 2b7a2f886cb30bff60a738b98bd8f9f571c9d97c..9a047dceb1adef76af03afdb970087bd9951fded 100644
|
| --- a/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| +++ b/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| @@ -210,7 +210,7 @@ public class EmbedExtractorTest extends DomDistillerJsTestCase {
|
| mBody.appendChild(twitter);
|
|
|
| // This string represents a very simplified version of the twitter iframe embed structure.
|
| - String iframeStructure =
|
| + String iframeStructure =
|
| "<div class=\"media-forward root standalone-tweet ltr\"" +
|
| "data-iframe-title=\"Embedded Tweet\"" +
|
| "data-scribe=\"page:tweet\">" +
|
| @@ -400,4 +400,63 @@ public class EmbedExtractorTest extends DomDistillerJsTestCase {
|
| extractLazilyLoadedImage("data-original");
|
| extractLazilyLoadedImage("data-url");
|
| }
|
| +
|
| + public void testFigureWithoutCaption() {
|
| + ImageElement image = TestUtil.createImage();
|
| + image.setSrc("http://wwww.example.com/image.jpeg");
|
| + image.setAttribute("width", "100");
|
| + image.setAttribute("height", "100");
|
| + Element figure = Document.get().createElement("FIGURE");
|
| + figure.appendChild(image);
|
| + mBody.appendChild(figure);
|
| +
|
| + EmbedExtractor extractor = new ImageExtractor();
|
| + WebImage result = (WebImage) extractor.extract(figure);
|
| + String got = result.generateOutput(false);
|
| + String expected =
|
| + "<figure>" +
|
| + "<img src=\"http://wwww.example.com/image.jpeg\"" +
|
| + " width=\"100\" height=\"100\">" +
|
| + "</figure>";
|
| + assertNotNull(result);
|
| + assertEquals(100, result.getHeight());
|
| + assertEquals(100, result.getWidth());
|
| + assertEquals(expected, got);
|
| + }
|
| +
|
| + public void testFigureWithCaption() {
|
| + ImageElement image = TestUtil.createImage();
|
| + image.setSrc("http://wwww.example.com/image.jpeg");
|
| + image.setAttribute("width", "100");
|
| + image.setAttribute("height", "100");
|
| + Element figure = Document.get().createElement("FIGURE");
|
| + figure.appendChild(image);
|
| + Element figcaption = Document.get().createElement("FIGCAPTION");
|
| + figcaption.setInnerHTML("This is a caption");
|
| + figure.appendChild(figcaption);
|
| + mBody.appendChild(figure);
|
| +
|
| + EmbedExtractor extractor = new ImageExtractor();
|
| + WebImage result = (WebImage) extractor.extract(figure);
|
| + String got = result.generateOutput(false);
|
| + String expected =
|
| + "<figure>" +
|
| + "<img src=\"http://wwww.example.com/image.jpeg\"" +
|
| + " width=\"100\" height=\"100\">" +
|
| + "<figcaption>This is a caption</figcaption>" +
|
| + "</figure>";
|
| + assertNotNull(result);
|
| + assertEquals(100, result.getHeight());
|
| + assertEquals(100, result.getWidth());
|
| + assertEquals(expected, got);
|
| + }
|
| +
|
| + public void testFigureWithoutImageAndCaption() {
|
| + Element figure = Document.get().createElement("FIGURE");
|
| + mBody.appendChild(figure);
|
| +
|
| + EmbedExtractor extractor = new ImageExtractor();
|
| + WebImage result = (WebImage) extractor.extract(figure);
|
| + assertNull(result);
|
| + }
|
| }
|
|
|