JAL-3253 temporary branch SwingJS upgrade with testNG fixes Java 8
[jalview.git] / test / jalview / gui / AlignFrameTest.java
index afb61d0..568d285 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import static org.junit.Assert.assertNotEquals;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotSame;
@@ -38,7 +39,7 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.io.DataSourceType;
 import jalview.io.FileLoader;
-import jalview.io.Jalview2xmlTests;
+import jalview.project.Jalview2xmlTests;
 import jalview.renderer.ResidueShaderI;
 import jalview.schemes.BuriedColourScheme;
 import jalview.schemes.FeatureColour;
@@ -65,6 +66,9 @@ public class AlignFrameTest
   {
     JvOptionPane.setInteractiveMode(false);
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+
+    // BH 2020.03.22 solved the assertEquals(c, i_faded) problem below
+    Jalview.setSynchronous(true);
   }
 
   @Test(groups = "Functional")
@@ -163,7 +167,7 @@ public class AlignFrameTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   /**
@@ -174,7 +178,7 @@ public class AlignFrameTest
   public void setUp()
   {
     Cache.loadProperties("test/jalview/io/testProps.jvprops");
-    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+    Cache.getInstance().applicationProperties.setProperty("SHOW_IDENTITY",
             Boolean.TRUE.toString());
     af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
             DataSourceType.FILE);
@@ -600,4 +604,26 @@ public class AlignFrameTest
     sp.valueChanged(22);
     assertEquals(av2.getResidueShading().getConservationInc(), 22);
   }
+
+  /**
+   * Verify that making a New View preserves the dataset reference for the
+   * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
+   * save alignments with multiple views, and codon mappings will not be shared
+   * across all panels in a split frame.
+   * 
+   * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
+   */
+  @Test(groups = "Functional")
+  public void testNewView_dsRefPreserved()
+  {
+    AlignViewport av = af.getViewport();
+    AlignmentI al = av.getAlignment();
+    AlignmentI original_ds = al.getDataset();
+    af.newView_actionPerformed(null);
+    assertNotEquals("New view didn't select the a new panel", av,
+            af.getViewport());
+    org.testng.Assert.assertEquals(original_ds,
+            af.getViewport().getAlignment().getDataset(),
+            "Dataset was not preserved in new view");
+  }
 }