From: gmungoc Date: Mon, 1 Oct 2018 14:05:28 +0000 (+0100) Subject: JAL-3093 unit tests for finding annotation row index for mouse pos X-Git-Tag: Release_2_11_0~17^2~83^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bb2361abadeaf6c8065e19391220faf39266f0ae;p=jalview.git JAL-3093 unit tests for finding annotation row index for mouse pos --- diff --git a/test/jalview/gui/AnnotationPanelTest.java b/test/jalview/gui/AnnotationPanelTest.java new file mode 100644 index 0000000..5f7d5a7 --- /dev/null +++ b/test/jalview/gui/AnnotationPanelTest.java @@ -0,0 +1,51 @@ +package jalview.gui; + +import static org.testng.Assert.assertEquals; + +import jalview.datamodel.AlignmentAnnotation; + +import org.testng.annotations.Test; + +public class AnnotationPanelTest +{ + + @Test(groups = "Functional") + public void testGetRowIndex() + { + assertEquals(AnnotationPanel.getRowIndex(0, null), -1); + + AlignmentAnnotation[] anns = new AlignmentAnnotation[] {}; + assertEquals(AnnotationPanel.getRowIndex(0, anns), -1); + + AlignmentAnnotation ann1 = new AlignmentAnnotation(null, null, null); + AlignmentAnnotation ann2 = new AlignmentAnnotation(null, null, null); + AlignmentAnnotation ann3 = new AlignmentAnnotation(null, null, null); + ann1.visible = true; + ann2.visible = true; + ann3.visible = true; + ann1.height = 10; + ann2.height = 20; + ann3.height = 30; + anns = new AlignmentAnnotation[] { ann1, ann2, ann3 }; + + assertEquals(AnnotationPanel.getRowIndex(0, anns), 0); + assertEquals(AnnotationPanel.getRowIndex(9, anns), 0); + assertEquals(AnnotationPanel.getRowIndex(10, anns), 1); + assertEquals(AnnotationPanel.getRowIndex(29, anns), 1); + assertEquals(AnnotationPanel.getRowIndex(30, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(59, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(60, anns), -1); + + ann2.visible = false; + assertEquals(AnnotationPanel.getRowIndex(0, anns), 0); + assertEquals(AnnotationPanel.getRowIndex(9, anns), 0); + assertEquals(AnnotationPanel.getRowIndex(10, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(39, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(40, anns), -1); + + ann1.visible = false; + assertEquals(AnnotationPanel.getRowIndex(0, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(29, anns), 2); + assertEquals(AnnotationPanel.getRowIndex(30, anns), -1); + } +}