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.ItemSelectable;
23:
24: import junit.framework.TestCase;
25:
26: public class ItemEventTest extends TestCase {
27:
28: ItemSelectable item = new ItemSelectable() {
29: public void addItemListener(ItemListener a0) {
30: }
31:
32: public Object[] getSelectedObjects() {
33: return null;
34: }
35:
36: public void removeItemListener(ItemListener a0) {
37: }
38: };
39:
40: public final void testItemEvent() {
41: ItemEvent event = new ItemEvent(item,
42: ItemEvent.ITEM_STATE_CHANGED, item, ItemEvent.SELECTED);
43:
44: assertEquals(event.getSource(), item);
45: assertEquals(event.getID(), ItemEvent.ITEM_STATE_CHANGED);
46: assertEquals(event.getItem(), item);
47: assertEquals(event.getStateChange(), ItemEvent.SELECTED);
48: assertEquals(event.getItemSelectable(), item);
49: }
50:
51: public final void testParamString() {
52: ItemEvent event = new ItemEvent(item,
53: ItemEvent.ITEM_STATE_CHANGED, item, ItemEvent.SELECTED);
54:
55: assertTrue(event.paramString().startsWith(
56: "ITEM_STATE_CHANGED,item=java.awt.event.ItemEventTest"));
57: assertTrue(event.paramString()
58: .endsWith(",stateChange=SELECTED"));
59:
60: event = new ItemEvent(item,
61: ItemEvent.ITEM_STATE_CHANGED + 1024, item,
62: ItemEvent.SELECTED + 1024);
63: assertTrue(event.paramString().startsWith(
64: "unknown type,item=java.awt.event.ItemEventTest"));
65: assertTrue(event.paramString().endsWith(
66: ",stateChange=unknown type"));
67: }
68:
69: }
|