01: package org.uispec4j;
02:
03: import org.uispec4j.xml.XmlAssert;
04:
05: import javax.swing.AbstractButton;
06: import javax.swing.*;
07:
08: public class ToggleButtonTest extends ButtonTestCase {
09:
10: private JToggleButton jToggleButton = new JToggleButton();
11: private ToggleButton toggle;
12:
13: protected void setUp() throws Exception {
14: super .setUp();
15: toggle = new ToggleButton(jToggleButton);
16: }
17:
18: protected org.uispec4j.AbstractButton getButton() {
19: return toggle;
20: }
21:
22: protected AbstractButton getSwingButton() {
23: return jToggleButton;
24: }
25:
26: public void testGetComponentTypeName() throws Exception {
27: assertEquals("toggleButton", toggle.getDescriptionTypeName());
28: }
29:
30: public void testGetDescription() throws Exception {
31: XmlAssert.assertEquivalent("<toggleButton/>", toggle
32: .getDescription());
33: jToggleButton.setText("toto");
34: XmlAssert.assertEquivalent("<toggleButton label='toto'/>",
35: toggle.getDescription());
36: }
37:
38: public void testFactory() throws Exception {
39: checkFactory(new JToggleButton(), ToggleButton.class);
40: }
41:
42: public void testSelectionThroughClick() throws Exception {
43: jToggleButton.setSelected(false);
44: toggle.click();
45: assertTrue(toggle.isSelected());
46: toggle.click();
47: assertFalse(toggle.isSelected());
48: }
49: }
|