1 29 30 package nextapp.echo2.app.test; 31 32 import nextapp.echo2.app.ContentPane; 33 import nextapp.echo2.app.IllegalChildException; 34 import nextapp.echo2.app.Label; 35 import nextapp.echo2.app.Window; 36 import junit.framework.TestCase; 37 38 41 public class WindowTest extends TestCase { 42 43 46 public void testChangeContent() { 47 Window window = new Window(); 48 window.setContent(new ContentPane()); 49 ContentPane content = new ContentPane(); 50 window.setContent(content); 51 assertEquals(content, window.getContent()); 52 } 53 54 58 public void testOverload() { 59 Window window = new Window(); 60 window.removeAll(); 61 window.add(new ContentPane()); 62 boolean exceptionThrown = false; 63 try { 64 window.add(new ContentPane()); 65 } catch (IllegalChildException ex) { 66 exceptionThrown = true; 67 } 68 assertTrue(exceptionThrown); 69 } 70 71 75 public void testInvalidChild() { 76 Window window = new Window(); 77 window.removeAll(); 78 boolean exceptionThrown = false; 79 try { 80 window.add(new Label()); 81 } catch (IllegalChildException ex) { 82 exceptionThrown = true; 83 } 84 assertTrue(exceptionThrown); 85 } 86 87 90 public void testProperties() { 91 Window window = new Window(); 92 window.setTitle("Title!!!"); 93 assertEquals("Title!!!", window.getTitle()); 94 } 95 } 96 | Popular Tags |