Search in sources :

Example 16 with ViewportLayerFixture

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

the class HorizontalScrollBarHandlerTest method issueNTBL99MoveByColumn.

/*
     * Test for issue reported in http://nattable.org/jira/browse/NTBL-99.
     * Resizing the last column to be larger than the width of a table and
     * scrolling to the right results in a all white background and no columns
     *
     * COLUMNS 0 1 |------|------| 250 250
     */
@Test
public void issueNTBL99MoveByColumn() 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));
    scrollViewportByOffset(200);
    assertEquals(0, this.viewport.getColumnIndexByPosition(0));
    scrollViewportByOffset(200);
    assertEquals(1, this.viewport.getColumnIndexByPosition(0));
    // No more scrolling
    scrollViewportByOffset(200);
    assertEquals(1, this.viewport.getColumnIndexByPosition(0));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Test(org.junit.Test)

Example 17 with ViewportLayerFixture

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

the class HorizontalScrollBarHandlerTest method horizontalScrollbarThumbSizeCalcNoScrollingNeeded.

@Test
public void horizontalScrollbarThumbSizeCalcNoScrollingNeeded() throws Exception {
    this.viewport = new ViewportLayerFixture(new Rectangle(0, 0, 500, 500));
    this.scrollHandler = new HorizontalScrollBarHandler(this.viewport, this.scrollBar);
    this.scrollHandler.recalculateScrollBarSize();
    assertEquals(465, this.viewport.getWidth());
    assertEquals(465, 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) Test(org.junit.Test)

Example 18 with ViewportLayerFixture

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

the class HorizontalScrollBarHandlerTest method horizontalScrollbarThumbSize.

@Test
public void horizontalScrollbarThumbSize() throws Exception {
    this.viewport = new ViewportLayerFixture(new Rectangle(0, 0, 250, 100));
    this.scrollHandler = new HorizontalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(250, this.viewport.getWidth());
    this.scrollHandler.recalculateScrollBarSize();
    // Fixture data - viewport (250px), scrollable(465px)
    assertEquals(250, this.scrollHandler.scroller.getThumb());
    this.viewport.moveColumnPositionIntoViewport(9);
    assertEquals(250, this.scrollHandler.scroller.getThumb());
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 19 with ViewportLayerFixture

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

the class VerticalScrollBarHandlerTest method init.

@Before
public void init() {
    this.viewport = new ViewportLayerFixture();
    this.scrollBar = ViewportLayerFixture.DEFAULT_SCROLLABLE.getVerticalBar();
    this.scrollHandler = new VerticalScrollBarHandler(this.viewport, this.scrollBar);
    assertEquals(0, this.viewport.getRowIndexByPosition(0));
    assertEquals(1, this.viewport.getRowIndexByPosition(1));
}
Also used : ViewportLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ViewportLayerFixture) VerticalScrollBarHandler(org.eclipse.nebula.widgets.nattable.viewport.VerticalScrollBarHandler) 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