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 Dennis Ushakov
19: * @version $Revision$
20: */package javax.swing.colorchooser;
21:
22: import javax.swing.BasicSwingTestCase;
23: import javax.swing.Icon;
24: import javax.swing.JColorChooser;
25:
26: public class AbstractColorChooserPanelTest extends BasicSwingTestCase {
27: AbstractColorChooserPanel panel;
28:
29: @Override
30: public void setUp() throws Exception {
31: panel = new AbstractColorChooserPanel() {
32: private static final long serialVersionUID = 1L;
33:
34: @Override
35: public String getDisplayName() {
36: return "";
37: }
38:
39: @Override
40: public Icon getSmallDisplayIcon() {
41: return null;
42: }
43:
44: @Override
45: public Icon getLargeDisplayIcon() {
46: return null;
47: }
48:
49: @Override
50: public void updateChooser() {
51: }
52:
53: @Override
54: protected void buildChooser() {
55: }
56: };
57: }
58:
59: @Override
60: public void tearDown() throws Exception {
61: panel = null;
62: }
63:
64: public void testAbstractColorChooserPanel() {
65: assertEquals(0, panel.getMnemonic());
66: assertEquals(-1, panel.getDisplayedMnemonicIndex());
67: }
68:
69: public void testInstallUninstallChooserPanel() {
70: testExceptionalCase(new NullPointerCase() {
71: @Override
72: public void exceptionalAction() throws Exception {
73: panel.getColorSelectionModel();
74: }
75: });
76: JColorChooser chooser = new JColorChooser();
77: int oldListenersCount = ((DefaultColorSelectionModel) chooser
78: .getSelectionModel()).getChangeListeners().length;
79: panel.installChooserPanel(chooser);
80: assertSame(chooser.getColor(), panel.getColorFromModel());
81: assertEquals(
82: oldListenersCount + 1,
83: ((DefaultColorSelectionModel) chooser
84: .getSelectionModel()).getChangeListeners().length);
85: panel.uninstallChooserPanel(chooser);
86: assertEquals(
87: oldListenersCount,
88: ((DefaultColorSelectionModel) chooser
89: .getSelectionModel()).getChangeListeners().length);
90: }
91: }
|