1 // package jalview.ext.archaeopteryx;
3 // import static org.testng.Assert.assertEquals;
4 // import static org.testng.Assert.assertTrue;
6 // import jalview.gui.Desktop;
8 // import org.forester.archaeopteryx.Archaeopteryx;
9 // import org.forester.archaeopteryx.MainFrame;
10 // import org.forester.archaeopteryx.TreePanel;
11 // import org.forester.phylogeny.Phylogeny;
12 // import org.forester.phylogeny.PhylogenyNode;
13 // import org.testng.annotations.BeforeClass;
14 // import org.testng.annotations.Test;
16 // public class AptxPhylogenyTreeTest extends TreeViewTest
18 // final Phylogeny inputTree = new Phylogeny();
20 // final PhylogenyNode rootNode = new PhylogenyNode("root");
22 // final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
24 // final PhylogenyNode ancestor2Node = new PhylogenyNode("leaf 2");
26 // final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
28 // final PhylogenyNode leaf1bNode = new PhylogenyNode("leaf 1b");
30 // final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
34 // TreePanel treePanel;
40 // @BeforeClass(alwaysRun = true)
41 // public void setUpTree()
43 // ancestor1Node.addAsChild(leaf1aNode);
44 // ancestor1Node.addAsChild(leaf1bNode);
45 // ancestor1Node.addAsChild(leaf1cNode);
47 // rootNode.addAsChild(ancestor1Node);
48 // rootNode.addAsChild(ancestor2Node);
50 // leaf1aNode.setDistanceToParent(2);
51 // leaf1bNode.setDistanceToParent(3);
52 // leaf1cNode.setDistanceToParent(4);
54 // ancestor1Node.setDistanceToParent(36);
55 // ancestor2Node.setDistanceToParent(42);
57 // inputTree.setName("test");
58 // inputTree.setRoot(rootNode);
59 // inputTree.setRooted(true);
64 // @BeforeClass(dependsOnMethods = { "setUpJalview", "setUpTree" })
65 // public void createTreeView()
67 // treeView = Archaeopteryx.createApplication(inputTree);
68 // aptx = (MainFrame) treeView; // pretty ugly
69 // treePanel = aptx.getMainPanel().getCurrentTreePanel();
70 // tree = treePanel.getPhylogeny();
72 // Desktop.addInternalFrame(aptx, "Archaeopteryx", 500, 500);
78 // @Test(groups = "Functional")
79 // public void testMainPanelExists()
81 // assertTrue(aptx.getMainPanel() != null);
84 // @Test(groups = "Functional")
85 // public void testTreePanelExists()
87 // assertTrue(treePanel != null);
91 // public void testTreeTitle()
93 // assertTrue(tree.getName().equals("test"));
98 // groups = "Functional",
99 // expectedExceptions = IllegalArgumentException.class)
100 // public void testInvalidBranchName()
102 // tree.getNode("I shouldn't exist");
107 // public void testExistingBranchName()
109 // tree.getNode("leaf 2");
114 // public void testTreeLoaded()
116 // assertTrue(tree != null);
120 // public void testChildNodesCount()
122 // assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
127 // public void testChildToParentBranchLength()
129 // assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
134 // public void testNodeToRootBranchLength()
136 // assertEquals(tree.getNode("leaf 2").getDistanceToParent(), 42.0);
141 // public void testDistantNodeToRootBranchLength()
143 // assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),