package jalview.gui;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
+import jalview.viewmodel.ViewportRanges;
import java.awt.event.MouseEvent;
SequenceI seq1 = new Sequence("Seq1", "MATRESS");
SequenceI seq2 = new Sequence("Seq2", "MADNESS");
AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
-
+
AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
al.getHeight());
- ScalePanel scalePanel = new ScalePanel(
- alignFrame.getViewport(), alignFrame.alignPanel
- );
-
- MouseEvent mouse = new MouseEvent(
- scalePanel, 0, 1, 0, 4, 0, 1, false
- );
+ ScalePanel scalePanel = alignFrame.alignPanel.getScalePanel();
+
+ MouseEvent mouse = new MouseEvent(scalePanel, 0, 1, 0, 4, 0, 1, false);
scalePanel.mousePressed(mouse);
scalePanel.mouseDragged(mouse);
int startCol = sg.getStartRes();
assertTrue(startCol >= 0);
+ }
+ /**
+ * Test for JAL-3212
+ */
+ @Test(groups = "Functional")
+ public void testSelectColumns_withHidden()
+ {
+ String seq1 = ">Seq1\nANTOFAGASTAVALPARAISOMONTEVIDEOANTANANARIVO";
+ AlignFrame alignFrame = new FileLoader().LoadFileWaitTillLoaded(seq1,
+ DataSourceType.PASTE);
+ ScalePanel scalePanel = alignFrame.alignPanel.getScalePanel();
+ /*
+ * hide columns 1-20 (of 43); then 'drag' to select columns 30-31;
+ * 31 is 51 in absolute columns but bug JAL-3212 reduces it to
+ * endRes which is 22
+ */
+ AlignViewport viewport = alignFrame.getViewport();
+ ViewportRanges ranges = viewport.getRanges();
+ assertEquals(ranges.getStartRes(), 0);
+ assertEquals(ranges.getEndRes(), 42);
+ viewport.hideColumns(0, 19);
+ alignFrame.alignPanel.updateLayout();
+ assertEquals(ranges.getStartRes(), 0);
+ assertEquals(ranges.getEndRes(), 22);
+
+ int cw = viewport.getCharWidth();
+ int xPos = 9 * cw + 2;
+ MouseEvent mouse = new MouseEvent(scalePanel, 0, 1, 0, xPos, 0, 1,
+ false);
+ scalePanel.mousePressed(mouse);
+ scalePanel.mouseDragged(mouse);
+ xPos += cw;
+ mouse = new MouseEvent(scalePanel, 0, 1, 0, xPos, 0, 1, false);
+ scalePanel.mouseReleased(mouse);
+
+ SequenceGroup sg = scalePanel.av.getSelectionGroup();
+ assertEquals(sg.getStartRes(), 29);
+ assertEquals(sg.getEndRes(), 30);
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public static void setUpBeforeClass() throws Exception
+ {
+ /*
+ * use read-only test properties file
+ */
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ Jalview.main(new String[] { "-nonews" });
}
}