Search in sources :

Example 6 with ViewportLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture in project nebula.widgets.nattable by eclipse.

the class VerticalScrollBarHandlerTest method verticalScrollbarThumbSizeCalcNoScrollingNeeded.

@Test
public void verticalScrollbarThumbSizeCalcNoScrollingNeeded() throws Exception {
    this.viewport = new ViewportLayerFixture(new Rectangle(0, 0, 500, 500));
    this.scrollHandler = new VerticalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(465, this.viewport.getWidth());
    assertEquals(465, this.viewport.getWidth());
    this.scrollHandler.recalculateScrollBarSize();
    assertEquals(365, this.scrollHandler.scroller.getThumb());
    assertFalse(this.scrollBar.isEnabled());
    assertFalse(this.scrollBar.isVisible());
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) VerticalScrollBarHandler(org.eclipse.nebula.widgets.nattable.viewport.VerticalScrollBarHandler) Test(org.junit.Test)

Example 7 with ViewportLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture in project nebula.widgets.nattable by eclipse.

the class VerticalScrollBarHandlerTest method verticalScrollbarThumbSize.

@Test
public void verticalScrollbarThumbSize() throws Exception {
    this.viewport = new ViewportLayerFixture(new Rectangle(0, 0, 250, 100));
    this.scrollHandler = new VerticalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(250, this.viewport.getWidth());
    this.scrollHandler.recalculateScrollBarSize();
    // Fixture data - viewport height (100px), scrollable height (365px)
    // No overhang
    assertEquals(100, this.scrollHandler.scroller.getThumb());
    this.viewport.moveRowPositionIntoViewport(5);
    assertEquals(100, this.scrollHandler.scroller.getThumb());
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) VerticalScrollBarHandler(org.eclipse.nebula.widgets.nattable.viewport.VerticalScrollBarHandler) Test(org.junit.Test)

Example 8 with ViewportLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture in project nebula.widgets.nattable by eclipse.

the class ViewportLayerTest method setViewportMinOriginColumnPosition.

@Test
public void setViewportMinOriginColumnPosition() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(10, 20, 50, 20);
    this.viewportLayer.setMinimumOriginX(100);
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(100, this.viewportLayer.getOrigin().getX());
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(4, this.viewportLayer.getColumnCount());
    this.viewportLayer.setMinimumOriginX(200);
    assertEquals(4, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(200, this.viewportLayer.getOrigin().getX());
    assertEquals(4, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(4, this.viewportLayer.getColumnCount());
    this.viewportLayer.setMinimumOriginX(100);
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(100, this.viewportLayer.getOrigin().getX());
    this.viewportLayer.setOriginX(150);
    this.viewportLayer.setMinimumOriginX(200);
    assertEquals(4, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(250, this.viewportLayer.getOrigin().getX());
    this.viewportLayer.setMinimumOriginX(100);
    assertEquals(2, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(150, this.viewportLayer.getOrigin().getX());
    this.viewportLayer.setMinimumOriginX(450);
    assertEquals(9, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(450, this.viewportLayer.getOrigin().getX());
    assertEquals(9, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(1, this.viewportLayer.getColumnCount());
    this.viewportLayer.setMinimumOriginX(500);
    assertEquals(-1, this.viewportLayer.getMinimumOriginColumnPosition());
    assertEquals(500, this.viewportLayer.getOrigin().getX());
    assertEquals(-1, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(0, this.viewportLayer.getColumnCount());
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 9 with ViewportLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture in project nebula.widgets.nattable by eclipse.

the class ViewportLayerTest method setViewportMinOriginRowPosition.

@Test
public void setViewportMinOriginRowPosition() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(10, 20, 50, 20);
    this.viewportLayer.setMinimumOriginY(40);
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(40, this.viewportLayer.getOrigin().getY());
    assertEquals(2, this.viewportLayer.getRowIndexByPosition(0));
    assertEquals(5, this.viewportLayer.getRowCount());
    this.viewportLayer.setMinimumOriginY(80);
    assertEquals(4, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(80, this.viewportLayer.getOrigin().getY());
    assertEquals(4, this.viewportLayer.getRowIndexByPosition(0));
    assertEquals(5, this.viewportLayer.getRowCount());
    this.viewportLayer.setMinimumOriginY(40);
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(40, this.viewportLayer.getOrigin().getY());
    this.viewportLayer.setOriginY(60);
    this.viewportLayer.setMinimumOriginY(80);
    assertEquals(4, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(100, this.viewportLayer.getOrigin().getY());
    this.viewportLayer.setMinimumOriginY(40);
    assertEquals(2, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(60, this.viewportLayer.getOrigin().getY());
    this.viewportLayer.setMinimumOriginY(380);
    assertEquals(19, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(380, this.viewportLayer.getOrigin().getY());
    assertEquals(19, this.viewportLayer.getRowIndexByPosition(0));
    assertEquals(1, this.viewportLayer.getRowCount());
    this.viewportLayer.setMinimumOriginY(400);
    assertEquals(-1, this.viewportLayer.getMinimumOriginRowPosition());
    assertEquals(400, this.viewportLayer.getOrigin().getY());
    assertEquals(-1, this.viewportLayer.getRowIndexByPosition(0));
    assertEquals(0, this.viewportLayer.getRowCount());
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 10 with ViewportLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture in project nebula.widgets.nattable by eclipse.

the class ViewportLayerTest method moveColumnIntoViewportByMovingLeftAndRight.

/*
     * 0 1 2 3 4 5 6 7 8 9 |----|----|----|----|----|----|----|----|----|----|
     */
@Test
public void moveColumnIntoViewportByMovingLeftAndRight() throws Exception {
    // width of each column = 80
    // total width = 800
    // client area width = 200 = 80 + 80 + 40
    this.viewportLayer = new ViewportLayerFixture(10, 5, 80, 40);
    assertEquals(200, this.viewportLayer.getClientAreaWidth());
    assertEquals(3, this.viewportLayer.getColumnCount());
    this.viewportLayer.setOriginX(600);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(200, this.viewportLayer.getWidth());
    assertEquals(7, this.viewportLayer.getColumnIndexByPosition(0));
    // Keep moving left by 1 col
    this.viewportLayer.moveColumnPositionIntoViewport(9);
    assertEquals(7, this.viewportLayer.getColumnIndexByPosition(0));
    this.viewportLayer.moveColumnPositionIntoViewport(8);
    assertEquals(7, this.viewportLayer.getColumnIndexByPosition(0));
    this.viewportLayer.moveColumnPositionIntoViewport(7);
    assertEquals(7, this.viewportLayer.getColumnIndexByPosition(0));
    this.viewportLayer.moveColumnPositionIntoViewport(6);
    assertEquals(6, this.viewportLayer.getColumnIndexByPosition(0));
    this.viewportLayer.moveColumnPositionIntoViewport(5);
    assertEquals(5, this.viewportLayer.getColumnIndexByPosition(0));
    // Move right
    // partially
    this.viewportLayer.moveColumnPositionIntoViewport(7);
    // displayed
    assertEquals(5, this.viewportLayer.getColumnIndexByPosition(0));
    this.viewportLayer.moveColumnPositionIntoViewport(8);
    assertEquals(6, this.viewportLayer.getColumnIndexByPosition(0));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Aggregations

ViewportLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture)19 Test (org.junit.Test)16 Rectangle (org.eclipse.swt.graphics.Rectangle)6 VerticalScrollBarHandler (org.eclipse.nebula.widgets.nattable.viewport.VerticalScrollBarHandler)3 Before (org.junit.Before)3 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)1