/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import static org.testng.Assert.assertEquals;
+import jalview.gui.AlignFrame;
+import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+import jalview.viewmodel.AlignmentViewport;
+
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AlignmentViewTest
{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
@Test(groups = { "Functional" })
public void testGetVisibleAlignmentGapChar()
{
assertEquals(av.getVisibleAlignment('$').getSequenceAt(0)
.getSequenceAsString(), "A$$CDE");
}
+
+ @Test(groups = { "Functional" })
+ public void testGetVisibleContigs()
+ {
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ ">s1\n0123456789\n", DataSourceType.PASTE);
+ AlignmentViewport av = af.getViewport();
+ AlignmentView view = av.getAlignmentView(true);
+
+ /*
+ * verify getVisibleContigs returns inclusive [start, end] ranges
+ *
+ * no columns hidden
+ */
+ int[] contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+
+ /*
+ * hide 3 internal columns
+ */
+ av.hideColumns(5, 7);
+ // the old AlignmentView is now stale!
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+ // get a fresh AlignmentView
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 4, 8, 9 });
+
+ // hide first 2 columns
+ av.hideColumns(0, 1);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 4, 8, 9 });
+
+ // hide last column
+ av.hideColumns(9, 9);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 4, 8, 8 });
+
+ // unhide columns 5-7
+ av.showColumn(5);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 2, 8 });
+
+ // hide columns 2-7
+ av.hideColumns(2, 7);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 8, 8 });
+
+ // hide column 8
+ av.hideColumns(8, 8);
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] {});
+
+ // unhide all
+ av.showAllHiddenColumns();
+ view = av.getAlignmentView(true);
+ contigs = view.getVisibleContigs();
+ assertEquals(contigs, new int[] { 0, 9 });
+ }
}