JAL-3253-applet JAL-3397
[jalview.git] / test / jalview / gui / SeqPanelTest.java
index 8067148..c148039 100644 (file)
@@ -26,7 +26,6 @@ import static org.testng.Assert.assertTrue;
 
 import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
-import jalview.bin.Instance;
 import jalview.bin.Jalview;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
@@ -253,7 +252,7 @@ public class SeqPanelTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Instance.getDesktop().closeAll_actionPerformed(null);
+    Desktop.getInstance().closeAll_actionPerformed(null);
   }
 
   @Test(groups = "Functional")
@@ -726,6 +725,8 @@ public class SeqPanelTest
     assertTrue(charWidth > 0); // sanity check
     assertEquals(alignFrame.getViewport().getRanges().getStartRes(), 0);
 
+    System.out.println("SPT endres "
+            + alignFrame.getViewport().getRanges().getEndRes());
     /*
      * mouse at top left of unwrapped panel
      */
@@ -766,8 +767,23 @@ public class SeqPanelTest
     SeqCanvas seqCanvas = alignFrame.alignPanel.getSeqPanel().seqCanvas;
     int w = seqCanvas.getWidth();
     // limited to number of whole columns, base 0
-    int expected = w / charWidth - 1;
-    assertEquals(testee.findColumn(evt), expected);
+    // BH there are only 61 residues, but this calculation gives 65
+    // from SeqPanel return for findColumn:
+
+    // /*
+    // * make sure we calculate relative to visible alignment,
+    // * rather than right-hand gutter
+    // */
+    // x = Math.min(x, seqCanvas.getX() + seqCanvas.getWidth());
+    // res = (x / charWidth) + startRes;
+    // res = Math.min(res, av.getRanges().getEndRes());
+
+    int expected = w / charWidth;
+    expected = Math.min(
+            alignFrame.getViewport().getRanges().getEndRes(),
+            expected);
+    int col = testee.findColumn(evt);
+    assertEquals(col, expected);
 
     /*
      * hide columns 5-10 (base 1)
@@ -777,7 +793,8 @@ public class SeqPanelTest
     // x is in 6th visible column, absolute column 12, or 11 base 0
     evt = new MouseEvent(testee, Event.MOUSE_MOVE, 0L, 0, x, 0, 0, 0, 0,
             false, 0);
-    assertEquals(testee.findColumn(evt), 11);
+    col = testee.findColumn(evt);
+    assertEquals(col, 11);
   }
 
   @Test(groups = "Functional")