use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class ResizeEventPropagationTest method shouldReturnARectangleStartingFromResizedColumnToEndOfGrid.
@Test
public void shouldReturnARectangleStartingFromResizedColumnToEndOfGrid() {
// Mimics resizing the second column
this.layerListener = new LayerListenerFixture();
this.dataLayer.addLayerListener(this.layerListener);
this.dataLayer.setColumnWidthByPosition(2, 200);
// This is the propagated event
ColumnResizeEvent columnResizeEvent = (ColumnResizeEvent) this.layerListener.getReceivedEvents().get(0);
Collection<Rectangle> actualRectangles = columnResizeEvent.getChangedPositionRectangles();
// The affected region should have the following size
Rectangle expectedRectangle = new Rectangle(2, 0, 3, 7);
Assert.assertEquals(expectedRectangle, actualRectangles.iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class AbstractLayerTest method setup.
@Before
public void setup() {
this.dataLayer = new DataLayerFixture();
this.firstListener = new LayerListenerFixture();
this.dataLayer.addLayerListener(this.firstListener);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class DataLayerCommandHandlingTest method handleUpdateDataCommandRaisesEvents.
@Test
public void handleUpdateDataCommandRaisesEvents() throws Exception {
LayerListenerFixture listener = new LayerListenerFixture();
this.dataLayer.addLayerListener(listener);
this.dataLayer.doCommand(this.command);
Assert.assertTrue(listener.getReceivedEvents().get(0) instanceof CellVisualChangeEvent);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class ColumnHideShowLayerTest2 method scrollAndHideTheLastColumn.
/**
* Integration test
*/
@Test
public void scrollAndHideTheLastColumn() throws Exception {
// Total columns in fixture - 20 (index 0 - 19)
NatTableFixture natTable = new NatTableFixture();
LayerListenerFixture natTableListener = new LayerListenerFixture();
natTable.addLayerListener(natTableListener);
// Scroll to position 14 in grid/14 in body
natTable.scrollToColumn(14);
assertEquals(14, natTable.getColumnIndexByPosition(1));
// Hide last column - position 6/index 19
assertEquals(19, natTable.getColumnIndexByPosition(6));
natTable.doCommand(new ColumnHideCommand(natTable, 6));
// Assert event received
assertNotNull(natTableListener.getReceivedEvent(HideColumnPositionsEvent.class));
HideColumnPositionsEvent hideEvent = (HideColumnPositionsEvent) natTableListener.getReceivedEvent(HideColumnPositionsEvent.class);
// When last column is hidden it is not carrying the following info
assertEquals(1, hideEvent.getColumnPositionRanges().size());
// View port adjusted origin to move an extra column in
Range hiddenRange = hideEvent.getColumnPositionRanges().iterator().next();
assertEquals(7, hiddenRange.start);
assertEquals(8, hiddenRange.end);
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture in project nebula.widgets.nattable by eclipse.
the class ReorderColumnEventTest method reorderEventMustPropagateToTheTop.
/**
* Fix for http://nattable.org/jira/browse/NTBL-476
*/
@Test
public void reorderEventMustPropagateToTheTop() throws Exception {
DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(20, 10, 100, 20));
NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer);
// Add listener
LayerListenerFixture listenerFixture = new LayerListenerFixture();
natTableFixture.addLayerListener(listenerFixture);
assertEquals(6, natTableFixture.getColumnCount());
assertEquals(1, natTableFixture.getColumnIndexByPosition(1));
// Move to outside the visible range
List<Integer> columnToMove = Arrays.asList(1, 2, 3);
int destinationPosition = 10;
natTableFixture.doCommand(new MultiColumnReorderCommand(natTableFixture, columnToMove, destinationPosition));
// Ensure that the event propagates to the top
assertEquals(1, listenerFixture.getEventsCount());
assertNotNull(listenerFixture.getReceivedEvent(ColumnReorderEvent.class));
assertEquals(4, natTableFixture.getColumnIndexByPosition(1));
}
Aggregations