001: /*
002: * @(#)IScriptMakerUTestI.java
003: *
004: * Copyright (C) 2002-2003 Matt Albrecht
005: * groboclown@users.sourceforge.net
006: * http://groboutils.sourceforge.net
007: *
008: * Permission is hereby granted, free of charge, to any person obtaining a
009: * copy of this software and associated documentation files (the "Software"),
010: * to deal in the Software without restriction, including without limitation
011: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
012: * and/or sell copies of the Software, and to permit persons to whom the
013: * Software is furnished to do so, subject to the following conditions:
014: *
015: * The above copyright notice and this permission notice shall be included in
016: * all copies or substantial portions of the Software.
017: *
018: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
021: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024: * DEALINGS IN THE SOFTWARE.
025: */
026:
027: package net.sourceforge.groboutils.uicapture.v1;
028:
029: import junit.framework.Test;
030: import junit.framework.TestCase;
031: import junit.framework.TestSuite;
032: import net.sourceforge.groboutils.junit.v1.iftc.*;
033:
034: import java.io.*;
035:
036: /**
037: * Tests the IScriptMaker interface.
038: *
039: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
040: * @version $Date: 2003/02/10 22:52:34 $
041: * @since Oct 3, 2002
042: */
043: public class IScriptMakerUTestI extends InterfaceTestCase {
044:
045: //-------------------------------------------------------------------------
046: // Standard JUnit Class-specific declarations
047:
048: private static final Class THIS_CLASS = IScriptMakerUTestI.class;
049:
050: public IScriptMakerUTestI(String name, ImplFactory f) {
051: super (name, IScriptMaker.class, f);
052: }
053:
054: //-------------------------------------------------------------------------
055: // setup
056:
057: /**
058: *
059: * @exception Exception thrown under any exceptional condition.
060: */
061: protected void setUp() throws Exception {
062: super .setUp();
063:
064: // set ourself up
065: }
066:
067: private IScriptMaker createIScriptMaker() {
068: return (IScriptMaker) createImplObject();
069: }
070:
071: //-------------------------------------------------------------------------
072: // Tests
073:
074: public void testStart1() {
075: IScriptMaker ism = createIScriptMaker();
076: ism.start();
077: }
078:
079: public void testStart2() {
080: IScriptMaker ism = createIScriptMaker();
081: ism.start();
082:
083: try {
084: ism.start();
085: fail("Did not throw IllegalStateException.");
086: } catch (IllegalStateException e) {
087: // test exception?
088: }
089: }
090:
091: public void testStart3() {
092: IScriptMaker ism = createIScriptMaker();
093: ism.start();
094: ism.end();
095:
096: try {
097: ism.start();
098: fail("Did not throw IllegalStateException.");
099: } catch (IllegalStateException e) {
100: // test exception?
101: }
102: }
103:
104: public void testEnd1() {
105: IScriptMaker ism = createIScriptMaker();
106: ism.start();
107:
108: ism.end();
109: }
110:
111: public void testEnd2() {
112: IScriptMaker ism = createIScriptMaker();
113: try {
114: ism.end();
115: fail("Did not throw IllegalStateException.");
116: } catch (IllegalStateException e) {
117: // test exception?
118: }
119: }
120:
121: public void testGenerateDelay1() {
122: IScriptMaker ism = createIScriptMaker();
123: ism.start();
124:
125: ism.generateDelay(100);
126: }
127:
128: public void testGenerateMoveMouseWheel1() {
129: IScriptMaker ism = createIScriptMaker();
130: ism.start();
131:
132: ism.generateMoveMouseWheel(10);
133: }
134:
135: public void testGenerateMoveMouse1() {
136: IScriptMaker ism = createIScriptMaker();
137: ism.start();
138:
139: ism.generateMoveMouse(10, 20);
140: }
141:
142: public void testGeneratePressMouse1() {
143: IScriptMaker ism = createIScriptMaker();
144: ism.start();
145:
146: ism.generatePressMouse(0);
147: }
148:
149: public void testGenerateReleaseMouse1() {
150: IScriptMaker ism = createIScriptMaker();
151: ism.start();
152:
153: ism.generateReleaseMouse(0);
154: }
155:
156: public void testGeneratePressKey1() {
157: IScriptMaker ism = createIScriptMaker();
158: ism.start();
159:
160: ism.generatePressKey(1);
161: }
162:
163: public void testGenerateReleaseKey1() {
164: IScriptMaker ism = createIScriptMaker();
165: ism.start();
166:
167: ism.generateReleaseKey(1);
168: }
169:
170: public void testGenerateScreenCapture1() throws IOException {
171: IScriptMaker ism = createIScriptMaker();
172: ism.start();
173:
174: File f = new File("blah");
175: FileWriter fw = new FileWriter(f);
176: try {
177: fw.write("blah blah");
178: fw.flush();
179: fw.close();
180:
181: ism.generateScreenCapture(f, 1, 100, 30, 30);
182: } finally {
183: f.delete();
184: }
185: }
186:
187: //-------------------------------------------------------------------------
188: // Helpers
189:
190: //-------------------------------------------------------------------------
191: // Standard JUnit declarations
192:
193: public static InterfaceTestSuite suite() {
194: InterfaceTestSuite suite = new InterfaceTestSuite(THIS_CLASS);
195:
196: return suite;
197: }
198:
199: public static void main(String[] args) {
200: String[] name = { THIS_CLASS.getName() };
201:
202: // junit.textui.TestRunner.main( name );
203: // junit.swingui.TestRunner.main( name );
204:
205: junit.textui.TestRunner.main(name);
206: }
207:
208: /**
209: *
210: * @exception Exception thrown under any exceptional condition.
211: */
212: protected void tearDown() throws Exception {
213: // tear ourself down
214:
215: super.tearDown();
216: }
217: }
|