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 Sergey Burlak
019: * @version $Revision$
020: */package javax.swing;
021:
022: public class ToolTipManagerTest extends SwingTestCase {
023: ToolTipManager m = ToolTipManager.sharedInstance();
024:
025: public void testSharedInstance() throws Exception {
026: assertNotNull(ToolTipManager.sharedInstance());
027: assertEquals(ToolTipManager.sharedInstance(), ToolTipManager
028: .sharedInstance());
029: }
030:
031: public void testSetGetReshowDelay() throws Exception {
032: assertEquals(500, m.getReshowDelay());
033: m.setReshowDelay(30);
034: assertEquals(30, m.getReshowDelay());
035: m.setReshowDelay(0);
036: assertEquals(0, m.getReshowDelay());
037: try {
038: m.setReshowDelay(-50);
039: fail("illegal argumant exception shall be thrown");
040: } catch (IllegalArgumentException e) {
041: }
042: }
043:
044: public void testSetGetInitialDelay() throws Exception {
045: assertEquals(750, m.getInitialDelay());
046: m.setInitialDelay(30);
047: assertEquals(30, m.getInitialDelay());
048: m.setInitialDelay(0);
049: assertEquals(0, m.getInitialDelay());
050: try {
051: m.setInitialDelay(-50);
052: fail("illegal argumant exception shall be thrown");
053: } catch (IllegalArgumentException e) {
054: }
055: }
056:
057: public void testSetGetDismissDelay() throws Exception {
058: assertEquals(4000, m.getDismissDelay());
059: m.setDismissDelay(30);
060: assertEquals(30, m.getDismissDelay());
061: m.setDismissDelay(0);
062: assertEquals(0, m.getDismissDelay());
063: try {
064: m.setDismissDelay(-50);
065: fail("illegal argumant exception shall be thrown");
066: } catch (IllegalArgumentException e) {
067: }
068: }
069:
070: public void testLightWeightPopupEnabled() throws Exception {
071: assertTrue(m.isLightWeightPopupEnabled());
072: assertTrue(m.lightWeightPopupEnabled);
073: m.setLightWeightPopupEnabled(false);
074: assertFalse(m.isLightWeightPopupEnabled());
075: assertFalse(m.lightWeightPopupEnabled);
076: }
077:
078: public void testHeavyWeightPopupEnabled() throws Exception {
079: assertFalse(m.heavyWeightPopupEnabled);
080: }
081:
082: public void testSetGetEnabled() throws Exception {
083: assertTrue(m.isEnabled());
084: m.setLightWeightPopupEnabled(true);
085: m.setEnabled(false);
086: assertFalse(m.isEnabled());
087: assertTrue(m.isLightWeightPopupEnabled());
088: assertFalse(m.heavyWeightPopupEnabled);
089: }
090:
091: public void testRegisterUnregisterComponent() throws Exception {
092: JPanel panel = new JPanel();
093: m.registerComponent(panel);
094: m.unregisterComponent(panel);
095: testExceptionalCase(new NullPointerCase() {
096: @Override
097: public void exceptionalAction() throws Exception {
098: m.registerComponent(null);
099: }
100: });
101: testExceptionalCase(new NullPointerCase() {
102: @Override
103: public void exceptionalAction() throws Exception {
104: m.unregisterComponent(null);
105: }
106: });
107: }
108: }
|