1 29 30 package nextapp.echo2.app.test; 31 32 import junit.framework.TestCase; 33 34 import nextapp.echo2.app.Color; 35 import nextapp.echo2.app.ContentPane; 36 import nextapp.echo2.app.IllegalChildException; 37 import nextapp.echo2.app.Label; 38 import nextapp.echo2.app.SplitPane; 39 import nextapp.echo2.app.WindowPane; 40 41 44 public class WindowPaneTest extends TestCase { 45 46 49 public void testInput() { 50 WindowPane windowPane = new WindowPane(); 51 windowPane.add(new Label("a label")); 52 windowPane.setPositionX(TestConstants.EXTENT_100_PX); 53 windowPane.setPositionY(TestConstants.EXTENT_100_PX); 54 windowPane.processInput(WindowPane.PROPERTY_POSITION_X, TestConstants.EXTENT_200_PX); 55 windowPane.processInput(WindowPane.PROPERTY_POSITION_Y, TestConstants.EXTENT_30_PX); 56 assertEquals(TestConstants.EXTENT_200_PX, windowPane.getPositionX()); 57 assertEquals(TestConstants.EXTENT_30_PX, windowPane.getPositionY()); 58 } 59 60 63 public void testInvalidParent() { 64 SplitPane splitPane = new SplitPane(); 65 WindowPane windowPane = new WindowPane(); 66 boolean exceptionThrown = false; 67 try { 68 splitPane.add(windowPane); 69 } catch (IllegalChildException ex) { 70 exceptionThrown = true; 71 } 72 assertTrue(exceptionThrown); 73 } 74 75 78 public void testValidParent() { 79 ContentPane contentPane = new ContentPane(); 80 WindowPane windowPane = new WindowPane(); 81 contentPane.add(windowPane); 82 } 83 84 87 public void testOverload() { 88 WindowPane windowPane = new WindowPane(); 89 windowPane.add(new Label("one label")); 90 boolean exceptionThrown = false; 91 try { 92 windowPane.add(new Label("one label too many")); 93 } catch (IllegalChildException ex) { 94 exceptionThrown = true; 95 } 96 assertTrue(exceptionThrown); 97 } 98 99 102 public void testPrimaryConstructor() { 103 WindowPane windowPane = new WindowPane("Hello", TestConstants.EXTENT_500_PX, TestConstants.EXTENT_200_PX); 104 assertEquals(TestConstants.EXTENT_500_PX, windowPane.getWidth()); 105 assertEquals(TestConstants.EXTENT_200_PX, windowPane.getHeight()); 106 assertEquals("Hello", windowPane.getTitle()); 107 } 108 109 112 public void testProperties() { 113 WindowPane windowPane = new WindowPane(); 114 windowPane.setBorder(TestConstants.FILL_IMAGE_BORDER); 115 assertEquals(TestConstants.FILL_IMAGE_BORDER, windowPane.getBorder()); 116 windowPane.setHeight(TestConstants.EXTENT_200_PX); 117 assertEquals(TestConstants.EXTENT_200_PX, windowPane.getHeight()); 118 windowPane.setPositionX(TestConstants.EXTENT_100_PX); 119 assertEquals(TestConstants.EXTENT_100_PX, windowPane.getPositionX()); 120 windowPane.setPositionY(TestConstants.EXTENT_30_PX); 121 assertEquals(TestConstants.EXTENT_30_PX, windowPane.getPositionY()); 122 windowPane.setTitle("Title!"); 123 assertEquals("Title!", windowPane.getTitle()); 124 windowPane.setTitleBackground(Color.ORANGE); 125 assertEquals(Color.ORANGE, windowPane.getTitleBackground()); 126 windowPane.setTitleFont(TestConstants.MONOSPACE_12); 127 assertEquals(TestConstants.MONOSPACE_12, windowPane.getTitleFont()); 128 windowPane.setTitleForeground(Color.PINK); 129 assertEquals(Color.PINK, windowPane.getTitleForeground()); 130 windowPane.setWidth(TestConstants.EXTENT_500_PX); 131 assertEquals(TestConstants.EXTENT_500_PX, windowPane.getWidth()); 132 windowPane.setClosable(false); 133 assertFalse(windowPane.isClosable()); 134 } 135 } 136 | Popular Tags |