X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignViewportTest.java;h=76021ce97f0af9dba587f9e0cc1011454b37ac8a;hb=b93f8af382bb2fbdb0c974558bcef57750d1bdd6;hp=780125016791750cb8ab79830377d517c86f1c37;hpb=4e77e758e10a6b83902b3cc21a669da8bcd0dc8f;p=jalview.git diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 7801250..76021ce 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -23,9 +23,18 @@ package jalview.gui; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNotSame; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; +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; + import jalview.bin.Cache; import jalview.bin.Jalview; import jalview.datamodel.AlignedCodonFrame; @@ -33,8 +42,6 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SearchResults; import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; @@ -42,20 +49,13 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.DataSourceType; import jalview.io.FileLoader; +import jalview.schemes.ClustalxColourScheme; import jalview.schemes.ColourSchemeI; import jalview.schemes.PIDColourScheme; import jalview.structure.StructureSelectionManager; import jalview.util.MapList; import jalview.viewmodel.ViewportRanges; -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; - public class AlignViewportTest { @@ -280,15 +280,15 @@ public class AlignViewportTest @Test(groups = { "Functional" }, timeOut=2000) public void testUpdateConservation_qualityOnly() { - Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", + Cache.setPropertyNoSave("SHOW_ANNOTATIONS", Boolean.TRUE.toString()); - Cache.applicationProperties.setProperty("SHOW_QUALITY", + Cache.setPropertyNoSave("SHOW_QUALITY", Boolean.TRUE.toString()); - Cache.applicationProperties.setProperty("SHOW_CONSERVATION", + Cache.setPropertyNoSave("SHOW_CONSERVATION", Boolean.FALSE.toString()); - Cache.applicationProperties.setProperty("SHOW_OCCUPANCY", + Cache.setPropertyNoSave("SHOW_OCCUPANCY", Boolean.FALSE.toString()); - Cache.applicationProperties.setProperty("SHOW_IDENTITY", + Cache.setPropertyNoSave("SHOW_IDENTITY", Boolean.FALSE.toString()); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); @@ -297,9 +297,29 @@ public class AlignViewportTest * wait for Conservation thread to complete */ AlignViewport viewport = af.getViewport(); + waitForCalculations(viewport); + AlignmentAnnotation[] anns = viewport.getAlignment() + .getAlignmentAnnotation(); + assertNotNull("No annotations found", anns); + assertEquals("More than one annotation found", 1, anns.length); + assertTrue("Annotation is not Quality", + anns[0].description.startsWith("Alignment Quality")); + Annotation[] annotations = anns[0].annotations; + assertNotNull("Quality annotations are null", annotations); + assertNotNull("Quality in column 1 is null", annotations[0]); + assertTrue("No quality value in column 1", annotations[0].value > 10f); + } + + /** + * Wait for consensus etc calculation threads to complete + * + * @param viewport + */ + protected void waitForCalculations(AlignViewport viewport) + { synchronized (this) { - while (viewport.getAlignmentConservationAnnotation() != null) + while (viewport.getCalcManager().isWorking()) { try { @@ -309,16 +329,6 @@ public class AlignViewportTest } } } - AlignmentAnnotation[] anns = viewport.getAlignment() - .getAlignmentAnnotation(); - assertNotNull("No annotations found", anns); - assertEquals("More than one annotation found", 1, anns.length); - assertTrue("Annotation is not Quality", - anns[0].description.startsWith("Alignment Quality")); - Annotation[] annotations = anns[0].annotations; - assertNotNull("Quality annotations are null", annotations); - assertNotNull("Quality in column 1 is null", annotations[0]); - assertTrue("No quality value in column 1", annotations[0].value > 10f); } @Test(groups = { "Functional" }) @@ -327,15 +337,40 @@ public class AlignViewportTest /* * test for JAL-2283: don't inadvertently turn on colour by conservation */ - Cache.applicationProperties.setProperty("DEFAULT_COLOUR_PROT", "None"); - Cache.applicationProperties.setProperty("SHOW_CONSERVATION", + Cache.setPropertyNoSave("DEFAULT_COLOUR_PROT", "None"); + Cache.setPropertyNoSave("SHOW_CONSERVATION", Boolean.TRUE.toString()); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); ColourSchemeI cs = new PIDColourScheme(); - af.getViewport().setGlobalColourScheme(cs); - assertFalse(af.getViewport().getResidueShading() + AlignViewport viewport = af.getViewport(); + viewport.setGlobalColourScheme(cs); + assertFalse(viewport.getResidueShading() .conservationApplied()); + + /* + * JAL-3201 groups have their own ColourSchemeI instances + */ + AlignmentI aln = viewport.getAlignment(); + SequenceGroup sg1 = new SequenceGroup(); + sg1.addSequence(aln.getSequenceAt(0), false); + sg1.addSequence(aln.getSequenceAt(2), false); + SequenceGroup sg2 = new SequenceGroup(); + sg2.addSequence(aln.getSequenceAt(1), false); + sg2.addSequence(aln.getSequenceAt(3), false); + aln.addGroup(sg1); + aln.addGroup(sg2); + viewport.setColourAppliesToAllGroups(true); + viewport.setGlobalColourScheme(new ClustalxColourScheme()); + ColourSchemeI cs0 = viewport.getGlobalColourScheme(); + ColourSchemeI cs1 = sg1.getColourScheme(); + ColourSchemeI cs2 = sg2.getColourScheme(); + assertTrue(cs0 instanceof ClustalxColourScheme); + assertTrue(cs1 instanceof ClustalxColourScheme); + assertTrue(cs2 instanceof ClustalxColourScheme); + assertNotSame(cs0, cs1); + assertNotSame(cs0, cs2); + assertNotSame(cs1, cs2); } @Test(groups = { "Functional" }) @@ -441,6 +476,7 @@ public class AlignViewportTest AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta, DataSourceType.PASTE); AlignViewport testme = af.getViewport(); + waitForCalculations(testme); SequenceI cons = testme.getConsensusSeq(); assertEquals("A-C", cons.getSequenceAsString()); }