From faa3d71f9d120d665870e72b7217ae6b8bd6062d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 27 Apr 2017 16:39:33 +0100 Subject: [PATCH 1/1] JAL-1933 test for SHOW_OCCUPANCY .jalview_properties setting --- test/jalview/gui/AlignViewportTest.java | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 06df70a..d76ac33 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -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."); + + } } -- 1.7.10.2