1 29 30 package nextapp.echo2.app.test; 31 32 import nextapp.echo2.app.Extent; 33 import nextapp.echo2.app.Insets; 34 import junit.framework.TestCase; 35 36 40 public class InsetsTest extends TestCase { 41 42 private static final Extent PX_1 = new Extent(1, Extent.PX); 43 private static final Extent PX_2 = new Extent(2, Extent.PX); 44 private static final Extent PX_3 = new Extent(3, Extent.PX); 45 private static final Extent PX_4 = new Extent(4, Extent.PX); 46 47 50 public void testConstructorEqual() { 51 Insets insets = new Insets(PX_1); 52 assertEquals(insets.getLeft(), PX_1); 53 assertEquals(insets.getTop(), PX_1); 54 assertEquals(insets.getRight(), PX_1); 55 assertEquals(insets.getBottom(), PX_1); 56 } 57 58 61 public void testConstructorHV() { 62 Insets insets = new Insets(PX_1, PX_2); 63 assertEquals(insets.getLeft(), PX_1); 64 assertEquals(insets.getTop(), PX_2); 65 assertEquals(insets.getRight(), PX_1); 66 assertEquals(insets.getBottom(), PX_2); 67 } 68 69 72 public void testConstructorSpecific() { 73 Insets insets = new Insets(PX_1, PX_2, PX_3, PX_4); 74 assertEquals(insets.getLeft(), PX_1); 75 assertEquals(insets.getTop(), PX_2); 76 assertEquals(insets.getRight(), PX_3); 77 assertEquals(insets.getBottom(), PX_4); 78 } 79 80 83 public void testConstructorPixelEqual() { 84 Insets insets = new Insets(1); 85 assertEquals(insets.getLeft(), PX_1); 86 assertEquals(insets.getTop(), PX_1); 87 assertEquals(insets.getRight(), PX_1); 88 assertEquals(insets.getBottom(), PX_1); 89 } 90 91 94 public void testConstructorPixelHV() { 95 Insets insets = new Insets(1, 2); 96 assertEquals(insets.getLeft(), PX_1); 97 assertEquals(insets.getTop(), PX_2); 98 assertEquals(insets.getRight(), PX_1); 99 assertEquals(insets.getBottom(), PX_2); 100 } 101 102 105 public void testConstructorPixelSpecific() { 106 Insets insets = new Insets(1, 2, 3, 4); 107 assertEquals(insets.getLeft(), PX_1); 108 assertEquals(insets.getTop(), PX_2); 109 assertEquals(insets.getRight(), PX_3); 110 assertEquals(insets.getBottom(), PX_4); 111 } 112 113 116 public void testEquals() { 117 assertEquals(new Insets(1), new Insets(1)); 118 assertEquals(new Insets(1, 2), new Insets(1, 2)); 119 assertEquals(new Insets(1, 2, 3, 4), new Insets(1, 2, 3, 4)); 120 assertEquals(new Insets(null, null, null, null), new Insets(null, null, null, null)); 121 assertFalse(new Insets(1, 2, 3, 4).equals(new Insets(1, 2, 3, 5))); 122 assertFalse(new Insets(1, 2, 3, 4).equals(new Insets(1, 2, 5, 4))); 123 assertFalse(new Insets(1, 2, 3, 4).equals(new Insets(1, 5, 3, 4))); 124 assertFalse(new Insets(1, 2, 3, 4).equals(new Insets(5, 2, 3, 4))); 125 assertTrue(new Insets(PX_1, PX_2, PX_3, PX_4).equals(new Insets(PX_1, PX_2, PX_3, PX_4))); 126 assertFalse(new Insets(PX_1, PX_2, PX_3, PX_4).equals(new Insets(null, PX_2, PX_3, PX_4))); 127 assertFalse(new Insets(PX_1, PX_2, PX_3, PX_4).equals(new Insets(PX_1, null, PX_3, PX_4))); 128 assertFalse(new Insets(PX_1, PX_2, PX_3, PX_4).equals(new Insets(PX_1, PX_2, null, PX_4))); 129 assertFalse(new Insets(PX_1, PX_2, PX_3, PX_4).equals(new Insets(PX_1, PX_2, PX_3, null))); 130 assertFalse(new Insets(null, PX_2, PX_3, PX_4).equals(new Insets(PX_1, PX_2, PX_3, PX_4))); 131 assertFalse(new Insets(PX_1, null, PX_3, PX_4).equals(new Insets(PX_1, PX_2, PX_3, PX_4))); 132 assertFalse(new Insets(PX_1, PX_2, null, PX_4).equals(new Insets(PX_1, PX_2, PX_3, PX_4))); 133 assertFalse(new Insets(PX_1, PX_2, PX_3, null).equals(new Insets(PX_1, PX_2, PX_3, PX_4))); 134 } 135 } 136 | Popular Tags |