@Test
public void testMovingAroundColumns() {
// ---------------------- Move into middle of frozen area
// Frozen Columns: 1 5 2 3
// Frozen Rows: 0 3 3 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 5, 2));
// Test positions
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(4,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// Test indexes
Assert.assertEquals(4, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(4,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(5, freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(2));
Assert.assertEquals(3, freezeLayer.getColumnIndexByPosition(3));
// ---------------------- Move right edge out of frozen area
// Frozen Columns: 1 5 2
// Frozen Rows: 0 3 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 4, 6));
// Test indexes
Assert.assertEquals(3, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// Test positions
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Swap right edge with preceeding column
// Frozen Columns: 1 2 5
// Frozen Rows: 0 3 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 2));
// Test indexes
Assert.assertEquals(3, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(5, freezeLayer.getColumnIndexByPosition(2));
// Test positions
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move new right edge out
// Frozen Columns: 1 2
// Frozen Rows: 0 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 5));
// Test indexes
Assert.assertEquals(2, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(1));
// Test positions
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move column into frozen area replacing top
// left index
// Frozen Columns: 8 1 2
// Frozen Rows: 1 3 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 8, 1));
// Test indexes
Assert.assertEquals(3, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
Assert.assertEquals(8, freezeLayer.getColumnIndexByPosition(0));
Assert.assertEquals(1, freezeLayer.getColumnIndexByPosition(1));
Assert.assertEquals(2, freezeLayer.getColumnIndexByPosition(2));
// Test positions
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(3,
freezeLayer.getBottomRightPosition().columnPosition);
Assert.assertEquals(3, freezeLayer.getBottomRightPosition().rowPosition);
// ---------------------- Move right edge out
// Frozen Columns: 8 1
// Frozen Rows: 1 3
hideShowLayer.doCommand(new ColumnReorderCommand(hideShowLayer, 3, 5));
Assert.assertEquals(2, freezeLayer.getColumnCount());
Assert.assertEquals(1, freezeLayer.getTopLeftPosition().columnPosition);
Assert.assertEquals(0, freezeLayer.getTopLeftPosition().rowPosition);
Assert.assertEquals(2,
freezeLayer.getBottomRightPosition().columnPosition);