Source Code Cross Referenced for EventTest.java in  » Apache-Harmony-Java-SE » java-package » java » awt » 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 » Apache Harmony Java SE » java package » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Dmitry A. Durnev
019:         * @version $Revision$
020:         */package java.awt;
021:
022:        import junit.framework.TestCase;
023:
024:        public class EventTest extends TestCase {
025:
026:            /*
027:             * @see TestCase#setUp()
028:             */
029:            @Override
030:            protected void setUp() throws Exception {
031:                super .setUp();
032:            }
033:
034:            /*
035:             * @see TestCase#tearDown()
036:             */
037:            @Override
038:            protected void tearDown() throws Exception {
039:                super .tearDown();
040:            }
041:
042:            public final void testParamString() {
043:                Button button = new Button("Test paramString()");
044:                int id = Event.GOT_FOCUS;
045:                Event evt = new Event(button, id, null);
046:                assertEquals("id=" + id + ",x=0,y=0,target="
047:                        + evt.target.toString(), evt.paramString());
048:                id = Event.ACTION_EVENT;
049:                Object obj = new Object();
050:                evt = new Event(button, id, obj);
051:                assertEquals("id=" + id + ",x=0,y=0,target=" + button + ",arg="
052:                        + obj, evt.paramString());
053:                id = Event.KEY_PRESS;
054:                evt = new Event(button, 1048576l, id, 0, 0, Event.ENTER,
055:                        Event.CTRL_MASK | Event.META_MASK | Event.SHIFT_MASK);
056:                assertEquals("id=" + id + ",x=0,y=0,key=" + evt.key
057:                        + ",shift,control,meta,target=" + button, evt
058:                        .paramString());
059:            }
060:
061:            /*
062:             * Class under test for void Event(java.lang.Object, int, java.lang.Object)
063:             */
064:            public final void testEventObjectintObject() {
065:                String buttonLabel = "Test Event";
066:                Button button = new Button(buttonLabel);
067:                int id = Event.ACTION_EVENT;
068:                Event evt = new Event(button, id, button.getLabel());
069:                assertSame(button, evt.target);
070:                assertEquals(id, evt.id);
071:                assertSame(buttonLabel, evt.arg);
072:            }
073:
074:            /*
075:             * Class under test for void Event(java.lang.Object, long, int, int, int, int, int)
076:             */
077:            public final void testEventObjectlongintintintintint() {
078:                Button button = new Button("Test constructor");
079:                int id = Event.MOUSE_DOWN;
080:                long when = 16 * 1048576l;
081:                int mod = Event.CTRL_MASK;
082:                Event evt = new Event(button, when, id, 100, 200, Event.ENTER,
083:                        mod);
084:                assertSame(button, evt.target);
085:                assertEquals(id, evt.id);
086:                assertEquals(100, evt.x);
087:                assertEquals(200, evt.y);
088:                assertEquals(mod, evt.modifiers);
089:                assertEquals(when, evt.when);
090:                assertEquals(0, evt.clickCount);
091:            }
092:
093:            /*
094:             * Class under test for void Event(java.lang.Object, long, int, int, int, int, int, java.lang.Object)
095:             */
096:            public final void testEventObjectlongintintintintintObject() {
097:                Button button = new Button("Test constructor");
098:                int id = Event.KEY_ACTION_RELEASE, x = 13, y = 666;
099:                int key = Event.ESCAPE;
100:                long when = 32 * 1048576l;
101:                int mod = Event.SHIFT_MASK | Event.META_MASK;
102:                Object obj = new Object();
103:                Event evt = new Event(button, when, id, x, y, key, mod, obj);
104:                assertSame(button, evt.target);
105:                assertEquals(id, evt.id);
106:                assertEquals(x, evt.x);
107:                assertEquals(y, evt.y);
108:                assertEquals(mod, evt.modifiers);
109:                assertEquals(when, evt.when);
110:                assertSame(obj, evt.arg);
111:            }
112:
113:            public final void testTranslate() {
114:                Button button = new Button("Test translate");
115:                int id = Event.MOUSE_MOVE, x = 20, y = -5;
116:                int key = 0;
117:                long when = 32 * 1048576l;
118:                int mod = 0;
119:                Event evt = new Event(button, when, id, x, y, key, mod);
120:                evt.translate(-20, 15);
121:                assertEquals(0, evt.x);
122:                assertEquals(10, evt.y);
123:            }
124:
125:            public final void testControlDown() {
126:                Button button = new Button("Test control down");
127:                int id = Event.KEY_ACTION, x = 0, y = -10;
128:                int key = Event.DOWN;
129:                long when = 32 * 1048576l;
130:                int mod = 0;
131:                Event evt = new Event(button, when, id, x, y, key, mod);
132:                assertFalse(evt.controlDown());
133:                evt.modifiers |= Event.SHIFT_MASK | Event.ALT_MASK;
134:                assertFalse(evt.controlDown());
135:                evt.modifiers = Event.CTRL_MASK;
136:                assertTrue(evt.controlDown());
137:            }
138:
139:            public final void testMetaDown() {
140:                Button button = new Button("Test META down");
141:                int id = Event.MOUSE_DRAG, x = -20, y = 30;
142:                int key = 0;
143:                long when = 32 * 1048576l;
144:                int mod = 0;
145:                Event evt = new Event(button, when, id, x, y, key, mod);
146:                assertFalse(evt.metaDown());
147:                evt.modifiers |= Event.META_MASK;
148:                assertTrue(evt.metaDown());
149:                evt.modifiers = Event.ALT_MASK;
150:                assertFalse(evt.metaDown());
151:                evt.modifiers |= Event.SHIFT_MASK | Event.CTRL_MASK
152:                        | Event.META_MASK;
153:                assertTrue(evt.metaDown());
154:            }
155:
156:            public final void testShiftDown() {
157:                Button button = new Button("Test shift down");
158:                int id = Event.MOUSE_MOVE, x = 20, y = -30;
159:                int key = 'a';
160:                long when = 32 * 1048576l;
161:                int mod = 0;
162:                Event evt = new Event(button, when, id, x, y, key, mod);
163:                assertFalse(evt.shiftDown());
164:                evt.modifiers |= Event.META_MASK;
165:                assertFalse(evt.shiftDown());
166:                evt.modifiers = Event.SHIFT_MASK;
167:                assertTrue(evt.shiftDown());
168:                evt.modifiers |= Event.CTRL_MASK | Event.ALT_MASK;
169:                assertTrue(evt.shiftDown());
170:            }
171:
172:            public void testDispatchEvent() {
173:                // Regression test for HARMONY-2460
174:                new MenuItem().dispatchEvent(new AWTEventImpl(new Button(), 1));
175:            }
176:
177:            class AWTEventImpl extends AWTEvent {
178:                public AWTEventImpl(Object source, int id) {
179:                    super (source, id);
180:                }
181:            }
182:
183:            public static void main(String[] args) {
184:                junit.textui.TestRunner.run(EventTest.class);
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.