import jalview.schemes.ColourSchemeI;
import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
import org.testng.Assert;
import org.testng.AssertJUnit;
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<String, SequenceI> refs = new HashMap<String, SequenceI>();
+ 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()
{