Merge branch 'Jalview-JS/develop' into merge_js_develop
[jalview.git] / test / jalview / project / Jalview2xmlTests.java
index b72852f..f0fbfc4 100644 (file)
@@ -39,6 +39,7 @@ import javax.swing.JInternalFrame;
 
 import org.testng.Assert;
 import org.testng.AssertJUnit;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -96,6 +97,11 @@ import junit.extensions.PA;
 @Test(singleThreaded = true)
 public class Jalview2xmlTests extends Jalview2xmlBase
 {
+  @AfterMethod(alwaysRun = true)
+  public void tearDown()
+  {
+    Desktop.getInstance().closeAll_actionPerformed(null);
+  }
 
   @Override
   @BeforeClass(alwaysRun = true)
@@ -278,9 +284,9 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
-    assertTrue(Desktop.getAlignFrames().length == 1 + origCount,
+    assertEquals(Desktop.getAlignFrames().length,
+            1 + origCount,
             "Didn't gather the views in the example file.");
-
   }
 
   /**
@@ -412,7 +418,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" }, enabled = true)
   public void testStoreAndRecoverExpandedviews() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
@@ -440,7 +446,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -466,7 +472,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverReferenceSeqSettings() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -505,7 +511,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -599,7 +605,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverGroupRepSeqs() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
     assertNotNull(af, "Didn't read in the example file correctly.");
@@ -674,7 +680,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the expanded view state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -719,7 +725,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverPDBEntry() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     String exampleFile = "examples/3W5V.pdb";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
             DataSourceType.FILE);
@@ -768,7 +774,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     if (Desktop.getAlignFrames() != null)
     {
       Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@@ -819,7 +825,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverColourThresholds() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
 
@@ -882,7 +888,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
             ".jvp");
     tfile.deleteOnExit();
     new Jalview2XML(false).saveState(tfile);
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);
     Assert.assertNotNull(af, "Failed to reload project");
@@ -1077,7 +1083,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverHmmProfile() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
   
@@ -1107,7 +1113,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
             ".jvp");
     tfile.deleteOnExit();
     new Jalview2XML(false).saveState(tfile);
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);
     Assert.assertNotNull(af, "Failed to reload project");
@@ -1144,7 +1150,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testMergeDatasetsforManyViews() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
 
     // complex project - one dataset, several views on several alignments
     AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
@@ -1188,7 +1194,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = "Functional")
   public void testPcaViewAssociation() throws IOException
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     final String PCAVIEWNAME = "With PCA";
     // create a new tempfile
     File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp");
@@ -1222,10 +1228,10 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     }
 
     // load again.
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             tempfile.getCanonicalPath(), DataSourceType.FILE);
-    JInternalFrame[] frames = Desktop.instance.getAllFrames();
+    JInternalFrame[] frames = Desktop.getInstance().getAllFrames();
     // PCA and the tabbed alignment view should be the only two windows on the
     // desktop
     assertEquals(frames.length, 2,
@@ -1255,7 +1261,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
   @Test(groups = { "Functional" })
   public void testStoreAndRecoverGeneLocus() throws Exception
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
     String seqData = ">P30419\nACDE\n>X1235\nGCCTGTGACGAA";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(seqData,
             DataSourceType.PASTE);
@@ -1291,7 +1297,7 @@ public class Jalview2xmlTests extends Jalview2xmlBase
     {
       Assert.fail("Didn't save the state", e);
     }
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   
     new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
             DataSourceType.FILE);