Search in sources :

Example 1 with ViewportLayerFixture

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

the class ViewportLayerTest method moveRowIntoViewportByMovingUpAndDown.

/*
     * Rows 0 1 2 3 4 |----|----|----|----|----|
     */
@Test
public void moveRowIntoViewportByMovingUpAndDown() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(10, 5, 80, 80);
    assertEquals(100, this.viewportLayer.getClientAreaHeight());
    assertEquals(3, this.viewportLayer.getColumnCount());
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(3));
    assertEquals(3, this.viewportLayer.getRowIndexByPosition(0));
    // Keep moving up by 1 row
    this.viewportLayer.moveRowPositionIntoViewport(2);
    assertEquals(2, this.viewportLayer.getRowIndexByPosition(0));
    this.viewportLayer.moveRowPositionIntoViewport(1);
    assertEquals(1, this.viewportLayer.getRowIndexByPosition(0));
    // Move down
    this.viewportLayer.moveRowPositionIntoViewport(3);
    // partially
    assertEquals(2, this.viewportLayer.getRowIndexByPosition(0));
    // visible
    assertEquals(3, this.viewportLayer.getRowIndexByPosition(1));
    assertEquals(4, this.viewportLayer.getRowIndexByPosition(2));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 2 with ViewportLayerFixture

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

the class ViewportLayerTest method getColumnIndexByPosition.

/*
     * 0 1 2 3 4 5 6 7 8 9 |----|----|----|----|----|----|----|----|----|----|
     */
@Test
public void getColumnIndexByPosition() {
    this.viewportLayer = new ViewportLayerFixture(10, 5, 80, 40);
    assertEquals(3, this.viewportLayer.getColumnCount());
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(1));
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(2));
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(3));
    assertEquals(3, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(4, this.viewportLayer.getColumnIndexByPosition(1));
    assertEquals(5, this.viewportLayer.getColumnIndexByPosition(2));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 3 with ViewportLayerFixture

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

the class ViewportLayerTest method moveIntoViewportForAColPartiallyDisplayedAtTheRightEdge.

@Test
public void moveIntoViewportForAColPartiallyDisplayedAtTheRightEdge() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(new Rectangle(0, 0, 260, 100));
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(1));
    // Partially
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(2));
    // visible
    this.viewportLayer.moveColumnPositionIntoViewport(2);
    // no
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
    // movement
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(1));
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(2));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 4 with ViewportLayerFixture

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

the class ViewportLayerTest method adjustRowOrigin.

@Test
public void adjustRowOrigin() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(10, 20, 100, 20);
    // Default client area: width 200, height 100
    assertEquals(5, this.viewportLayer.getRowCount());
    assertEquals(200, this.viewportLayer.getStartYOfRowPosition(10));
    assertEquals(200, this.viewportLayer.adjustOriginY(this.viewportLayer.getStartYOfRowPosition(10)));
    // Increase view port height
    this.viewportLayer.getClientAreaProvider().getClientArea().height = 400;
    assertEquals(0, this.viewportLayer.adjustOriginY(this.viewportLayer.getStartYOfRowPosition(10)));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 5 with ViewportLayerFixture

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

the class HorizontalScrollBarHandlerTest method issueNTBL99MoveByPage.

@Test
public void issueNTBL99MoveByPage() throws Exception {
    this.viewport = new ViewportLayerFixture(2, 1, 250, 40);
    this.scrollHandler = new HorizontalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(200, this.viewport.getClientAreaWidth());
    assertEquals(1, this.viewport.getColumnCount());
    assertEquals(0, this.viewport.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