01: package org.uispec4j;
02:
03: import junit.framework.AssertionFailedError;
04: import org.uispec4j.utils.AssertionFailureNotDetectedError;
05:
06: import javax.swing.tree.TreePath;
07:
08: public class TreeExpansionTest extends TreeTestCase {
09:
10: public void testExpandAndCollapsePath() throws Exception {
11: TreePath path = new TreePath(child1Node.getPath());
12: jTree.expandPath(path);
13: checkExpanded("child1", true);
14: jTree.collapsePath(path);
15: checkExpanded("child1", false);
16: }
17:
18: public void testAssertPathExpanded() throws Exception {
19: tree.expand("child1", true);
20: checkExpanded("child1", true);
21: tree.expand("child1", false);
22: checkExpanded("child1", false);
23: }
24:
25: public void testAssertPathExpandedNeedsAValidPath()
26: throws Exception {
27: try {
28: tree.expand("unknown", true);
29: throw new AssertionFailureNotDetectedError();
30: } catch (AssertionFailedError e) {
31: assertEquals(Tree.badTreePath("unknown"), e.getMessage());
32: }
33: }
34:
35: private void checkExpanded(String path, boolean expanded) {
36: assertEquals(expanded, tree.pathIsExpanded(path));
37: try {
38: assertEquals(!expanded, tree.pathIsExpanded(path));
39: throw new AssertionFailureNotDetectedError();
40: } catch (AssertionFailedError e) {
41: }
42: }
43: }
|