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: package org.netbeans.jemmy.operators;
045:
046: import java.awt.Frame;
047:
048: import java.awt.TextArea;
049:
050: import junit.framework.Test;
051:
052: import junit.framework.TestCase;
053:
054: import junit.framework.TestSuite;
055:
056: import org.netbeans.jemmy.util.NameComponentChooser;
057:
058: /**
059:
060: * A JUnit test for TextAreaOperator.
061:
062: *
063:
064: * @author Manfred Riem (mriem@netbeans.org)
065:
066: * @version $Revision$
067:
068: */
069:
070: public class TextAreaOperatorTest extends TestCase {
071:
072: /**
073:
074: * Stores the frame.
075:
076: */
077:
078: private Frame frame;
079:
080: /**
081:
082: * Stores the text area.
083:
084: */
085:
086: private TextArea textArea;
087:
088: /**
089:
090: * Constructor.
091:
092: *
093:
094: * @param testName the name of the test.
095:
096: */
097:
098: public TextAreaOperatorTest(String testName) {
099:
100: super (testName);
101:
102: }
103:
104: /**
105:
106: * Setup before testing.
107:
108: *
109:
110: * @throws Exception when a major error occurs.
111:
112: */
113:
114: protected void setUp() throws Exception {
115:
116: frame = new Frame();
117:
118: textArea = new TextArea();
119:
120: textArea.setName("TextAreaOperatorTest");
121:
122: textArea.setText("TextAreaOperatorTest");
123:
124: frame.add(textArea);
125:
126: frame.setSize(400, 300);
127:
128: frame.setLocationRelativeTo(null);
129:
130: }
131:
132: /**
133:
134: * Cleanup after testing.
135:
136: *
137:
138: * @throws Exception when a major error occurs.
139:
140: */
141:
142: protected void tearDown() throws Exception {
143:
144: frame.setVisible(false);
145:
146: frame.dispose();
147:
148: frame = null;
149:
150: }
151:
152: /**
153:
154: * Suite method.
155:
156: */
157:
158: public static Test suite() {
159:
160: TestSuite suite = new TestSuite(TextAreaOperatorTest.class);
161:
162: return suite;
163:
164: }
165:
166: /**
167:
168: * Test constructor.
169:
170: */
171:
172: public void testConstructor() {
173:
174: frame.setVisible(true);
175:
176: FrameOperator operator = new FrameOperator();
177:
178: assertNotNull(operator);
179:
180: TextAreaOperator operator1 = new TextAreaOperator(operator);
181:
182: assertNotNull(operator1);
183:
184: TextAreaOperator operator2 = new TextAreaOperator(operator,
185: "TextAreaOperatorTest");
186:
187: assertNotNull(operator2);
188:
189: TextAreaOperator operator3 = new TextAreaOperator(operator,
190: new NameComponentChooser("TextAreaOperatorTest"));
191:
192: assertNotNull(operator3);
193:
194: }
195:
196: /**
197:
198: * Test findTextArea method.
199:
200: */
201:
202: public void testFindTextArea() {
203:
204: frame.setVisible(true);
205:
206: TextArea textArea1 = TextAreaOperator.findTextArea(frame,
207: "TextAreaOperatorTest", false, false);
208:
209: assertNotNull(textArea1);
210:
211: TextArea textArea2 = TextAreaOperator.findTextArea(frame,
212: new NameComponentChooser("TextAreaOperatorTest"));
213:
214: assertNotNull(textArea2);
215:
216: }
217:
218: /**
219:
220: * Test waitTextArea method.
221:
222: */
223:
224: public void testWaitTextArea() {
225:
226: frame.setVisible(true);
227:
228: TextArea textArea1 = TextAreaOperator.waitTextArea(frame,
229: "TextAreaOperatorTest", false, false);
230:
231: assertNotNull(textArea1);
232:
233: TextArea textArea2 = TextAreaOperator.waitTextArea(frame,
234: new NameComponentChooser("TextAreaOperatorTest"));
235:
236: assertNotNull(textArea2);
237:
238: }
239:
240: /**
241:
242: * Test getDump method.
243:
244: */
245:
246: public void testGetDump() {
247:
248: frame.setVisible(true);
249:
250: FrameOperator operator = new FrameOperator();
251:
252: assertNotNull(operator);
253:
254: TextAreaOperator operator1 = new TextAreaOperator(operator);
255:
256: assertNotNull(operator1);
257:
258: operator1.getDump();
259:
260: }
261:
262: /**
263:
264: * Test getColumns method.
265:
266: */
267:
268: public void testGetColumns() {
269:
270: frame.setVisible(true);
271:
272: FrameOperator operator = new FrameOperator();
273:
274: assertNotNull(operator);
275:
276: TextAreaOperator operator1 = new TextAreaOperator(operator);
277:
278: assertNotNull(operator1);
279:
280: operator1.getColumns();
281:
282: }
283:
284: /**
285:
286: * Test getMinimumSize method.
287:
288: */
289:
290: public void testGetMinimumSize() {
291:
292: frame.setVisible(true);
293:
294: FrameOperator operator = new FrameOperator();
295:
296: assertNotNull(operator);
297:
298: TextAreaOperator operator1 = new TextAreaOperator(operator);
299:
300: assertNotNull(operator1);
301:
302: operator1.getMinimumSize(0, 0);
303:
304: }
305:
306: /**
307:
308: * Test getPreferredSize method.
309:
310: */
311:
312: public void testGetPreferredSize() {
313:
314: frame.setVisible(true);
315:
316: FrameOperator operator = new FrameOperator();
317:
318: assertNotNull(operator);
319:
320: TextAreaOperator operator1 = new TextAreaOperator(operator);
321:
322: assertNotNull(operator1);
323:
324: operator1.getPreferredSize(0, 0);
325:
326: }
327:
328: /**
329:
330: * Test getRows method.
331:
332: */
333:
334: public void testGetRows() {
335:
336: frame.setVisible(true);
337:
338: FrameOperator operator = new FrameOperator();
339:
340: assertNotNull(operator);
341:
342: TextAreaOperator operator1 = new TextAreaOperator(operator);
343:
344: assertNotNull(operator1);
345:
346: operator1.getRows();
347:
348: }
349:
350: /**
351:
352: * Test getScrollbarVisibility method.
353:
354: */
355:
356: public void testGetScrollbarVisibility() {
357:
358: frame.setVisible(true);
359:
360: FrameOperator operator = new FrameOperator();
361:
362: assertNotNull(operator);
363:
364: TextAreaOperator operator1 = new TextAreaOperator(operator);
365:
366: assertNotNull(operator1);
367:
368: operator1.getScrollbarVisibility();
369:
370: }
371:
372: /**
373:
374: * Test replaceRange method.
375:
376: */
377:
378: public void testReplaceRange() {
379:
380: frame.setVisible(true);
381:
382: FrameOperator operator = new FrameOperator();
383:
384: assertNotNull(operator);
385:
386: TextAreaOperator operator1 = new TextAreaOperator(operator);
387:
388: assertNotNull(operator1);
389:
390: operator1.replaceRange("Text", 0, 4);
391:
392: }
393:
394: /**
395:
396: * Test setColumns method.
397:
398: */
399:
400: public void testSetColumns() {
401:
402: frame.setVisible(true);
403:
404: FrameOperator operator = new FrameOperator();
405:
406: assertNotNull(operator);
407:
408: TextAreaOperator operator1 = new TextAreaOperator(operator);
409:
410: assertNotNull(operator1);
411:
412: operator1.setColumns(2);
413:
414: }
415:
416: /**
417:
418: * Test setRows method.
419:
420: */
421:
422: public void testSetRows() {
423:
424: frame.setVisible(true);
425:
426: FrameOperator operator = new FrameOperator();
427:
428: assertNotNull(operator);
429:
430: TextAreaOperator operator1 = new TextAreaOperator(operator);
431:
432: assertNotNull(operator1);
433:
434: operator1.setRows(2);
435:
436: }
437:
438: }
|