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: TestSLabel.java,v 1.5 2002/08/05 13:19:26 ludovicc Exp $ 38 */ 39 40 41 package test.view.swing; 42 43 44 import junit.framework.TestCase; 45 import org.apache.commons.logging.LogFactory;import org.apache.commons.logging.Log; 46 import org.scopemvc.core.Selector; 47 import org.scopemvc.view.swing.SLabel; 48 import org.scopemvc.view.swing.SPanel; 49 50 51 /*** 52 * <P> 53 * ***** Should test validation state too. 54 * </P> 55 * 56 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net>;Steve Meyfroidt</A> 57 * @version $Revision: 1.5 $ $Date: 2002/08/05 13:19:26 $ 58 */ 59 public final class TestSLabel extends TestCase { 60 61 62 private static final Log LOG = LogFactory.getLog(TestSLabel.class); 63 64 65 private SLabel label; 66 private SwingDummyController controller; 67 private SPanel view; 68 private SwingDummyModel model; 69 70 71 public TestSLabel(String inName) { 72 super(inName); 73 } 74 75 76 protected void setUp() throws Exception { 77 78 label = new SLabel(); 79 80 view = new SPanel(); 81 view.add(label); 82 83 controller = new SwingDummyController(); 84 controller.setView(view); 85 controller.startup(); // does showView() 86 87 model = new SwingDummyModel(); 88 } 89 90 91 protected void tearDown() { 92 controller.shutdown(); 93 } 94 95 96 public void testBind1() throws Exception { 97 label.setSelector(Selector.fromString("stringProperty")); 98 assertEquals(Selector.fromString("stringProperty"), label.getSelector()); 99 100 controller.setModel(model); 101 SuiteViewSwing.waitForAWT(); 102 assertSame(view.getBoundModel(), model); 103 assertSame(label.getBoundModel(), model); 104 assertEquals(model.getStringProperty(), label.getText()); 105 assertTrue(label.isEnabled()); 106 107 int width = label.getSize().width; 108 109 model.setStringProperty("abcdefghijklmnopq"); 110 SuiteViewSwing.waitForAWT(); 111 assertTrue(label.isEnabled()); 112 assertEquals(model.getStringProperty(), label.getText()); 113 assertTrue(label.getSize().width != width); 114 width = label.getSize().width; 115 116 model.setStringProperty("abc"); 117 SuiteViewSwing.waitForAWT(); 118 119 model.setStringProperty(null); 120 SuiteViewSwing.waitForAWT(); 121 assertTrue(label.isEnabled()); 122 assertNull(model.getStringProperty()); 123 assertTrue(label.getSize().width != width); 124 } 125 126 127 public void testConvenience() throws Exception { 128 label.setSelectorString("stringProperty"); 129 assertEquals(Selector.fromString("stringProperty"), label.getSelector()); 130 } 131 }

This page was automatically generated by Maven