X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignViewportTest.java;h=977e90169567c13c1bb60695b7af28805b2366f2;hb=f452bcb5ddecb4378e952447031ddb076bdf8268;hp=6ab262292afde1f723f3cb7d5d577ab3c92dd6b3;hpb=6c32da957091bb863e5bc70e94b13fd4bf72cf38;p=jalview.git diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 6ab2622..977e901 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -23,6 +23,7 @@ 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; @@ -41,6 +42,7 @@ 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; @@ -277,7 +279,7 @@ public class AlignViewportTest * Test for JAL-1306 - conservation thread should run even when only Quality * (and not Conservation) is enabled in Preferences */ - @Test(groups = { "Functional" }) + @Test(groups = { "Functional" }, timeOut=2000) public void testUpdateConservation_qualityOnly() { Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", @@ -292,7 +294,24 @@ public class AlignViewportTest Boolean.FALSE.toString()); AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); - AlignmentAnnotation[] anns = af.viewport.getAlignment() + + /* + * wait for Conservation thread to complete + */ + AlignViewport viewport = af.getViewport(); + synchronized (this) + { + while (viewport.getAlignmentConservationAnnotation() != null) + { + try + { + wait(50); + } catch (InterruptedException e) + { + } + } + } + AlignmentAnnotation[] anns = viewport.getAlignment() .getAlignmentAnnotation(); assertNotNull("No annotations found", anns); assertEquals("More than one annotation found", 1, anns.length); @@ -316,9 +335,34 @@ public class AlignViewportTest 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" }) @@ -385,7 +429,8 @@ public class AlignViewportTest AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); AlignViewportI av = af.getViewport(); - Assert.assertNull(av.getOccupancyAnnotation(), "Preference did not disable occupancy row."); + Assert.assertNull(av.getAlignmentGapAnnotation(), + "Preference did not disable occupancy row."); int c = 0; for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, null, "Occupancy")) @@ -399,10 +444,11 @@ public class AlignViewportTest af = new FileLoader().LoadFileWaitTillLoaded( "examples/uniref50.fa", DataSourceType.FILE); av = af.getViewport(); - Assert.assertNotNull(av.getOccupancyAnnotation(), "Preference did not enable occupancy row."); + Assert.assertNotNull(av.getAlignmentGapAnnotation(), + "Preference did not enable occupancy row."); c = 0; for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, - null, av.getOccupancyAnnotation().label)) + null, av.getAlignmentGapAnnotation().label)) { c++; }