Merge branch 'develop' into features/JAL-2446NCList
[jalview.git] / test / jalview / gui / AlignViewportTest.java
index 5695b15..06df70a 100644 (file)
@@ -38,6 +38,7 @@ import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.io.DataSourceType;
 import jalview.io.FileLoader;
@@ -70,7 +71,8 @@ public class AlignViewportTest
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
-    Jalview.main(new String[] { "-props", "test/jalview/testProps.jvprops" });
+    Jalview.main(new String[] { "-nonews", "-props",
+        "test/jalview/testProps.jvprops" });
   }
 
   @BeforeMethod(alwaysRun = true)
@@ -345,16 +347,17 @@ public class AlignViewportTest
   public void testSetGlobalColourScheme()
   {
     /*
-     * test for JAL-2283 don't inadvertently turn on colour by conservation
+     * test for JAL-2283: don't inadvertently turn on colour by conservation
      */
-    Cache.applicationProperties.setProperty("DEFAULT_COLOUR_PROT", "NONE");
+    Cache.applicationProperties.setProperty("DEFAULT_COLOUR_PROT", "None");
     Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
             Boolean.TRUE.toString());
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
             "examples/uniref50.fa", DataSourceType.FILE);
     ColourSchemeI cs = new PIDColourScheme();
     af.getViewport().setGlobalColourScheme(cs);
-    assertFalse(cs.conservationApplied());
+    assertFalse(af.getViewport().getResidueShading()
+            .conservationApplied());
   }
 
   @Test(groups = { "Functional" })
@@ -380,4 +383,25 @@ public class AlignViewportTest
     af.getViewport().setSearchResults(null);
     assertFalse(af.getViewport().hasSearchResults());
   }
+
+  /**
+   * Verify that setting the selection group has the side-effect of setting the
+   * context on the group, unless it already has one
+   */
+  @Test(groups = { "Functional" })
+  public void testSetSelectionGroup()
+  {
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/uniref50.fa", DataSourceType.FILE);
+    AlignViewport av = af.getViewport();
+    SequenceGroup sg1 = new SequenceGroup();
+    SequenceGroup sg2 = new SequenceGroup();
+
+    av.setSelectionGroup(sg1);
+    assertSame(sg1.getContext(), av.getAlignment()); // context set
+
+    sg2.setContext(sg1);
+    av.setSelectionGroup(sg2);
+    assertSame(sg2.getContext(), sg1); // unchanged
+  }
 }