| Index: javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| diff --git a/javatests/org/chromium/distiller/EmbedExtractorTest.java b/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| index 5c23f0c3f9a6cdc95632d8e29088d1050db5ce32..6731b044aef5ebc87dfb956ce723cb46f56b125f 100644
|
| --- a/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| +++ b/javatests/org/chromium/distiller/EmbedExtractorTest.java
|
| @@ -380,4 +380,63 @@ public class EmbedExtractorTest extends DomDistillerJsTestCase {
|
| assertEquals(38, result.getHeight());
|
| assertEquals(38, result.getWidth());
|
| }
|
| +
|
| + 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);
|
| + }
|
| }
|
|
|