01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Michael Danilov
19: * @version $Revision$
20: */package java.awt.event;
21:
22: import java.awt.Button;
23:
24: import junit.framework.TestCase;
25:
26: public class ActionEventTest extends TestCase {
27:
28: public final void testActionEventObjectintString() {
29: Button button = new Button("Button");
30: ActionEvent event = new ActionEvent(button,
31: ActionEvent.ACTION_PERFORMED, "Button");
32:
33: assertEquals(event.getSource(), button);
34: assertEquals(event.getID(), ActionEvent.ACTION_PERFORMED);
35: assertEquals(event.getActionCommand(), "Button");
36: assertEquals(event.getWhen(), 0l);
37: assertEquals(event.getModifiers(), 0);
38: }
39:
40: public final void testActionEventObjectintStringint() {
41: Button button = new Button("Button");
42: ActionEvent event = new ActionEvent(button,
43: ActionEvent.ACTION_PERFORMED, "Button",
44: ActionEvent.CTRL_MASK | ActionEvent.ALT_MASK);
45:
46: assertEquals(event.getSource(), button);
47: assertEquals(event.getID(), ActionEvent.ACTION_PERFORMED);
48: assertEquals(event.getActionCommand(), "Button");
49: assertEquals(event.getWhen(), 0l);
50: assertEquals(event.getModifiers(), ActionEvent.CTRL_MASK
51: | ActionEvent.ALT_MASK);
52: }
53:
54: public final void testActionEventObjectintStringlongint() {
55: Button button = new Button("Button");
56: long when = System.currentTimeMillis();
57: ActionEvent event = new ActionEvent(button,
58: ActionEvent.ACTION_PERFORMED, "Button", when,
59: ActionEvent.CTRL_MASK | ActionEvent.ALT_MASK);
60:
61: assertEquals(event.getSource(), button);
62: assertEquals(event.getID(), ActionEvent.ACTION_PERFORMED);
63: assertEquals(event.getActionCommand(), "Button");
64: assertEquals(event.getWhen(), when);
65: assertEquals(event.getModifiers(), ActionEvent.CTRL_MASK
66: | ActionEvent.ALT_MASK);
67: }
68:
69: public final void testParamString() {
70: Button button = new Button("Button");
71: long when = 1000000000;
72: ActionEvent event = new ActionEvent(button,
73: ActionEvent.ACTION_PERFORMED, "Button", when,
74: ActionEvent.CTRL_MASK | ActionEvent.ALT_MASK);
75:
76: assertEquals(event.paramString(),
77: "ACTION_PERFORMED,cmd=Button,when=1000000000,modifiers=Ctrl+Alt");
78: event = new ActionEvent(button,
79: ActionEvent.ACTION_PERFORMED - 1, "Button", when,
80: ActionEvent.CTRL_MASK | ActionEvent.ALT_MASK);
81: assertEquals(event.paramString(),
82: "unknown type,cmd=Button,when=1000000000,modifiers=Ctrl+Alt");
83: }
84:
85: }
|