1 29 30 package nextapp.echo2.app.test; 31 32 import junit.framework.TestCase; 33 import nextapp.echo2.app.Color; 34 import nextapp.echo2.app.Extent; 35 import nextapp.echo2.app.IllegalChildException; 36 import nextapp.echo2.app.Label; 37 import nextapp.echo2.app.SplitPane; 38 39 42 public class SplitPaneTest extends TestCase { 43 44 47 public void testEmptyConstructor() { 48 SplitPane splitPane = new SplitPane(); 49 assertNull(splitPane.getSeparatorPosition()); 50 assertFalse(splitPane.isResizable()); 51 } 52 53 56 public void testInput() { 57 SplitPane splitPane = new SplitPane(); 58 splitPane.add(new Label("one label")); 59 splitPane.add(new Label("one more label")); 60 splitPane.setSeparatorPosition(new Extent(80)); 61 splitPane.processInput(SplitPane.PROPERTY_SEPARATOR_POSITION, new Extent(212)); 62 assertEquals(new Extent(212), splitPane.getSeparatorPosition()); 63 } 64 65 68 public void testOverload() { 69 SplitPane splitPane = new SplitPane(); 70 splitPane.add(new Label("one label")); 71 splitPane.add(new Label("one more label")); 72 boolean exceptionThrown = false; 73 try { 74 splitPane.add(new Label("one label too many")); 75 } catch (IllegalChildException ex) { 76 exceptionThrown = true; 77 } 78 assertTrue(exceptionThrown); 79 } 80 81 84 public void testPrimaryConstructor() { 85 SplitPane splitPane; 86 splitPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL, TestConstants.EXTENT_200_PX); 87 assertEquals(SplitPane.ORIENTATION_VERTICAL, splitPane.getOrientation()); 88 assertEquals(TestConstants.EXTENT_200_PX, splitPane.getSeparatorPosition()); 89 90 splitPane = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL, TestConstants.EXTENT_500_PX); 91 assertEquals(SplitPane.ORIENTATION_HORIZONTAL, splitPane.getOrientation()); 92 assertEquals(TestConstants.EXTENT_500_PX, splitPane.getSeparatorPosition()); 93 } 94 95 98 public void testProperties() { 99 SplitPane splitPane = new SplitPane(); 100 splitPane.setOrientation(SplitPane.ORIENTATION_VERTICAL); 101 assertEquals(SplitPane.ORIENTATION_VERTICAL, splitPane.getOrientation()); 102 splitPane.setSeparatorPosition(TestConstants.EXTENT_200_PX); 103 assertEquals(TestConstants.EXTENT_200_PX, splitPane.getSeparatorPosition()); 104 splitPane.setSeparatorHeight(TestConstants.EXTENT_30_PX); 105 assertEquals(TestConstants.EXTENT_30_PX, splitPane.getSeparatorHeight()); 106 splitPane.setSeparatorWidth(TestConstants.EXTENT_100_PX); 107 assertEquals(TestConstants.EXTENT_100_PX, splitPane.getSeparatorWidth()); 108 splitPane.setSeparatorColor(Color.RED); 109 assertEquals(Color.RED, splitPane.getSeparatorColor()); 110 splitPane.setResizable(true); 111 assertEquals(true, splitPane.isResizable()); 112 splitPane.setSeparatorHorizontalImage(TestConstants.BACKGROUND_IMAGE); 113 assertEquals(TestConstants.BACKGROUND_IMAGE, splitPane.getSeparatorHorizontalImage()); 114 splitPane.setSeparatorVerticalImage(TestConstants.BACKGROUND_IMAGE); 115 splitPane.setSeparatorHorizontalImage(null); 116 assertEquals(TestConstants.BACKGROUND_IMAGE, splitPane.getSeparatorVerticalImage()); 117 } 118 } 119 | Popular Tags |