01: package org.uispec4j;
02:
03: import org.uispec4j.utils.UIComponentFactory;
04: import org.uispec4j.xml.XmlAssert;
05:
06: import javax.swing.*;
07:
08: public class CheckBoxTest extends ButtonTestCase {
09: private CheckBox checkBox;
10: private JCheckBox jCheckBox;
11:
12: protected void setUp() throws Exception {
13: super .setUp();
14: jCheckBox = new JCheckBox();
15: jCheckBox.setName("myCheckBox");
16: this .checkBox = (CheckBox) UIComponentFactory
17: .createUIComponent(jCheckBox);
18: }
19:
20: protected AbstractButton getButton() {
21: return checkBox;
22: }
23:
24: protected javax.swing.AbstractButton getSwingButton() {
25: return jCheckBox;
26: }
27:
28: public void testGetComponentTypeName() throws Exception {
29: assertEquals("checkBox", checkBox.getDescriptionTypeName());
30: }
31:
32: public void testGetDescription() throws Exception {
33: XmlAssert.assertEquivalent("<checkBox name='myCheckBox'/>",
34: checkBox.getDescription());
35: }
36:
37: public void testFactory() throws Exception {
38: checkFactory(new JCheckBox(), CheckBox.class);
39: }
40:
41: public void testSelected() throws Exception {
42: assertFalse(checkBox.isSelected());
43: checkBox.select();
44: assertTrue(checkBox.isSelected());
45: checkBox.select();
46: assertTrue(checkBox.isSelected());
47: checkBox.unselect();
48: assertFalse(checkBox.isSelected());
49: checkBox.unselect();
50: assertFalse(checkBox.isSelected());
51: }
52: }
|