001: /*
002: * $Id$
003: *
004: * ----------------------------------------------------------------------------
005: *
006: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
007: *
008: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
009: *
010: * The contents of this file are subject to the terms of either the GNU
011: * General Public License Version 2 only ("GPL") or the Common
012: * Development and Distribution License("CDDL") (collectively, the
013: * "License"). You may not use this file except in compliance with the
014: * License. You can obtain a copy of the License at
015: * http://www.netbeans.org/cddl-gplv2.html
016: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
017: * specific language governing permissions and limitations under the
018: * License. When distributing the software, include this License Header
019: * Notice in each file and include the License file at
020: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
021: * particular file as subject to the "Classpath" exception as provided
022: * by Sun in the GPL Version 2 section of the License file that
023: * accompanied this code. If applicable, add the following below the
024: * License Header, with the fields enclosed by brackets [] replaced by
025: * your own identifying information:
026: * "Portions Copyrighted [year] [name of copyright owner]"
027: *
028: * Contributor(s): Manfred Riem (mriem@netbeans.org).
029: *
030: * The Original Software is the Jemmy library. The Initial Developer of the
031: * Original Software is Alexandre Iline. All Rights Reserved.
032: *
033: * If you wish your version of this file to be governed by only the CDDL
034: * or only the GPL Version 2, indicate your decision by adding
035: * "[Contributor] elects to include this software in this distribution
036: * under the [CDDL or GPL Version 2] license." If you do not indicate a
037: * single choice of license, a recipient has the option to distribute
038: * your version of this file under either the CDDL, the GPL Version 2 or
039: * to extend the choice of license to its licensees as provided above.
040: * However, if you add GPL Version 2 code and therefore, elected the GPL
041: * Version 2 license, then the option applies only if the new code is
042: * made subject to such option by the copyright holder.
043: *
044: * ----------------------------------------------------------------------------
045: *
046: */
047: package org.netbeans.jemmy.accessibility;
048:
049: import javax.swing.JButton;
050: import javax.swing.JFrame;
051: import junit.framework.Test;
052: import junit.framework.TestCase;
053: import junit.framework.TestSuite;
054: import org.netbeans.jemmy.operators.JButtonOperator;
055: import org.netbeans.jemmy.operators.JFrameOperator;
056:
057: /**
058: * A JUnit test for AccessibleNameChooser.
059: *
060: * @author Manfred Riem (mriem@netbeans.org)
061: * @version $Revision$
062: */
063: public class AccessibleNameChooserTest extends TestCase {
064: /**
065: * Stores the frame.
066: */
067: private JFrame frame;
068:
069: /**
070: * Stores the button.
071: */
072: private JButton button;
073:
074: /**
075: * Constructor.
076: *
077: * @param testName the name of the test.
078: */
079: public AccessibleNameChooserTest(String testName) {
080: super (testName);
081: }
082:
083: /**
084: * Setup before testing.
085: *
086: * @throws Exception when a serious error occurs.
087: */
088: protected void setUp() throws Exception {
089: frame = new JFrame();
090: button = new JButton("Button");
091: button.getAccessibleContext().setAccessibleName("Accessible");
092: frame.getContentPane().add(button);
093: frame.setLocationRelativeTo(null);
094: }
095:
096: /**
097: * Cleanup after testing.
098: *
099: * @throws Exception when a serious error occurs.
100: */
101: protected void tearDown() throws Exception {
102: frame.setVisible(false);
103: frame.dispose();
104: frame = null;
105: }
106:
107: /**
108: * Suite method.
109: */
110: public static Test suite() {
111: TestSuite suite = new TestSuite(AccessibleNameChooserTest.class);
112:
113: return suite;
114: }
115:
116: /**
117: * Test checkContext method.
118: */
119: public void testCheckContext() {
120: frame.setVisible(true);
121:
122: JFrameOperator operator = new JFrameOperator();
123: assertNotNull(operator);
124:
125: JButtonOperator operator1 = new JButtonOperator(operator,
126: new AccessibleNameChooser("Accessible"));
127: assertNotNull(operator1);
128: }
129:
130: /**
131: * Test getDescription method.
132: */
133: public void testGetDescription() {
134: assertEquals("JComponent with \"Accessible\" accessible name",
135: new AccessibleNameChooser("Accessible")
136: .getDescription());
137: }
138: }
|