* resized.
*/
@Test
public void shouldAutoResizeCorrectlyIfMultipleColumnsAreSelected()
throws Exception {
GridLayer gridLayer = new DefaultGridLayer(
RowDataListFixture.getList(),
RowDataListFixture.getPropertyNames(),
RowDataListFixture.getPropertyToLabelMap());
setClientAreaProvider(gridLayer);
// Resize grid column 1, 2
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 1, 10));
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 2, 10));
assertEquals(10, gridLayer.getColumnWidthByPosition(1));
assertEquals(10, gridLayer.getColumnWidthByPosition(2));
// Fully select columns 1, 2
SelectionLayer selectionLayer = ((DefaultBodyLayerStack) gridLayer
.getBodyLayer()).getSelectionLayer();
selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, 0, 0,
false, false));
selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, 1, 0,
true, false));
assertEquals(2, selectionLayer.getFullySelectedColumnPositions().length);
// Resize grid column 5
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 5, 10));
assertEquals(10, gridLayer.getColumnWidthByPosition(5));
// Auto resize column 5
InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(
gridLayer, 5, configRegistry, gcFactory);
gridLayer.doCommand(command);
// Columns 1 and 2 should not be resized
assertEquals(10, gridLayer.getColumnWidthByPosition(1));
assertEquals(10, gridLayer.getColumnWidthByPosition(2));
assertTrue(gridLayer.getColumnWidthByPosition(5) > 10);
}