Revision: 659
Author: allain.lalonde
Date: Thu Aug 6 11:20:01 2009
Log: Added test for PHtmlViewTest that checks for paint covering the entire
bounds.
http://code.google.com/p/piccolo2d/source/detail?r=659
Modified:
/piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/nodes/PHtmlViewTest.java
=======================================
---
/piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/nodes/PHtmlViewTest.java
Thu Aug 6 10:18:47 2009
+++
/piccolo2d.java/trunk/core/src/test/java/edu/umd/cs/piccolo/nodes/PHtmlViewTest.java
Thu Aug 6 11:20:01 2009
@@ -30,9 +30,16 @@
import java.awt.Color;
import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
import junit.framework.TestCase;
import edu.umd.cs.piccolo.MockPropertyChangeListener;
+import edu.umd.cs.piccolo.PCanvas;
import edu.umd.cs.piccolo.util.PBounds;
/**
@@ -219,4 +226,28 @@
html.setFont(font);
assertSame(font, html.getFont());
}
-}
+
+ public void testPaintFillsBounds() throws IOException {
+ PHtmlView html = new PHtmlView("<html><body>30. Lorem ipsum dolor
sit amet, consectetur adipiscing elit posuere.</body></html>");
+ html.setBounds(0, 0, 400, 30);
+ html.setPaint(Color.RED);
+
+ PCanvas canvas = new PCanvas();
+ canvas.setBackground(Color.WHITE);
+ canvas.setBounds(0, 0, 500, 30);
+ canvas.getLayer().addChild(html);
+
+ BufferedImage image = new BufferedImage(600, 30,
BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2 = image.createGraphics();
+ canvas.paint(g2);
+
+ ImageIO.write(image, "JPEG", new File("C:\\html.jpg"));
+ assertEquals(Color.red.getRGB(), image.getRGB(0, 0));
+ assertEquals(Color.red.getRGB(), image.getRGB(0, 15));
+ assertEquals(Color.red.getRGB(), image.getRGB(0, 29));
+ assertEquals(Color.red.getRGB(), image.getRGB(399, 0));
+ assertEquals(Color.white.getRGB(), image.getRGB(400, 0));
+
+
+ }
+}
--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---