Source Code Cross Referenced for VirtualWindowUTest.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » uicapture » v1 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » GroboUtils » net.sourceforge.groboutils.uicapture.v1 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)VirtualWindowUTest.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 java.awt.Robot;
030:
031:        import net.sourceforge.groboutils.autodoc.v1.AutoDoc;
032:        import junit.framework.Test;
033:        import junit.framework.TestCase;
034:        import junit.framework.TestSuite;
035:
036:        import net.sourceforge.groboutils.uicapture.v1.event.*;
037:        import java.awt.*;
038:        import java.awt.event.*;
039:        import java.util.*;
040:
041:        /**
042:         * Tests the VirtualWindow class.
043:         *
044:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
045:         * @version   $Date: 2003/02/10 22:52:34 $
046:         * @since   Jan 6, 2002
047:         */
048:        public class VirtualWindowUTest extends TestCase {
049:            //-------------------------------------------------------------------------
050:            // Standard JUnit Class-specific declarations
051:
052:            private static final Class THIS_CLASS = VirtualWindowUTest.class;
053:            private static final AutoDoc DOC = new AutoDoc(THIS_CLASS);
054:
055:            public VirtualWindowUTest(String name) {
056:                super (name);
057:            }
058:
059:            private VirtualWindow vw;
060:
061:            public class MyCaptureListener implements  ICaptureListener {
062:                ArrayList mwm = new ArrayList();
063:                ArrayList mm = new ArrayList();
064:                ArrayList mp = new ArrayList();
065:                ArrayList mr = new ArrayList();
066:                ArrayList kp = new ArrayList();
067:                ArrayList kr = new ArrayList();
068:
069:                public void mouseWheelMoved(MouseWheelCaptureEvent ce) {
070:                    mwm.add(ce);
071:                }
072:
073:                public void mouseMoved(MouseMovedCaptureEvent ce) {
074:                    mm.add(ce);
075:                }
076:
077:                public void mousePressed(MousePressedCaptureEvent ce) {
078:                    mp.add(ce);
079:                }
080:
081:                public void mouseReleased(MouseReleasedCaptureEvent ce) {
082:                    mr.add(ce);
083:                }
084:
085:                public void keyPressed(KeyPressedCaptureEvent ce) {
086:                    kp.add(ce);
087:                }
088:
089:                public void keyReleased(KeyReleasedCaptureEvent ce) {
090:                    kr.add(ce);
091:                }
092:            }
093:
094:            //-------------------------------------------------------------------------
095:            // Tests
096:
097:            public void testInstantiation1() {
098:                this .vw = createVirtualWindow();
099:                assertTrue("Default glass pane state is true.", this .vw
100:                        .isGlassEnabled());
101:            }
102:
103:            public void testInstantiation2() {
104:                this .vw = createVirtualWindow(null, true);
105:                assertTrue("Manually set glass pane state to true.", this .vw
106:                        .isGlassEnabled());
107:            }
108:
109:            public void testInstantiation3() {
110:                this .vw = createVirtualWindow(null, false);
111:                assertTrue("Manually set glass pane state to false.", !this .vw
112:                        .isGlassEnabled());
113:            }
114:
115:            public void testMouseWheelMoved1() {
116:                this .vw = createVirtualWindow();
117:                MyCaptureListener mcl1 = createCaptureListener();
118:                MyCaptureListener mcl2 = createCaptureListener();
119:                this .vw.addCaptureListener(mcl1);
120:                this .vw.addCaptureListener(mcl2);
121:
122:                MouseWheelEvent mwe = new MouseWheelEvent(getUIComponent(), 1,
123:                        System.currentTimeMillis(), 0, 0, 0, 2, false,
124:                        MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1);
125:                this .vw.mouseWheelMoved(mwe);
126:
127:                assertEquals("Did not fire a wheel event to listener 1.", 1,
128:                        mcl1.mwm.size());
129:                assertEquals("Did not fire a wheel event to listener 2.", 1,
130:                        mcl2.mwm.size());
131:            }
132:
133:            public void testMouseDragged1() {
134:                this .vw = createVirtualWindow();
135:                MyCaptureListener mcl1 = createCaptureListener();
136:                MyCaptureListener mcl2 = createCaptureListener();
137:                this .vw.addCaptureListener(mcl1);
138:                this .vw.addCaptureListener(mcl2);
139:
140:                MouseEvent me = new MouseEvent(getUIComponent(), 1, System
141:                        .currentTimeMillis(), 0, 0, 0, 0, // click count
142:                        false, 0);
143:                this .vw.mouseDragged(me);
144:            }
145:
146:            public void testMouseMoved1() {
147:                this .vw = createVirtualWindow();
148:                MyCaptureListener mcl1 = createCaptureListener();
149:                MyCaptureListener mcl2 = createCaptureListener();
150:                this .vw.addCaptureListener(mcl1);
151:                this .vw.addCaptureListener(mcl2);
152:
153:                MouseEvent me = new MouseEvent(getUIComponent(), 1, System
154:                        .currentTimeMillis(), 0, 0, 0, 0, // click count
155:                        false, 0);
156:                this .vw.mouseMoved(me);
157:
158:                assertEquals("Did not fire a move event to listener 1.", 1,
159:                        mcl1.mm.size());
160:                assertEquals("Did not fire a move event to listener 2.", 1,
161:                        mcl2.mm.size());
162:            }
163:
164:            public void testMousePressed1() {
165:                this .vw = createVirtualWindow();
166:                MyCaptureListener mcl1 = createCaptureListener();
167:                MyCaptureListener mcl2 = createCaptureListener();
168:                this .vw.addCaptureListener(mcl1);
169:                this .vw.addCaptureListener(mcl2);
170:
171:                MouseEvent me = new MouseEvent(getUIComponent(), 1, System
172:                        .currentTimeMillis(), 0, 0, 0, 1, // click count
173:                        false, 0);
174:                this .vw.mousePressed(me);
175:
176:                assertEquals("Did not fire a mouse press event to listener 1.",
177:                        1, mcl1.mp.size());
178:                assertEquals("Did not fire a mouse press event to listener 2.",
179:                        1, mcl2.mp.size());
180:            }
181:
182:            public void testMouseReleased1() {
183:                this .vw = createVirtualWindow();
184:                MyCaptureListener mcl1 = createCaptureListener();
185:                MyCaptureListener mcl2 = createCaptureListener();
186:                this .vw.addCaptureListener(mcl1);
187:                this .vw.addCaptureListener(mcl2);
188:
189:                MouseEvent me = new MouseEvent(getUIComponent(), 1, System
190:                        .currentTimeMillis(), 0, 0, 0, 0, // click count
191:                        false, 0);
192:                this .vw.mouseReleased(me);
193:
194:                assertEquals(
195:                        "Did not fire a mouse release event to listener 1.", 1,
196:                        mcl1.mr.size());
197:                assertEquals(
198:                        "Did not fire a mouse release event to listener 2.", 1,
199:                        mcl2.mr.size());
200:            }
201:
202:            public void testKeyPressed1() {
203:                this .vw = createVirtualWindow();
204:                MyCaptureListener mcl1 = createCaptureListener();
205:                MyCaptureListener mcl2 = createCaptureListener();
206:                this .vw.addCaptureListener(mcl1);
207:                this .vw.addCaptureListener(mcl2);
208:
209:                KeyEvent ke = new KeyEvent(getUIComponent(), 1, System
210:                        .currentTimeMillis(), 0, KeyEvent.VK_A, 'a', 0);
211:                this .vw.keyPressed(ke);
212:
213:                assertEquals("Did not fire a key press event to listener 1.",
214:                        1, mcl1.kp.size());
215:                assertEquals("Did not fire a key press event to listener 2.",
216:                        1, mcl2.kp.size());
217:            }
218:
219:            public void testKeyReleased1() {
220:                this .vw = createVirtualWindow();
221:                MyCaptureListener mcl1 = createCaptureListener();
222:                MyCaptureListener mcl2 = createCaptureListener();
223:                this .vw.addCaptureListener(mcl1);
224:                this .vw.addCaptureListener(mcl2);
225:
226:                KeyEvent ke = new KeyEvent(getUIComponent(), 1, System
227:                        .currentTimeMillis(), 0, KeyEvent.VK_A, 'a', 0);
228:                this .vw.keyReleased(ke);
229:
230:                assertEquals("Did not fire a key release event to listener 1.",
231:                        1, mcl1.kr.size());
232:                assertEquals("Did not fire a key release event to listener 2.",
233:                        1, mcl2.kr.size());
234:            }
235:
236:            //-------------------------------------------------------------------------
237:
238:            protected VirtualWindow createVirtualWindow() {
239:                try {
240:                    return new VirtualWindow();
241:                } catch (java.awt.AWTException ae) {
242:                    fail("JDK implementation does not support low-level Robot "
243:                            + "actions: " + ae);
244:                    // unreachable
245:                    return null;
246:                }
247:            }
248:
249:            protected VirtualWindow createVirtualWindow(String title,
250:                    boolean enable) {
251:                try {
252:                    return new VirtualWindow(title, enable);
253:                } catch (java.awt.AWTException ae) {
254:                    fail("JDK implementation does not support low-level Robot "
255:                            + "actions: " + ae);
256:                    // unreachable
257:                    return null;
258:                }
259:            }
260:
261:            protected Component getUIComponent() {
262:                return this .vw.getWindow();
263:            }
264:
265:            protected MyCaptureListener createCaptureListener() {
266:                return new MyCaptureListener();
267:            }
268:
269:            //-------------------------------------------------------------------------
270:            // Standard JUnit declarations
271:
272:            public static Test suite() {
273:                TestSuite suite = new TestSuite(THIS_CLASS);
274:
275:                return suite;
276:            }
277:
278:            public static void main(String[] args) {
279:                String[] name = { THIS_CLASS.getName() };
280:
281:                // junit.textui.TestRunner.main( name );
282:                // junit.swingui.TestRunner.main( name );
283:
284:                junit.textui.TestRunner.main(name);
285:            }
286:
287:            /**
288:             * 
289:             * @exception Exception thrown under any exceptional condition.
290:             */
291:            protected void setUp() throws Exception {
292:                super .setUp();
293:
294:                // set ourself up
295:            }
296:
297:            /**
298:             * 
299:             * @exception Exception thrown under any exceptional condition.
300:             */
301:            protected synchronized void tearDown() throws Exception {
302:                // tear ourself down
303:                if (this.vw != null) {
304:                    this.vw.dispose();
305:                    this.vw = null;
306:                }
307:
308:                super.tearDown();
309:            }
310:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.