1 42 43 package org.jfree.junit; 44 45 import java.awt.Color ; 46 import java.awt.GradientPaint ; 47 import java.awt.Paint ; 48 import java.awt.TexturePaint ; 49 import java.awt.geom.Rectangle2D ; 50 import java.awt.image.BufferedImage ; 51 52 import junit.framework.Test; 53 import junit.framework.TestCase; 54 import junit.framework.TestSuite; 55 56 59 public class PaintTests extends TestCase { 60 61 66 public static Test suite() { 67 return new TestSuite(PaintTests.class); 68 } 69 70 75 public PaintTests(final String name) { 76 super(name); 77 } 78 79 82 public void testColorEquals() { 83 final Paint p1 = new Color (0xFF, 0xEE, 0xDD); 84 final Paint p2 = new Color (0xFF, 0xEE, 0xDD); 85 assertEquals(p1, p2); 86 } 87 88 91 public void testColorHashcode() { 92 final Paint p1 = new Color (0xFF, 0xEE, 0xDD); 93 final Paint p2 = new Color (0xFF, 0xEE, 0xDD); 94 assertTrue(p1.equals(p2)); 95 final int h1 = p1.hashCode(); 96 final int h2 = p2.hashCode(); 97 assertEquals(h1, h2); 98 } 99 100 103 public void testGradientPaintEquals() { 104 final Paint p1 = new GradientPaint (10.0f, 20.0f, Color.blue, 30.0f, 40.0f, Color.red); 105 final Paint p2 = new GradientPaint (10.0f, 20.0f, Color.blue, 30.0f, 40.0f, Color.red); 106 assertEquals(p1, p2); 107 } 108 109 112 public void testTexturePaintEquals() { 113 final Paint p1 = new TexturePaint ( 114 new BufferedImage (100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double () 115 ); 116 final Paint p2 = new TexturePaint ( 117 new BufferedImage (100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double () 118 ); 119 assertEquals(p1, p2); 120 } 121 122 } 123 | Popular Tags |