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 MouseWheelEventTest extends TestCase {
27:
28: public final void testMouseWheelEvent() {
29: Button button = new Button("Button");
30: MouseWheelEvent event = new MouseWheelEvent(button,
31: MouseEvent.MOUSE_WHEEL, 1000000000,
32: InputEvent.BUTTON2_DOWN_MASK, 100, 200, 10, true,
33: MouseWheelEvent.WHEEL_UNIT_SCROLL, 2, 3);
34:
35: assertEquals(event.getSource(), button);
36: assertEquals(event.getID(), MouseEvent.MOUSE_WHEEL);
37: assertEquals(event.getScrollAmount(), 2);
38: assertEquals(event.getScrollType(),
39: MouseWheelEvent.WHEEL_UNIT_SCROLL);
40: assertEquals(event.getWheelRotation(), 3);
41: assertEquals(event.getUnitsToScroll(), 3 * 2);
42: }
43:
44: public final void testParamString() {
45: Button button = new Button("Button");
46: MouseWheelEvent event = new MouseWheelEvent(button,
47: MouseEvent.MOUSE_WHEEL, 1000000000,
48: InputEvent.BUTTON2_DOWN_MASK, 100, 200, 10, true,
49: MouseWheelEvent.WHEEL_UNIT_SCROLL, 2, 3);
50:
51: assertEquals(
52: event.paramString(),
53: "MOUSE_WHEEL,(100,200),button=0,modifiers=Button2,extModifiers=Button2,clickCount=10,scrollType=WHEEL_UNIT_SCROLL,scrollAmount=2,wheelRotation=3");
54: event = new MouseWheelEvent(button,
55: MouseEvent.MOUSE_WHEEL + 1024, 1000000000,
56: InputEvent.BUTTON2_DOWN_MASK, 100, 200, 10, true,
57: MouseWheelEvent.WHEEL_UNIT_SCROLL, 2, 3);
58: assertTrue(event.paramString().startsWith("unknown type"));
59: }
60:
61: }
|