01: package abbot.tester;
02:
03: import javax.swing.*;
04: import junit.extensions.abbot.*;
05:
06: /** Unit test to verify the JSliderTester class.<p> */
07:
08: public class JSliderTesterTest extends ComponentTestFixture {
09:
10: public void testIncrement() {
11: for (int i = 0; i < sliders.length; i++) {
12: int value = sliders[i].getValue();
13: tester.actionIncrement(sliders[i]);
14: assertTrue("Not incremented: " + sliders[i], sliders[i]
15: .getValue() > value);
16: }
17: }
18:
19: public void testDecrement() {
20: for (int i = 0; i < sliders.length; i++) {
21: int value = sliders[i].getValue();
22: tester.actionDecrement(sliders[i]);
23: assertTrue("Not decremented: " + sliders[i], sliders[i]
24: .getValue() < value);
25: }
26: }
27:
28: // FIXME intermittent failure, Linux 1.4.2_04
29: public void testSlide() {
30: int VALUE = 25;
31: for (int i = 0; i < sliders.length; i++) {
32: tester.actionSlide(sliders[i], VALUE);
33: assertEquals("Wrong value on " + sliders[i], VALUE,
34: sliders[i].getValue());
35: }
36: }
37:
38: public void testSlideMaximum() {
39: for (int i = 0; i < sliders.length; i++) {
40: int VALUE = sliders[i].getMaximum();
41: tester.actionSlideMaximum(sliders[i]);
42: assertEquals("Wrong value on " + sliders[i], VALUE,
43: sliders[i].getValue());
44: }
45: }
46:
47: public void testSlideMinimum() {
48: for (int i = 0; i < sliders.length; i++) {
49: int VALUE = sliders[i].getMinimum();
50: tester.actionSlideMinimum(sliders[i]);
51: assertEquals("Wrong value on " + sliders[i], VALUE,
52: sliders[i].getValue());
53: }
54: }
55:
56: /** Create a new test case with the given name. */
57: public JSliderTesterTest(String name) {
58: super (name);
59: }
60:
61: private JSliderTester tester;
62: private JSlider[] sliders;
63:
64: protected void setUp() {
65: tester = (JSliderTester) ComponentTester
66: .getTester(JSlider.class);
67: sliders = new JSlider[4];
68: sliders[0] = new JSlider();
69: sliders[1] = new JSlider();
70: sliders[1].setInverted(true);
71: sliders[2] = new JSlider(JSlider.VERTICAL);
72: sliders[3] = new JSlider(JSlider.VERTICAL);
73: sliders[3].setInverted(true);
74: JPanel p = new JPanel();
75: p.add(sliders[0]);
76: p.add(sliders[1]);
77: p.add(sliders[2]);
78: p.add(sliders[3]);
79: showFrame(p);
80: }
81:
82: public static void main(String[] args) {
83: RepeatHelper.runTests(args, JSliderTesterTest.class);
84: }
85: }
|