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

Side by Side Diff: javatests/org/chromium/distiller/EmbedExtractorTest.java

Issue 2020403002: Add support for figure element (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.dom.client.Style; 7 import com.google.gwt.dom.client.Style;
8 import org.chromium.distiller.webdocument.WebEmbed; 8 import org.chromium.distiller.webdocument.WebEmbed;
9 import org.chromium.distiller.webdocument.WebImage; 9 import org.chromium.distiller.webdocument.WebImage;
10 import org.chromium.distiller.extractors.embeds.EmbedExtractor; 10 import org.chromium.distiller.extractors.embeds.EmbedExtractor;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 ImageElement image = TestUtil.createImage(); 373 ImageElement image = TestUtil.createImage();
374 image.setSrc(IMAGE_BASE64); 374 image.setSrc(IMAGE_BASE64);
375 image.getStyle().setHeight(1, Style.Unit.CM); 375 image.getStyle().setHeight(1, Style.Unit.CM);
376 mBody.appendChild(image); 376 mBody.appendChild(image);
377 EmbedExtractor extractor = new ImageExtractor(); 377 EmbedExtractor extractor = new ImageExtractor();
378 WebImage result = (WebImage) extractor.extract(image); 378 WebImage result = (WebImage) extractor.extract(image);
379 assertNotNull(result); 379 assertNotNull(result);
380 assertEquals(38, result.getHeight()); 380 assertEquals(38, result.getHeight());
381 assertEquals(38, result.getWidth()); 381 assertEquals(38, result.getWidth());
382 } 382 }
383
384 public void testFigureWithoutCaption() {
385 ImageElement image = TestUtil.createImage();
386 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.
387 image.setAttribute("width", "100");
388 image.setAttribute("height", "100");
389 Element figure = Document.get().createElement("FIGURE");
390 figure.appendChild(image);
391 mBody.appendChild(figure);
392
393 EmbedExtractor extractor = new ImageExtractor();
394 WebImage result = (WebImage) extractor.extract(figure);
395 String got = result.generateOutput(false);
396 String expected =
397 "<figure>" +
398 "<img src=\"http://wwww.someimage.com/image.jpeg\"" +
399 " width=\"100\" height=\"100\">" +
400 "</figure>";
401 assertNotNull(result);
402 assertEquals(100, result.getHeight());
403 assertEquals(100, result.getWidth());
404 assertEquals(expected, got);
405 }
406
407 public void testFigureWithCaption() {
wychen 2016/05/31 21:28:04 Add one more test without <img>?
marcelorcorrea 2016/05/31 21:46:44 Done.
408 ImageElement image = TestUtil.createImage();
409 image.setSrc("http://wwww.someimage.com/image.jpeg");
410 image.setAttribute("width", "100");
411 image.setAttribute("height", "100");
412 Element figure = Document.get().createElement("FIGURE");
413 figure.appendChild(image);
414 Element figcaption = Document.get().createElement("FIGCAPTION");
415 figcaption.setInnerHTML("This is a caption");
416 figure.appendChild(figcaption);
417 mBody.appendChild(figure);
418
419 EmbedExtractor extractor = new ImageExtractor();
420 WebImage result = (WebImage) extractor.extract(figure);
421 String got = result.generateOutput(false);
422 String expected =
423 "<figure>" +
424 "<img src=\"http://wwww.someimage.com/image.jpeg\"" +
425 " width=\"100\" height=\"100\">" +
426 "<figcaption>This is a caption</figcaption>" +
427 "</figure>";
428 assertNotNull(result);
429 assertEquals(100, result.getHeight());
430 assertEquals(100, result.getWidth());
431 assertEquals(expected, got);
432 }
383 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698