--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.TreeBuilder;
+import jalview.bin.Jalview;
+
+import org.forester.archaeopteryx.MainFrame;
+import org.forester.archaeopteryx.TreePanel;
+import org.forester.phylogeny.Phylogeny;
+import org.testng.annotations.BeforeClass;
+
+public class AptxJalviewTreeTest
+{
+ TreeBuilder jalviewTree;
+
+ TreePanel treePanel;
+
+ Phylogeny tree;
+
+ MainFrame aptx;
+
+ Jalview jalview;
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpTree()
+ {
+
+ }
+
+ @BeforeClass(dependsOnMethods = { "setUpTree" })
+ public void setUpJalview()
+ {
+ String[] args = new String[0];
+ Jalview.main(args);
+ aptx = ArchaeopteryxInit.createInstance(jalviewTree);
+
+ treePanel = aptx.getMainPanel().getCurrentTreePanel();
+ tree = treePanel.getPhylogeny();
+ }
+}
package jalview.ext.archaeopteryx;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import jalview.bin.Jalview;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-public class AptxTreeCreationTest
+public class AptxPhylogenyTreeTest
{
- final Phylogeny phy = new Phylogeny();
+ final Phylogeny inputTree = new Phylogeny();
final PhylogenyNode rootNode = new PhylogenyNode("root");
final PhylogenyNode ancestor1Node = new PhylogenyNode("ancestor 1");
- final PhylogenyNode leaf2Node = new PhylogenyNode("leaf 2");
+ final PhylogenyNode ancestor2Node = new PhylogenyNode("ancestor 2");
final PhylogenyNode leaf1aNode = new PhylogenyNode("leaf 1a");
final PhylogenyNode leaf1cNode = new PhylogenyNode("leaf 1c");
- MainFrame aptx;
-
TreePanel treePanel;
+ Phylogeny tree;
+
+ MainFrame aptx;
+
Jalview jalview;
@BeforeClass(alwaysRun = true)
- public void setUpTrees()
+ public void setUpTree()
{
ancestor1Node.addAsChild(leaf1aNode);
ancestor1Node.addAsChild(leaf1bNode);
ancestor1Node.addAsChild(leaf1cNode);
rootNode.addAsChild(ancestor1Node);
- rootNode.addAsChild(leaf2Node);
+ rootNode.addAsChild(ancestor2Node);
leaf1aNode.setDistanceToParent(2);
leaf1bNode.setDistanceToParent(3);
leaf1cNode.setDistanceToParent(4);
ancestor1Node.setDistanceToParent(36);
- leaf2Node.setDistanceToParent(42);
+ ancestor2Node.setDistanceToParent(42);
- phy.setRoot(rootNode);
- phy.setRooted(true);
+ inputTree.setRoot(rootNode);
+ inputTree.setRooted(true);
}
- @BeforeClass(alwaysRun = true)
+ @BeforeClass(dependsOnMethods = { "setUpTree" })
public void setUpJalview()
{
String[] args = new String[0];
Jalview.main(args);
- aptx = ArchaeopteryxInit.createInstance(phy);
+ aptx = ArchaeopteryxInit.createInstance(inputTree);
+
+ treePanel = aptx.getMainPanel().getCurrentTreePanel();
+ tree = treePanel.getPhylogeny();
}
+
@BeforeClass(alwaysRun = true)
public void setUpJvOptionPane()
{
assertTrue(aptx != null);
}
+
@Test(groups = "Functional")
public void testAptxBoundToJalview()
{
}
@Test(groups = "Functional")
- public void testShowingTree()
+ public void testShowingAptx()
{
assertTrue(aptx.isShowing());
}
- // @Test(groups = "Functional")
- // public void testCorrectBranchLengths()
- //
- // {
- // aptx.getMainPanel().getTabbedPane().setSelectedIndex(0); // select the
- // // first
- // // (and only) tree
- // // panel
- // treePanel = aptx.getMainPanel().getCurrentTreePanel();
- //
- // System.out.println(treePanel);
- //
- //
- //
- // }
+ @Test(groups = "Functional")
+ public void testMainPanelExists()
+ {
+ assertTrue(aptx.getMainPanel() != null);
+ }
+
+ @Test(groups = "Functional")
+ public void testTreePanelExists()
+ {
+ assertTrue(aptx.getMainPanel().getCurrentTreePanel() != null);
+ }
+
+ @Test(groups = "Functional")
+ public void testTreeLoaded()
+ {
+ assertTrue(aptx.getMainPanel().getCurrentTreePanel() != null);
+ }
+
+ @Test(groups = "Functional")
+ public void testChildNodesCount()
+ {
+ assertEquals(tree.getNode("ancestor 1").getNumberOfExternalNodes(), 3);
+
+ }
+
+ @Test(groups = "Functional")
+ public void testCorrectLeafToParentBranchLength()
+ {
+ assertEquals(tree.getNode("leaf 1a").getDistanceToParent(), 2.0);
+
+ }
+
+ @Test(groups = "Functional")
+ public void testCorrectAncestorLeafToRootBranchLength()
+ {
+ assertEquals(tree.getNode("ancestor 2").getDistanceToParent(), 42.0);
+
+ }
+
+ @Test(groups = "Functional")
+ public void testCorrectLeafToRootBranchLength()
+ {
+ assertEquals(tree.getNode("leaf 1c").calculateDistanceToRoot(),
+ 4.0 + 36.0);
+
+ }
+
+