use of org.gwtproject.dom.client.ImageElement in project gwtproject by treblereel.
the class ImageLoadingCellTest method testRenderNegativeIndex.
@Override
public void testRenderNegativeIndex() {
Cell<String> cell = createCell();
String value = createCellValue();
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(-1, -1, null);
cell.render(context, value, sb);
// Render the html.
Element elem = Document.get().createDivElement();
elem.setInnerSafeHtml(sb.toSafeHtml());
// Verify the image.
assertEquals(2, elem.getChildCount());
Element imgWrapper = elem.getChild(1).cast();
ImageElement img = imgWrapper.getFirstChildElement().cast();
assertEquals("img", img.getTagName().toLowerCase(Locale.ROOT));
assertTrue(img.getSrc().toLowerCase(Locale.ROOT).endsWith("test.png"));
}
use of org.gwtproject.dom.client.ImageElement in project gwtproject by treblereel.
the class ImageLoadingCellTest method testRender.
@Override
public void testRender() {
Cell<String> cell = createCell();
String value = createCellValue();
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(0, 0, null);
cell.render(context, value, sb);
// Render the html.
Element elem = Document.get().createDivElement();
elem.setInnerSafeHtml(sb.toSafeHtml());
// Verify the image.
assertEquals(2, elem.getChildCount());
Element imgWrapper = elem.getChild(1).cast();
ImageElement img = imgWrapper.getFirstChildElement().cast();
assertEquals("img", img.getTagName().toLowerCase(Locale.ROOT));
assertTrue(img.getSrc().toLowerCase(Locale.ROOT).endsWith("test.png"));
}
use of org.gwtproject.dom.client.ImageElement in project gwtproject by treblereel.
the class Image method prefetch.
/**
* Causes the browser to pre-fetch the image at a given URL.
*
* @param url the URL of the image to be prefetched
*/
public static void prefetch(String url) {
ImageElement img = Document.get().createImageElement();
img.setSrc(url);
prefetchImages.put(url, img);
}
Aggregations