X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAlignmentViewTest.java;h=b201c7eb1f19cd9f4cbe9055a10c5328d1c0ff24;hb=fa906a98b4d665e4bf2ab0ae3605c4682730bd83;hp=24fe067fcb4abf930c9df0a6ac320053f1c8a01d;hpb=c5cf27bd5db2fc477c1483c1037f21375c9d0a04;p=jalview.git diff --git a/test/jalview/datamodel/AlignmentViewTest.java b/test/jalview/datamodel/AlignmentViewTest.java index 24fe067..b201c7e 100644 --- a/test/jalview/datamodel/AlignmentViewTest.java +++ b/test/jalview/datamodel/AlignmentViewTest.java @@ -1,11 +1,47 @@ +/* + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.datamodel; + import static org.testng.Assert.assertEquals; +import jalview.gui.AlignFrame; +import jalview.gui.AlignViewport; +import jalview.gui.JvOptionPane; +import jalview.io.DataSourceType; +import jalview.io.FileLoader; + +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class AlignmentViewTest { - @Test + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + + @Test(groups = { "Functional" }) public void testGetVisibleAlignmentGapChar() { SeqCigar ss = new SeqCigar(new Sequence("One", "A..CDE")); @@ -18,4 +54,69 @@ public class AlignmentViewTest assertEquals(av.getVisibleAlignment('$').getSequenceAt(0) .getSequenceAsString(), "A$$CDE"); } + + @Test(groups = { "Functional" }) + public void testGetVisibleContigs() + { + AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( + ">s1\n0123456789\n", DataSourceType.PASTE); + AlignViewport 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 }); + } }