From: Jim Procter Date: Mon, 20 Jun 2016 15:26:16 +0000 (+0100) Subject: JAL-1369 failing test X-Git-Tag: Release_2_10_0~161^2~5^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1b5ceff73a44527894e97d81211d2d7e659ce22f;p=jalview.git JAL-1369 failing test --- diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index 5e2ceb9..21bf846 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -36,6 +36,8 @@ import jalview.schemes.AnnotationColourGradient; import jalview.schemes.ColourSchemeI; import java.io.File; +import java.util.HashMap; +import java.util.Map; import org.testng.Assert; import org.testng.AssertJUnit; @@ -413,6 +415,72 @@ public class Jalview2xmlTests Desktop.getAlignmentPanels(af.getViewport().getSequenceSetId()).length); } + /** + * based on above test store and recovery of expanded views. + * + * @throws Exception + */ + @Test(groups = { "Functional" }, enabled = true) + public void testStoreAndRecoverReferenceSeqSettings() throws Exception + { + String afid = ""; + { + AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( + "examples/exampleFile_2_7.jar", FormatAdapter.FILE); + assertTrue("Didn't read in the example file correctly.", af != null); + afid = af.getViewport().getSequenceSetId(); + } + Map refs = new HashMap(); + int n = 1; + for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid)) + { + // mark representative + SequenceI rep = ap.getAlignment().getSequenceAt( + n++ % ap.getAlignment().getHeight()); + refs.put(ap.getViewName(), rep); + // code from mark/unmark sequence as reference in jalview.gui.PopupMenu + // todo refactor the to an alignment view controller + ap.getAlignViewport().setDisplayReferenceSeq(true); + ap.getAlignViewport().setColourByReferenceSeq(true); + ap.getAlignViewport().getAlignment().setSeqrep(rep); + } + File tfile = File.createTempFile("testStoreAndRecoverReferenceSeq", + ".jvp"); + try + { + new Jalview2XML(false).saveState(tfile); + } catch (Error e) + { + Assert.fail("Didn't save the expanded view state", e); + } catch (Exception e) + { + Assert.fail("Didn't save the expanded view state", e); + } + Desktop.instance.closeAll_actionPerformed(null); + if (Desktop.getAlignFrames() != null) + { + Assert.assertEquals(Desktop.getAlignFrames().length, 0); + } + { + AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( + tfile.getAbsolutePath(), FormatAdapter.FILE); + } + for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(Desktop + .getAlignFrames()[0].getViewport().getSequenceSetId())) + { + // check representative + SequenceI rep = ap.getAlignment().getSeqrep(); + Assert.assertNotNull(rep, + "Couldn't restore sequence representative from project"); + Assert.assertEquals(refs.get(ap.getViewName()), rep, + "Representative wasn't the same when recovered."); + Assert.assertTrue(ap.getAlignViewport().isDisplayReferenceSeq(), + "Display reference sequence view setting not set."); + Assert.assertTrue(ap.getAlignViewport().isColourByReferenceSeq(), + "Colour By Reference Seq view setting not set."); + } + } + @Test(groups = { "Functional" }) public void testIsVersionStringLaterThan() {