⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 numberspinner.java

📁 基于Junit的 功能和单元测试的的测试工具。只支持Swing.
💻 JAVA
字号:
package org.uispec4j;

import junit.framework.Assert;
import org.uispec4j.assertion.Assertion;

import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

/**
 * Wrapper for JSpinner components implementing a SpinnerNumberModel.
 */
public class NumberSpinner extends Spinner {
  private SpinnerNumberModel model;

  public NumberSpinner(JSpinner jSpinner) {
    super(jSpinner);
    SpinnerModel model = jSpinner.getModel();
    if (!model.getClass().isAssignableFrom(SpinnerNumberModel.class)) {
      throw new ItemNotFoundException("Expected JSpinner using a SpinnerNumberModel");
    }
    this.model = (SpinnerNumberModel) model;
  }

  /**
   * Checks that the list spinner displays starts with the given value
   */
  public Assertion minEquals(final int expectedMin) {
    return new Assertion() {
      public void check() throws Exception {
        Assert.assertEquals(new Integer(expectedMin), model.getMinimum());
      }
    };
  }

  /**
   * Checks that the list spinner displays starts with the given value
   */
  public Assertion maxEquals(final int expectedMax) {
    return new Assertion() {
      public void check() throws Exception {
        Assert.assertEquals(new Integer(expectedMax), model.getMaximum());
      }
    };
  }

  /**
   * Checks that the list spinner computes previous and next value with the given value.
   */
  public Assertion stepSizeEquals(final int expectedStepSize) {
    return new Assertion() {
      public void check() throws Exception {
        Assert.assertEquals(new Integer(expectedStepSize), model.getStepSize());
      }
    };
  }
}

⌨️ 快捷键说明

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