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 Dmitry A. Durnev
019: * @version $Revision$
020: */package java.awt;
021:
022: import junit.framework.TestCase;
023:
024: /**
025: * CheckboxGroupTest
026: */
027: public class CheckboxGroupTest extends TestCase {
028:
029: CheckboxGroup group;
030:
031: @Override
032: protected void setUp() throws Exception {
033: super .setUp();
034: group = new CheckboxGroup();
035: }
036:
037: public final void testCheckboxGroup() {
038: assertNotNull(group);
039: assertNull(group.getSelectedCheckbox());
040: }
041:
042: public final void testGetSelectedCheckbox() {
043: assertNull(group.getSelectedCheckbox());
044: }
045:
046: public final void testSetSelectedCheckbox() {
047: Checkbox checkbox = new Checkbox();
048: group.setSelectedCheckbox(checkbox);
049: assertNull(group.getSelectedCheckbox());
050: checkbox.setCheckboxGroup(group);
051: group.setSelectedCheckbox(checkbox);
052: assertSame(checkbox, group.getSelectedCheckbox());
053:
054: }
055:
056: @SuppressWarnings("deprecation")
057: public final void testGetCurrent() {
058: assertNull(group.getCurrent());
059: }
060:
061: @SuppressWarnings("deprecation")
062: public final void testSetCurrent() {
063: Checkbox cb1 = new Checkbox();
064: Checkbox cb2 = new Checkbox();
065: group.setCurrent(cb1);
066: assertNull(group.getSelectedCheckbox());
067: cb1.setCheckboxGroup(group);
068: assertNull(group.getSelectedCheckbox());
069: cb2.setCheckboxGroup(group);
070: assertNull(group.getSelectedCheckbox());
071: group.setCurrent(cb1);
072: assertSame(cb1, group.getSelectedCheckbox());
073: assertTrue(cb1.getState());
074: group.setCurrent(cb2);
075: assertSame(cb2, group.getSelectedCheckbox());
076: assertTrue(cb2.getState());
077: assertFalse(cb1.getState());
078: group.setCurrent(null);
079: assertNull(group.getSelectedCheckbox());
080:
081: }
082:
083: public final void testMoveCheckBox() {
084: CheckboxGroup group1 = new CheckboxGroup();
085: Checkbox cb = new Checkbox();
086: Checkbox cb1 = new Checkbox();
087: Checkbox cb2 = new Checkbox("", true);
088: cb.setCheckboxGroup(group1);
089: cb1.setCheckboxGroup(group);
090: cb2.setCheckboxGroup(group);
091: assertSame(cb2, group.getSelectedCheckbox());
092: assertNull(group1.getSelectedCheckbox());
093: cb2.setCheckboxGroup(group1);
094: assertSame(cb2, group1.getSelectedCheckbox());
095: assertNull(group.getSelectedCheckbox());
096: cb1.setState(true);
097: assertSame(cb1, group.getSelectedCheckbox());
098: cb1.setCheckboxGroup(group1);
099: assertNull(group.getSelectedCheckbox());
100: assertSame(cb2, group1.getSelectedCheckbox());
101: assertFalse(cb1.getState());
102:
103: }
104:
105: }
|