1 29 30 package nextapp.echo2.app.test; 31 32 import junit.framework.TestCase; 33 import nextapp.echo2.app.Alignment; 34 import nextapp.echo2.app.IllegalChildException; 35 import nextapp.echo2.app.Label; 36 37 40 public class LabelTest extends TestCase { 41 42 45 public void testDefaults() { 46 Label label = new Label(); 47 assertTrue(label.isLineWrap()); 48 } 49 50 53 public void testIllegalChildren() { 54 Label label = new Label(); 55 boolean exceptionThrown = false; 56 try { 57 label.add(new Label("you can't add children to this component, right?")); 58 } catch (IllegalChildException ex) { 59 exceptionThrown = true; 60 } 61 assertTrue(exceptionThrown); 62 } 63 64 67 public void testProperties() { 68 Label label = new Label(); 69 label.setText("Label"); 70 label.setIcon(TestConstants.ICON); 71 label.setTextAlignment(new Alignment(Alignment.LEFT, Alignment.TOP)); 72 label.setTextPosition(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM)); 73 label.setLineWrap(false); 74 assertEquals("Label", label.getText()); 75 assertEquals(TestConstants.ICON, label.getIcon()); 76 assertEquals(new Alignment(Alignment.LEFT, Alignment.TOP), label.getTextAlignment()); 77 assertEquals(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM), label.getTextPosition()); 78 assertEquals(false, label.isLineWrap()); 79 } 80 } 81 | Popular Tags |