--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import static org.testng.Assert.assertEquals;
+
+import jalview.bin.Jalview;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AlignmentPanelTest
+{
+ SequenceI seq1 = new Sequence(
+ "Seq1",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq2 = new Sequence(
+ "Seq2",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq3 = new Sequence(
+ "Seq3",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq4 = new Sequence(
+ "Seq4",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq5 = new Sequence(
+ "Seq5",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq6 = new Sequence(
+ "Seq6",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq7 = new Sequence(
+ "Seq7",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq8 = new Sequence(
+ "Seq8",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq9 = new Sequence(
+ "Seq9",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq10 = new Sequence(
+ "Seq10",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq11 = new Sequence(
+ "Seq11",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq12 = new Sequence(
+ "Seq12",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq13 = new Sequence(
+ "Seq13",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq14 = new Sequence(
+ "Seq14",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq15 = new Sequence(
+ "Seq15",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq16 = new Sequence(
+ "Seq16",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq17 = new Sequence(
+ "Seq17",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq18 = new Sequence(
+ "Seq18",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq19 = new Sequence(
+ "Seq19",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq20 = new Sequence(
+ "Seq20",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq21 = new Sequence(
+ "Seq21",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq22 = new Sequence(
+ "Seq22",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ SequenceI seq23 = new Sequence(
+ "Seq23",
+ "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+ @BeforeClass(alwaysRun = true)
+ public void setUp()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+
+ Jalview.main(new String[] { "-nonews", "-props",
+ "test/jalview/testProps.jvprops" });
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ Desktop.instance.closeAll_actionPerformed(null);
+ }
+
+ /**
+ * Test side effect that end residue is set correctly by setScrollValues, with
+ * or without hidden columns
+ */
+ @Test(groups = "Functional")
+ public void TestSetScrollValues()
+ {
+ SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4, seq5,
+ seq6, seq7, seq8, seq9, seq10, seq11, seq12, seq13, seq14, seq15,
+ seq16, seq17, seq18, seq19, seq20, seq21, seq22, seq23 };
+ Alignment al = new Alignment(seqs);
+ al.setDataset(null);
+ AlignViewport av = new AlignViewport(al);
+
+ AlignFrame alignFrame = new AlignFrame(al, 700, 500);
+ AlignmentPanel ap = new AlignmentPanel(alignFrame, av);
+
+ int oldres = av.getEndRes();
+ ap.setScrollValues(-1, 5);
+
+ // setting -ve x value does not change residue
+ assertEquals(av.getEndRes(), oldres);
+
+ ap.setScrollValues(0, 5);
+
+ // setting 0 as x value does not change residue
+ assertEquals(av.getEndRes(), oldres);
+
+ ap.setScrollValues(5, 5);
+ // setting x value to 20 extends endRes by 20px converted to residues
+ assertEquals(av.getEndRes(), oldres + 5);
+
+
+ }
+}