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 Anton Avtamonov
19: * @version $Revision$
20: */package javax.swing.event;
21:
22: import javax.swing.SwingTestCase;
23:
24: public class ListDataEventTest extends SwingTestCase {
25: private ListDataEvent event;
26:
27: public ListDataEventTest(final String name) {
28: super (name);
29: }
30:
31: @Override
32: protected void tearDown() throws Exception {
33: event = null;
34: }
35:
36: public void testListDataEvent() throws Exception {
37: Object source = new Object();
38: event = new ListDataEvent(source,
39: ListDataEvent.CONTENTS_CHANGED, 0, 0);
40: assertEquals(source, event.getSource());
41: }
42:
43: public void testGetIndex0() throws Exception {
44: event = new ListDataEvent(new Object(),
45: ListDataEvent.CONTENTS_CHANGED, 10, 0);
46: assertEquals(0, event.getIndex0());
47: }
48:
49: public void testGetIndex1() throws Exception {
50: event = new ListDataEvent(new Object(),
51: ListDataEvent.CONTENTS_CHANGED, 10, 5);
52: assertEquals(10, event.getIndex1());
53: }
54:
55: public void testToString() throws Exception {
56: event = new ListDataEvent(new Object(),
57: ListDataEvent.INTERVAL_ADDED, 1, 2);
58: assertTrue(event.toString().indexOf("ListDataEvent") > 0);
59: assertTrue(event.toString().indexOf(
60: "type=" + ListDataEvent.INTERVAL_ADDED) > 0);
61: assertTrue(event.toString().indexOf("index0=1") > 0);
62: assertTrue(event.toString().indexOf("index1=2") > 0);
63: }
64: }
|