01: package abbot.tester;
02:
03: import javax.swing.*;
04:
05: import junit.extensions.abbot.*;
06:
07: /** Unit test to verify the JSplitPaneTester class.<p> */
08:
09: public class JSplitPaneTesterTest extends ComponentTestFixture {
10:
11: private JSplitPaneTester tester;
12: private JSplitPane h, v;
13:
14: protected void setUp() {
15: tester = new JSplitPaneTester();
16: h = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
17: h.add(new JTree());
18: h.add(new JTree());
19: v = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
20: v.add(new JTree());
21: v.add(new JTree());
22: JPanel p = new JPanel();
23: p.add(h);
24: p.add(v);
25: showFrame(p);
26: }
27:
28: public void testMoveDividerVerticalMax() {
29: tester.actionMoveDivider(h, 1.0);
30: assertEquals(
31: "Vertical divider should be moved to max position", h
32: .getMaximumDividerLocation(), h
33: .getDividerLocation());
34: }
35:
36: public void testMoveDividerHorizontalMax() {
37: tester.actionMoveDivider(v, 1.0);
38: assertEquals(
39: "Horizontal divider should be moved to max position", v
40: .getMaximumDividerLocation(), v
41: .getDividerLocation());
42: }
43:
44: public void testMoveDividerVerticalCenter() {
45: tester.actionMoveDivider(h, 0.5);
46: int mid = h.getMaximumDividerLocation() / 2;
47: assertEquals("Vertical divider should be moved to center: "
48: + h.getDividerLocation() + "/"
49: + h.getMaximumDividerLocation(), mid, h
50: .getDividerLocation());
51: }
52:
53: public void testMoveDividerHorizontalCenter() {
54: tester.actionMoveDivider(v, 0.5);
55: int mid = v.getMaximumDividerLocation() / 2;
56: assertEquals("Horizontal divider should be moved to center: "
57: + v.getDividerLocation() + "/"
58: + v.getMaximumDividerLocation(), mid, v
59: .getDividerLocation());
60: }
61:
62: public void testMoveDividerVerticalMin() {
63: tester.actionMoveDivider(h, 1.0);
64: tester.actionMoveDivider(h, 0.0);
65: assertEquals(
66: "Vertical divider should be moved to min position", h
67: .getMinimumDividerLocation(), h
68: .getDividerLocation());
69: }
70:
71: public void testMoveDividerHorizontalMin() {
72: tester.actionMoveDivider(v, 1.0);
73: tester.actionMoveDivider(v, 0.0);
74: assertEquals(
75: "Horizontal divider should be moved to min position", v
76: .getMinimumDividerLocation(), v
77: .getDividerLocation());
78: }
79:
80: public static void main(String[] args) {
81: RepeatHelper.runTests(args, JSplitPaneTesterTest.class);
82: }
83: }
|