JAL-2611 unit tests
[jalview.git] / test / jalview / viewmodel / OverviewDimensionsHideHiddenTest.java
index ebafba6..f6a9d32 100644 (file)
@@ -954,6 +954,51 @@ public class OverviewDimensionsHideHiddenTest
     assertFalse(od.isPositionInBox(75, 20));
   }
 
+  /**
+   * Test the dragging functionality
+   */
+  @Test(groups = { "Functional" })
+  public void testDragging()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    od.setDragPoint(4, 16, al.getHiddenSequences(),
+            hiddenCols);
+    od.adjustViewportFromMouse(20, 22,
+            al.getHiddenSequences(), hiddenCols);
+
+    // updates require an OverviewPanel to exist which it doesn't here
+    // so call setBoxPosition() as it would be called by the AlignmentPanel
+    // normally
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+    // corner moves 16 (20-4) right and 6 (22-16) up
+    assertEquals(od.getBoxX(), 16);
+    assertEquals(od.getBoxY(), 6);
+
+    // hide columns - makes no difference
+    hiddenCols.hideColumns(1, 4);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols);
+    od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+    // corner moves 16 (20-4) right and 6 (22-16) up
+    assertEquals(od.getBoxX(), 16);
+    assertEquals(od.getBoxY(), 6);
+
+    // hide sequences in box area
+    // makes absolutely no difference
+    hideSequences(1, 3);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols);
+    od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+    // corner moves 16 (20-4) right and 6 (22-16) up
+    assertEquals(od.getBoxX(), 16);
+    assertEquals(od.getBoxY(), 6);
+  }
+
   /*
    * Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same.
    */