KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > uicapture > v1 > IScriptMakerUTestI


1 /*
2  * @(#)IScriptMakerUTestI.java
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */

26
27 package net.sourceforge.groboutils.uicapture.v1;
28
29 import junit.framework.Test;
30 import junit.framework.TestCase;
31 import junit.framework.TestSuite;
32 import net.sourceforge.groboutils.junit.v1.iftc.*;
33
34 import java.io.*;
35
36
37 /**
38  * Tests the IScriptMaker interface.
39  *
40  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
41  * @version $Date: 2003/02/10 22:52:34 $
42  * @since Oct 3, 2002
43  */

44 public class IScriptMakerUTestI extends InterfaceTestCase
45 {
46     
47     
48     //-------------------------------------------------------------------------
49
// Standard JUnit Class-specific declarations
50

51     private static final Class JavaDoc THIS_CLASS = IScriptMakerUTestI.class;
52     
53     public IScriptMakerUTestI( String JavaDoc name, ImplFactory f )
54     {
55         super( name, IScriptMaker.class, f );
56     }
57
58     
59     //-------------------------------------------------------------------------
60
// setup
61

62     /**
63      *
64      * @exception Exception thrown under any exceptional condition.
65      */

66     protected void setUp() throws Exception JavaDoc
67     {
68         super.setUp();
69         
70         // set ourself up
71
}
72     
73     
74     
75     private IScriptMaker createIScriptMaker()
76     {
77         return (IScriptMaker)createImplObject();
78     }
79     
80     
81     //-------------------------------------------------------------------------
82
// Tests
83

84     
85     public void testStart1()
86     {
87         IScriptMaker ism = createIScriptMaker();
88         ism.start();
89     }
90     
91     
92     public void testStart2()
93     {
94         IScriptMaker ism = createIScriptMaker();
95         ism.start();
96         
97         try
98         {
99             ism.start();
100             fail( "Did not throw IllegalStateException." );
101         }
102         catch (IllegalStateException JavaDoc e)
103         {
104             // test exception?
105
}
106     }
107     
108     
109     public void testStart3()
110     {
111         IScriptMaker ism = createIScriptMaker();
112         ism.start();
113         ism.end();
114         
115         try
116         {
117             ism.start();
118             fail( "Did not throw IllegalStateException." );
119         }
120         catch (IllegalStateException JavaDoc e)
121         {
122             // test exception?
123
}
124     }
125     
126     
127     public void testEnd1()
128     {
129         IScriptMaker ism = createIScriptMaker();
130         ism.start();
131         
132         ism.end();
133     }
134     
135     
136     public void testEnd2()
137     {
138         IScriptMaker ism = createIScriptMaker();
139         try
140         {
141             ism.end();
142             fail( "Did not throw IllegalStateException." );
143         }
144         catch (IllegalStateException JavaDoc e)
145         {
146             // test exception?
147
}
148     }
149     
150     
151     public void testGenerateDelay1()
152     {
153         IScriptMaker ism = createIScriptMaker();
154         ism.start();
155         
156         ism.generateDelay( 100 );
157     }
158     
159     
160     public void testGenerateMoveMouseWheel1()
161     {
162         IScriptMaker ism = createIScriptMaker();
163         ism.start();
164         
165         ism.generateMoveMouseWheel( 10 );
166     }
167     
168     
169     public void testGenerateMoveMouse1()
170     {
171         IScriptMaker ism = createIScriptMaker();
172         ism.start();
173         
174         ism.generateMoveMouse( 10, 20 );
175     }
176     
177     
178     public void testGeneratePressMouse1()
179     {
180         IScriptMaker ism = createIScriptMaker();
181         ism.start();
182         
183         ism.generatePressMouse( 0 );
184     }
185     
186     
187     public void testGenerateReleaseMouse1()
188     {
189         IScriptMaker ism = createIScriptMaker();
190         ism.start();
191         
192         ism.generateReleaseMouse( 0 );
193     }
194     
195     
196     public void testGeneratePressKey1()
197     {
198         IScriptMaker ism = createIScriptMaker();
199         ism.start();
200         
201         ism.generatePressKey( 1 );
202     }
203     
204     
205     public void testGenerateReleaseKey1()
206     {
207         IScriptMaker ism = createIScriptMaker();
208         ism.start();
209         
210         ism.generateReleaseKey( 1 );
211     }
212     
213     
214     public void testGenerateScreenCapture1()
215             throws IOException
216     {
217         IScriptMaker ism = createIScriptMaker();
218         ism.start();
219         
220         File f = new File( "blah" );
221         FileWriter fw = new FileWriter( f );
222         try
223         {
224             fw.write( "blah blah" );
225             fw.flush();
226             fw.close();
227         
228             ism.generateScreenCapture( f, 1, 100, 30, 30 );
229         }
230         finally
231         {
232             f.delete();
233         }
234     }
235     
236     
237     
238     //-------------------------------------------------------------------------
239
// Helpers
240

241     
242         
243     //-------------------------------------------------------------------------
244
// Standard JUnit declarations
245

246     
247     public static InterfaceTestSuite suite()
248     {
249         InterfaceTestSuite suite = new InterfaceTestSuite( THIS_CLASS );
250         
251         return suite;
252     }
253     
254     public static void main( String JavaDoc[] args )
255     {
256         String JavaDoc[] name = { THIS_CLASS.getName() };
257         
258         // junit.textui.TestRunner.main( name );
259
// junit.swingui.TestRunner.main( name );
260

261         junit.textui.TestRunner.main( name );
262     }
263     
264     
265     /**
266      *
267      * @exception Exception thrown under any exceptional condition.
268      */

269     protected void tearDown() throws Exception JavaDoc
270     {
271         // tear ourself down
272

273         
274         super.tearDown();
275     }
276 }
277
278
Popular Tags