Package org.uispec4j

Source Code of org.uispec4j.NumberSpinner

package org.uispec4j;

import org.uispec4j.assertion.Assertion;
import org.uispec4j.assertion.testlibrairies.AssertAdapter;

import javax.swing.*;

/**
* 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 (!SpinnerNumberModel.class.isInstance(model)) {
      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() {
        AssertAdapter.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() {
        AssertAdapter.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() {
        AssertAdapter.assertEquals(new Integer(expectedStepSize), model.getStepSize());
      }
    };
  }
}
TOP

Related Classes of org.uispec4j.NumberSpinner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.