1 42 43 package org.jfree.chart.title.junit; 44 45 import junit.framework.Test; 46 import junit.framework.TestCase; 47 import junit.framework.TestSuite; 48 49 import org.jfree.chart.JFreeChart; 50 import org.jfree.chart.title.ImageTitle; 51 52 55 public class ImageTitleTests extends TestCase { 56 57 62 public static Test suite() { 63 return new TestSuite(ImageTitleTests.class); 64 } 65 66 71 public ImageTitleTests(String name) { 72 super(name); 73 } 74 75 78 public void testEquals() { 79 ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); 80 ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); 81 assertEquals(t1, t2); 82 } 83 84 87 public void testHashcode() { 88 ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); 89 ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); 90 assertTrue(t1.equals(t2)); 91 int h1 = t1.hashCode(); 92 int h2 = t2.hashCode(); 93 assertEquals(h1, h2); 94 } 95 96 99 public void testCloning() { 100 ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); 101 ImageTitle t2 = null; 102 try { 103 t2 = (ImageTitle) t1.clone(); 104 } 105 catch (CloneNotSupportedException e) { 106 System.err.println("ImageTitleTests.testCloning: failed to clone."); 107 } 108 assertTrue(t1 != t2); 109 assertTrue(t1.getClass() == t2.getClass()); 110 assertTrue(t1.equals(t2)); 111 } 112 113 116 public void testSerialization() { 117 118 120 } 121 122 private static final double EPSILON = 0.00000001; 123 124 127 public void testWidthAndHeight() { 128 ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); 129 assertEquals(100, t1.getWidth(), EPSILON); 130 assertEquals(100, t1.getHeight(), EPSILON); 131 } 132 133 } 134 | Popular Tags |