1 19 20 package org.openide.awt; 21 22 import java.awt.Color ; 23 import java.awt.Font ; 24 import java.awt.Graphics ; 25 import java.awt.image.BufferedImage ; 26 import junit.framework.TestCase; 27 28 32 public class HtmlRendererTest extends TestCase { 33 34 private Graphics graphic; 35 public HtmlRendererTest(String testName) { 36 super(testName); 37 } 38 39 protected void setUp() throws Exception { 40 BufferedImage waitingForPaintDummyImage = new BufferedImage (1, 1, BufferedImage.TYPE_INT_RGB); 41 graphic = waitingForPaintDummyImage.getGraphics(); 42 43 } 44 45 48 public void testRenderHTML() throws Exception { 49 doTestRender("<html>text</html>"); 50 doTestRender("<html>text</html"); 51 doTestRender("<html>text</h"); 52 doTestRender("<html>text</"); 53 doTestRender("<html>text<"); 54 doTestRender("<html>text"); 55 doTestRender("<html>text</html<html/>"); 56 doTestRender("<html>text</h</html>"); 57 doTestRender("<html>text</</html>"); 58 doTestRender("<html>text<</html>"); 59 doTestRender("<html>text<</html>&"); 60 doTestRender55310(); 61 } 62 63 private void doTestRender(String text) { 64 try { 65 HtmlRenderer.renderHTML(text, graphic, 0, 0, 1000, 1000, 66 Font.getFont("Dialog"), Color.RED, HtmlRenderer.STYLE_TRUNCATE, true); 67 } catch (IllegalArgumentException arg) { 68 if (arg.getMessage().startsWith("HTML rendering failed on string")) { 70 System.err.println("throwing illegal argument for " + text); 71 } else { 72 throw arg; 73 } 74 } 75 } 76 77 82 private void doTestRender55310() { 83 doTestRender("<html><b>a </b></html> "); 84 } 85 } 86 | Popular Tags |