01: package abbot.tester;
02:
03: import javax.swing.*;
04:
05: import junit.extensions.abbot.*;
06:
07: /** Unit test to verify the JScrollBarTester class.<p> */
08:
09: public class JScrollBarTesterTest extends ComponentTestFixture {
10:
11: private JScrollBarTester tester;
12: private JScrollBar h, v;
13:
14: protected void setUp() {
15: tester = new JScrollBarTester();
16: h = new JScrollBar(JScrollBar.HORIZONTAL);
17: v = new JScrollBar(JScrollBar.VERTICAL);
18: JPanel p = new JPanel();
19: p.add(h);
20: p.add(v);
21: showFrame(p);
22: }
23:
24: public void testScrollUnit() {
25: int value = h.getValue();
26: tester.actionScrollUnitUp(h);
27: assertEquals("Value not incremented", value
28: + h.getUnitIncrement(), h.getValue());
29: tester.actionScrollUnitDown(h);
30: assertEquals("Value not decremented", value, h.getValue());
31:
32: tester.actionScrollUnitUp(v);
33: assertEquals("Value not incremented", value
34: + v.getUnitIncrement(), v.getValue());
35: tester.actionScrollUnitDown(v);
36: assertEquals("Value not decremented", value, v.getValue());
37: }
38:
39: public void testScrollBlock() {
40: int value = h.getValue();
41: tester.actionScrollBlockUp(h);
42: assertEquals("Value not incremented", value
43: + h.getBlockIncrement(), h.getValue());
44: tester.actionScrollBlockDown(h);
45: assertEquals("Value not decremented", value, h.getValue());
46:
47: tester.actionScrollBlockUp(v);
48: assertEquals("Value not incremented", value
49: + v.getBlockIncrement(), v.getValue());
50: tester.actionScrollBlockDown(v);
51: assertEquals("Value not decremented", value, v.getValue());
52: }
53:
54: public void testSetPosition() {
55: int min = h.getMinimum();
56: int max = h.getMaximum();
57: int where = min + 3 * (max - min) / 4;
58: tester.actionScrollTo(h, where);
59: assertEquals("horizontal setPosition(" + where + ") failed",
60: where, h.getValue());
61: tester.actionScrollTo(v, where);
62: assertEquals("vertical setPosition(" + where + ") failed",
63: where, v.getValue());
64: }
65:
66: public static void main(String[] args) {
67: RepeatHelper.runTests(args, JScrollBarTesterTest.class);
68: }
69: }
|