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

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

Issue 2000093005: Support extraction of lazily-loaded images (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: fix comments 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
« no previous file with comments | « javatests/org/chromium/distiller/ContentExtractorTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 private void extractLazilyLoadedImage(String attr) {
385 ImageElement image = TestUtil.createImage();
386 image.setAttribute(attr, "image.png");
387 mBody.appendChild(image);
388
389 mHead.setInnerHTML("<base href=\"http://example.com/\">");
390
391 EmbedExtractor extractor = new ImageExtractor();
392 WebImage result = (WebImage) extractor.extract(image);
393 assertNotNull(result);
394 assertEquals("<img src=\"http://example.com/image.png\">", result.genera teOutput(false));
395 }
396
397 public void testImageExtractorLazy() {
398 extractLazilyLoadedImage("data-src");
399 extractLazilyLoadedImage("datasrc");
400 extractLazilyLoadedImage("data-original");
401 extractLazilyLoadedImage("data-url");
402 }
383 } 403 }
OLDNEW
« no previous file with comments | « javatests/org/chromium/distiller/ContentExtractorTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698