radiobuttontest.java

来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 55 行

JAVA
55
字号
package org.uispec4j;

import org.uispec4j.utils.UIComponentFactory;
import org.uispec4j.xml.XmlAssert;

import javax.swing.*;

public class RadioButtonTest extends ButtonTestCase {
  private RadioButton radioButton;
  private JRadioButton jRadioButton;

  protected void setUp() throws Exception {
    super.setUp();
    jRadioButton = new JRadioButton("myRadioButton");
    radioButton = (RadioButton)UIComponentFactory.createUIComponent(jRadioButton);
  }

  protected AbstractButton getButton() {
    return radioButton;
  }

  protected javax.swing.AbstractButton getSwingButton() {
    return jRadioButton;
  }

  public void testGetComponentTypeName() throws Exception {
    assertEquals("radioButton", radioButton.getDescriptionTypeName());
  }

  public void testGetDescription() throws Exception {
    XmlAssert.assertEquivalent("<radioButton label='myRadioButton'/>", radioButton.getDescription());
  }

  public void testFactory() throws Exception {
    checkFactory(jRadioButton, RadioButton.class);
  }

  public void testIsActivated() throws Exception {
    assertFalse(radioButton.isSelected());
    jRadioButton.doClick();
    assertTrue(radioButton.isSelected());
    jRadioButton.doClick();
    assertFalse(radioButton.isSelected());
  }

  public void testActivate() throws Exception {
    assertFalse(radioButton.isSelected());
    radioButton.click();
    assertTrue(jRadioButton.isSelected());
    assertTrue(radioButton.isSelected());
    radioButton.click();
    assertFalse(radioButton.isSelected());
    assertFalse(jRadioButton.isSelected());
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?