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 Sergey Burlak
19: * @version $Revision$
20: */package javax.swing;
21:
22: public class JToolTipTest extends SwingTestCase {
23: private JToolTip tooltip;
24:
25: @Override
26: protected void setUp() throws Exception {
27: tooltip = new JToolTip();
28: }
29:
30: @Override
31: protected void tearDown() throws Exception {
32: tooltip = null;
33: }
34:
35: public void testGetUIClassID() throws Exception {
36: assertEquals("ToolTipUI", tooltip.getUIClassID());
37: }
38:
39: public void testGetUI() throws Exception {
40: assertNotNull(tooltip.getUI());
41: assertTrue(tooltip.getUI() == tooltip.getUI());
42: }
43:
44: public void testSetGetTipText() throws Exception {
45: assertNull(tooltip.getTipText());
46: propertyChangeController = new PropertyChangeController();
47: tooltip.addPropertyChangeListener(propertyChangeController);
48: tooltip.setTipText("text");
49: assertTrue(propertyChangeController.isChanged("tiptext"));
50: assertEquals("text", tooltip.getTipText());
51: propertyChangeController.reset();
52: tooltip.setTipText("text");
53: assertFalse(propertyChangeController.isChanged("tiptext"));
54: propertyChangeController.reset();
55: tooltip.setTipText(null);
56: assertTrue(propertyChangeController.isChanged("tiptext"));
57: assertNull(tooltip.getTipText());
58: }
59:
60: public void testSetGetComponent() throws Exception {
61: assertNull(tooltip.getComponent());
62: propertyChangeController = new PropertyChangeController();
63: tooltip.addPropertyChangeListener(propertyChangeController);
64: JButton button = new JButton("b");
65: tooltip.setComponent(button);
66: assertTrue(propertyChangeController.isChanged("component"));
67: assertEquals(button, tooltip.getComponent());
68: propertyChangeController.reset();
69: tooltip.setComponent(button);
70: assertFalse(propertyChangeController.isChanged("component"));
71: propertyChangeController.reset();
72: tooltip.setComponent(null);
73: assertTrue(propertyChangeController.isChanged("component"));
74: assertNull(tooltip.getComponent());
75: }
76: }
|