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.operators;
048:
049: import java.awt.Frame;
050: import junit.framework.Test;
051: import junit.framework.TestCase;
052: import junit.framework.TestSuite;
053: import org.netbeans.jemmy.util.NameComponentChooser;
054:
055: /**
056: * A JUnit test for FrameOperator.
057: *
058: * @author Manfred Riem (mriem@netbeans.org)
059: * @version $Revision$
060: */
061: public class FrameOperatorTest extends TestCase {
062: /**
063: * Stores the frame.
064: */
065: private Frame frame;
066:
067: /**
068: * Constructor.
069: *
070: * @param testName the name of the test.
071: */
072: public FrameOperatorTest(String testName) {
073: super (testName);
074: }
075:
076: /**
077: * Setup before testing.
078: *
079: * @throws Exception when a major problem occurs.
080: */
081: protected void setUp() throws Exception {
082: frame = new Frame();
083: frame.setTitle("FrameOperatorTest");
084: frame.setName("FrameOperatorTest");
085: }
086:
087: /**
088: * Cleanup after testing.
089: *
090: * @throws Exception when a major problem occurs.
091: */
092: protected void tearDown() throws Exception {
093: frame.setVisible(false);
094: frame.dispose();
095: }
096:
097: /**
098: * Suite method.
099: */
100: public static Test suite() {
101: TestSuite suite = new TestSuite(FrameOperatorTest.class);
102:
103: return suite;
104: }
105:
106: /**
107: * Test constructor.
108: */
109: public void testConstructor() {
110: frame.setVisible(true);
111:
112: FrameOperator operator = new FrameOperator();
113: assertNotNull(operator);
114:
115: FrameOperator operator2 = new FrameOperator(
116: new NameComponentChooser("FrameOperatorTest"));
117: assertNotNull(operator2);
118:
119: FrameOperator operator3 = new FrameOperator("FrameOperatorTest");
120: assertNotNull(operator3);
121: }
122:
123: /**
124: * Test waitTitle method.
125: */
126: public void testWaitTitle() {
127: frame.setVisible(true);
128:
129: FrameOperator operator = new FrameOperator();
130: assertNotNull(operator);
131:
132: operator.setTitle("Title");
133: operator.waitTitle("Title");
134: }
135:
136: /**
137: * Test iconify method.
138: */
139: public void testIconify() {
140: frame.setVisible(true);
141:
142: FrameOperator operator = new FrameOperator();
143: assertNotNull(operator);
144:
145: operator.iconify();
146: }
147:
148: /**
149: * Test deiconify method.
150: */
151: public void testDeiconify() {
152: frame.setVisible(true);
153:
154: FrameOperator operator = new FrameOperator();
155: assertNotNull(operator);
156:
157: operator.deiconify();
158: }
159:
160: /**
161: * Test maximize method.
162: */
163: public void testMaximize() {
164: frame.setVisible(true);
165:
166: FrameOperator operator = new FrameOperator();
167: assertNotNull(operator);
168:
169: operator.maximize();
170: }
171:
172: /**
173: * Test demaximize method.
174: */
175: public void testDemaximize() {
176: frame.setVisible(true);
177:
178: FrameOperator operator = new FrameOperator();
179: assertNotNull(operator);
180:
181: operator.demaximize();
182: }
183:
184: /**
185: * Test getDump method.
186: */
187: public void testGetDump() {
188: frame.setVisible(true);
189:
190: FrameOperator operator = new FrameOperator();
191: assertNotNull(operator);
192:
193: operator.getDump();
194: }
195:
196: /**
197: * Test setIconImage method.
198: */
199: public void testSetIconImage() {
200: frame.setVisible(true);
201:
202: FrameOperator operator = new FrameOperator();
203: assertNotNull(operator);
204:
205: operator.setIconImage(operator.getIconImage());
206: }
207:
208: /**
209: * Test setMenuBar method.
210: */
211: public void testSetMenuBar() {
212: frame.setVisible(true);
213:
214: FrameOperator operator = new FrameOperator();
215: assertNotNull(operator);
216:
217: operator.setMenuBar(operator.getMenuBar());
218: }
219:
220: /**
221: * Test setResizable method.
222: */
223: public void testSetResizable() {
224: frame.setVisible(true);
225:
226: FrameOperator operator = new FrameOperator();
227: assertNotNull(operator);
228:
229: operator.setResizable(operator.isResizable());
230: }
231:
232: /**
233: * Test setState method.
234: */
235: public void testSetState() {
236: frame.setVisible(true);
237:
238: FrameOperator operator = new FrameOperator();
239: assertNotNull(operator);
240:
241: operator.setState(operator.getState());
242: }
243:
244: /**
245: * Test setTitle method.
246: */
247: public void testSetTitle() {
248: frame.setVisible(true);
249:
250: FrameOperator operator = new FrameOperator();
251: assertNotNull(operator);
252:
253: operator.setTitle(operator.getTitle());
254: }
255: }
|