View Javadoc
1 /* 2 * Scope: a generic MVC framework. 3 * Copyright (c) 2000-2002, Steve Meyfroidt 4 * All rights reserved. 5 * Email: smeyfroi@users.sourceforge.net 6 * 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * Neither the name "Scope" nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 * 36 * 37 * $Id: TestSMenuItem.java,v 1.4 2002/08/05 13:19:26 ludovicc Exp $ 38 */ 39 40 41 package test.view.swing; 42 43 44 import javax.swing.JMenu; 45 import javax.swing.JMenuBar; 46 import junit.framework.TestCase; 47 import org.scopemvc.core.Control; 48 import org.scopemvc.view.swing.SMenuItem; 49 import org.scopemvc.view.swing.SPanel; 50 51 52 /*** 53 * <P> 54 * </P> 55 * 56 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net>;Steve Meyfroidt</A> 57 * @version $Revision: 1.4 $ $Date: 2002/08/05 13:19:26 $ 58 */ 59 public final class TestSMenuItem extends TestCase { 60 61 62 private SMenuItem menuitem; 63 private SwingDummyController controller; 64 65 66 public TestSMenuItem(String inName) { 67 super(inName); 68 } 69 70 71 protected void setUp() throws Exception { 72 73 menuitem = new SMenuItem("Test"); 74 75 SPanel p = new SPanel() { 76 public JMenuBar getMenuBar() { 77 JMenuBar menubar = new JMenuBar(); 78 JMenu menu = new JMenu(); 79 menu.add(menuitem); 80 menubar.add(menu); 81 return menubar; 82 } 83 }; 84 menuitem.setOwner(p); 85 controller = new SwingDummyController(); 86 controller.setView(p); 87 88 controller.startup(); 89 } 90 91 92 protected void tearDown() { 93 controller.shutdown(); 94 } 95 96 97 public void testNoControl() throws Exception { 98 menuitem.setControlID(null); 99 menuitem.doClick(); 100 SuiteViewSwing.waitForAWT(); 101 assertNull(controller.lastControl); 102 } 103 104 105 public void testControl() throws Exception { 106 assertEquals("Test", menuitem.getText()); 107 menuitem.doClick(); 108 SuiteViewSwing.waitForAWT(); 109 assertEquals(new Control("Test"), controller.lastControl); 110 } 111 112 public void testOwner() throws Exception { 113 assertTrue(menuitem.isEnabled()); 114 menuitem.doClick(); 115 SuiteViewSwing.waitForAWT(); 116 assertNotNull(controller.lastControl); 117 } 118 119 public void testNoOwner() throws Exception { 120 menuitem.setOwner(null); 121 assertTrue(!menuitem.isEnabled()); 122 menuitem.doClick(); 123 SuiteViewSwing.waitForAWT(); 124 assertNull(controller.lastControl); 125 } 126 } 127

This page was automatically generated by Maven