Search in sources :

Example 11 with ViewportLayerFixture

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

the class ViewportLayerTest method testMoveColumnPositionIntoViewportSimpleCase.

@Test
public void testMoveColumnPositionIntoViewportSimpleCase() {
    this.viewportLayer = new ViewportLayerFixture();
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(1));
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(2));
    this.viewportLayer.moveColumnPositionIntoViewport(3);
    assertEquals(1, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(2, this.viewportLayer.getColumnIndexByPosition(1));
    assertEquals(3, this.viewportLayer.getColumnIndexByPosition(2));
    this.viewportLayer.moveColumnPositionIntoViewport(0);
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 12 with ViewportLayerFixture

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

the class ViewportLayerTest method testMoveColumnPositionIntoViewportForAColumnAlreadyInTheViewport.

@Test
public void testMoveColumnPositionIntoViewportForAColumnAlreadyInTheViewport() {
    this.viewportLayer = new ViewportLayerFixture(new Rectangle(0, 0, 285, 100));
    this.viewportLayer.moveColumnPositionIntoViewport(2);
    assertEquals(0, this.viewportLayer.getColumnIndexByPosition(0));
    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 13 with ViewportLayerFixture

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

the class ViewportLayerTest method setup.

@Before
public void setup() {
    this.viewportLayer = new ViewportLayerFixture();
    this.layerListener = new LayerListenerFixture();
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Before(org.junit.Before)

Example 14 with ViewportLayerFixture

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

the class ViewportLayerTest method adjustColOrigin.

@Test
public void adjustColOrigin() throws Exception {
    this.viewportLayer = new ViewportLayerFixture(10, 20, 50, 20);
    // Default client area: width 200, height 100
    assertEquals(4, this.viewportLayer.getColumnCount());
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(4));
    assertEquals(4, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(200, this.viewportLayer.getStartXOfColumnPosition(4));
    assertEquals(200, this.viewportLayer.adjustOriginX(this.viewportLayer.getStartXOfColumnPosition(4)));
    // Try to scroll off the end
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(9));
    assertEquals(6, this.viewportLayer.getColumnIndexByPosition(0));
    assertEquals(450, this.viewportLayer.getStartXOfColumnPosition(9));
    assertEquals(300, this.viewportLayer.adjustOriginX(this.viewportLayer.getStartXOfColumnPosition(9)));
    // Increase viewport width
    this.viewportLayer.getClientAreaProvider().getClientArea().width = 500;
    assertEquals(450, this.viewportLayer.getStartXOfColumnPosition(9));
    assertEquals(0, this.viewportLayer.adjustOriginX(this.viewportLayer.getStartXOfColumnPosition(9)));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 15 with ViewportLayerFixture

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

the class HorizontalScrollBarHandlerTest method init.

@Before
public void init() {
    this.viewport = new ViewportLayerFixture();
    this.scrollBar = ViewportLayerFixture.DEFAULT_SCROLLABLE.getHorizontalBar();
    this.scrollHandler = new HorizontalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(0, this.viewport.getColumnIndexByPosition(0));
    assertEquals(1, this.viewport.getColumnIndexByPosition(1));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Before(org.junit.Before)

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