treeexpansiontest.java
来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 45 行
JAVA
45 行
package org.uispec4j;
import junit.framework.AssertionFailedError;
import org.uispec4j.utils.AssertionFailureNotDetectedError;
import javax.swing.tree.TreePath;
public class TreeExpansionTest extends TreeTestCase {
public void testExpandAndCollapsePath() throws Exception {
TreePath path = new TreePath(child1Node.getPath());
jTree.expandPath(path);
checkExpanded("child1", true);
jTree.collapsePath(path);
checkExpanded("child1", false);
}
public void testAssertPathExpanded() throws Exception {
tree.expand("child1", true);
checkExpanded("child1", true);
tree.expand("child1", false);
checkExpanded("child1", false);
}
public void testAssertPathExpandedNeedsAValidPath() throws Exception {
try {
tree.expand("unknown", true);
throw new AssertionFailureNotDetectedError();
}
catch (AssertionFailedError e) {
assertEquals(Tree.badTreePath("unknown"), e.getMessage());
}
}
private void checkExpanded(String path, boolean expanded) {
assertEquals(expanded, tree.pathIsExpanded(path));
try {
assertEquals(!expanded, tree.pathIsExpanded(path));
throw new AssertionFailureNotDetectedError();
}
catch (AssertionFailedError e) {
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?