Chromium Code Reviews| 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..8bbfb02a90dd8a5625d70d5ba1a03344d327cd8f 100644 |
| --- a/javatests/org/chromium/distiller/EmbedExtractorTest.java |
| +++ b/javatests/org/chromium/distiller/EmbedExtractorTest.java |
| @@ -380,4 +380,54 @@ public class EmbedExtractorTest extends DomDistillerJsTestCase { |
| assertEquals(38, result.getHeight()); |
| assertEquals(38, result.getWidth()); |
| } |
| + |
| + public void testFigureWithoutCaption() { |
| + ImageElement image = TestUtil.createImage(); |
| + image.setSrc("http://wwww.someimage.com/image.jpeg"); |
|
wychen
2016/05/31 21:28:04
We should use example.com for the domain.
marcelorcorrea
2016/05/31 21:46:44
Done.
|
| + 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.someimage.com/image.jpeg\"" + |
| + " width=\"100\" height=\"100\">" + |
| + "</figure>"; |
| + assertNotNull(result); |
| + assertEquals(100, result.getHeight()); |
| + assertEquals(100, result.getWidth()); |
| + assertEquals(expected, got); |
| + } |
| + |
| + public void testFigureWithCaption() { |
|
wychen
2016/05/31 21:28:04
Add one more test without <img>?
marcelorcorrea
2016/05/31 21:46:44
Done.
|
| + ImageElement image = TestUtil.createImage(); |
| + image.setSrc("http://wwww.someimage.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.someimage.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); |
| + } |
| } |