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 Michael Danilov
019: * @version $Revision$
020: */package java.awt.event;
021:
022: import java.awt.Adjustable;
023:
024: import junit.framework.TestCase;
025:
026: public class AdjustmentEventTest extends TestCase {
027:
028: public final void testAdjustmentEventAdjustableintintint() {
029: AdjustmentEvent event = new AdjustmentEvent(adj,
030: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
031: AdjustmentEvent.UNIT_DECREMENT, 10);
032:
033: assertEquals(event.getSource(), adj);
034: assertEquals(event.getID(),
035: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED);
036: assertEquals(event.getAdjustable(), adj);
037: assertEquals(event.getValue(), 10);
038: assertEquals(event.getAdjustmentType(),
039: AdjustmentEvent.UNIT_DECREMENT);
040: assertFalse(event.getValueIsAdjusting());
041: }
042:
043: public final void testAdjustmentEventAdjustableintintintboolean() {
044: AdjustmentEvent event = new AdjustmentEvent(adj,
045: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
046: AdjustmentEvent.BLOCK_DECREMENT, 11, true);
047:
048: assertEquals(event.getSource(), adj);
049: assertEquals(event.getID(),
050: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED);
051: assertEquals(event.getAdjustable(), adj);
052: assertEquals(event.getValue(), 11);
053: assertEquals(event.getAdjustmentType(),
054: AdjustmentEvent.BLOCK_DECREMENT);
055: assertTrue(event.getValueIsAdjusting());
056: }
057:
058: public final void testParamString() {
059: AdjustmentEvent event = new AdjustmentEvent(adj,
060: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
061: AdjustmentEvent.BLOCK_DECREMENT, 11, true);
062:
063: assertEquals(event.paramString(),
064: "ADJUSTMENT_VALUE_CHANGED,adjType=BLOCK_DECREMENT,value=11,isAdjusting=true");
065: event = new AdjustmentEvent(adj,
066: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED - 1,
067: AdjustmentEvent.BLOCK_DECREMENT, 11, true);
068: assertEquals(event.paramString(),
069: "unknown type,adjType=BLOCK_DECREMENT,value=11,isAdjusting=true");
070: event = new AdjustmentEvent(adj,
071: AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
072: AdjustmentEvent.BLOCK_DECREMENT + 1024, 11, true);
073: assertEquals(event.paramString(),
074: "ADJUSTMENT_VALUE_CHANGED,adjType=unknown type,value=11,isAdjusting=true");
075: }
076:
077: static final Adjustable adj = new Adjustable() {
078: public int getValue() {
079: return 0;
080: }
081:
082: public void setValue(int a0) {
083: }
084:
085: public void addAdjustmentListener(AdjustmentListener a0) {
086: }
087:
088: public int getBlockIncrement() {
089: return 0;
090: }
091:
092: public int getMaximum() {
093: return 0;
094: }
095:
096: public int getMinimum() {
097: return 0;
098: }
099:
100: public int getOrientation() {
101: return 0;
102: }
103:
104: public int getUnitIncrement() {
105: return 0;
106: }
107:
108: public int getVisibleAmount() {
109: return 0;
110: }
111:
112: public void removeAdjustmentListener(AdjustmentListener a0) {
113: }
114:
115: public void setBlockIncrement(int a0) {
116: }
117:
118: public void setMaximum(int a0) {
119: }
120:
121: public void setMinimum(int a0) {
122: }
123:
124: public void setUnitIncrement(int a0) {
125: }
126:
127: public void setVisibleAmount(int a0) {
128: }
129: };
130:
131: }
|