01: package org.uispec4j;
02:
03: import javax.swing.JSpinner;
04: import javax.swing.SpinnerListModel;
05: import javax.swing.SpinnerModel;
06: import javax.swing.SpinnerNumberModel;
07:
08: public class NumberSpinnerTest extends SpinnerTestCase {
09: private NumberSpinner numberSpinner;
10:
11: protected void setUp() throws Exception {
12: super .setUp();
13: numberSpinner = (NumberSpinner) spinner;
14: }
15:
16: protected SpinnerModel createSpinnerModel() throws Exception {
17: return new SpinnerNumberModel(10, 0, 20, 2);
18: }
19:
20: protected Spinner createSpinner(JSpinner jSpinner) {
21: return new NumberSpinner(jSpinner);
22: }
23:
24: public void testMinAndMax() throws Exception {
25: assertTrue(numberSpinner.minEquals(0));
26: assertTrue(numberSpinner.maxEquals(20));
27:
28: assertFalse(numberSpinner.minEquals(1));
29: assertFalse(numberSpinner.maxEquals(2));
30: }
31:
32: public void testStepSizeEquals() throws Exception {
33: assertTrue(numberSpinner.stepSizeEquals(2));
34: assertFalse(numberSpinner.stepSizeEquals(3));
35: }
36:
37: public void testUsingNumberSpinnerWithOtherModelThanSpinnerNumberModelThrowsAnException()
38: throws Exception {
39: try {
40: new NumberSpinner(new JSpinner(new SpinnerListModel()));
41: fail();
42: } catch (ItemNotFoundException e) {
43: assertEquals(
44: "Expected JSpinner using a SpinnerNumberModel", e
45: .getMessage());
46: }
47: }
48:
49: }
|