JAL-1933 test for SHOW_OCCUPANCY .jalview_properties setting
authorJim Procter <jprocter@issues.jalview.org>
Thu, 27 Apr 2017 15:39:33 +0000 (16:39 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 27 Apr 2017 15:39:33 +0000 (16:39 +0100)
test/jalview/gui/AlignViewportTest.java

index 06df70a..d76ac33 100644 (file)
@@ -50,6 +50,7 @@ import jalview.util.MapList;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -404,4 +405,40 @@ public class AlignViewportTest
     av.setSelectionGroup(sg2);
     assertSame(sg2.getContext(), sg1); // unchanged
   }
+  /**
+   * Verify that setting/clearing SHOW_OCCUPANCY preference adds or omits occupancy row from viewport
+   */
+  @Test(groups = { "Functional" })
+  public void testShowOrDontShowOccupancy()
+  {
+    // disable occupancy
+    jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.FALSE.toString());
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/uniref50.fa", DataSourceType.FILE);
+    AlignViewport av = af.getViewport();
+    Assert.assertNull(av.getAlignmentGapAnnotation(), "Preference did not disable occupancy row.");
+    int c = 0;
+    for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null,
+            null, "Occupancy"))
+    {
+      c++;
+    }
+    Assert.assertEquals(c, 0, "Expected zero occupancy rows.");
+    
+    // enable occupancy
+    jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", Boolean.TRUE.toString());
+    af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/uniref50.fa", DataSourceType.FILE);
+    av = af.getViewport();
+    Assert.assertNotNull(av.getAlignmentGapAnnotation(), "Preference did not enable occupancy row.");
+    c = 0;
+    for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null,
+            null, av.getAlignmentGapAnnotation().label))
+    {
+      c++;
+    }
+    ;
+    Assert.assertEquals(c, 1, "Expected to find one occupancy row.");
+
+  }
 }