" }",
" }",
"}");
panel.refresh();
TableLayoutInfo layout = (TableLayoutInfo) panel.getLayout();
IGridInfo gridInfo = layout.getGridInfo();
//
assertEquals(2, gridInfo.getColumnCount());
assertEquals(2, gridInfo.getRowCount());
// getColumnIntervals()
{
Interval[] intervals = gridInfo.getColumnIntervals();
assertThat(intervals).hasSize(2);
assertEquals(1, intervals[0].begin);
assertEquals(A_WIDTH, intervals[0].length);
assertEquals(1 + A_WIDTH, intervals[1].begin);
assertEquals(A_WIDTH * 2, intervals[1].length);
}
// getRowIntervals()
{
Interval[] intervals = gridInfo.getRowIntervals();
assertThat(intervals).hasSize(2);
assertEquals(1, intervals[0].begin);
assertEquals(A_HEIGHT, intervals[0].length);
assertEquals(1 + A_HEIGHT, intervals[1].begin);
assertEquals(A_HEIGHT, intervals[1].length);
}
// getCellsRectangle()
{
{
Rectangle cells = new Rectangle(0, 0, 1, 1);
Rectangle expected = new Rectangle(1, 1, A_WIDTH, A_HEIGHT);
assertEquals(expected, gridInfo.getCellsRectangle(cells));
}
{
Rectangle cells = new Rectangle(0, 0, 2, 1);
Rectangle expected = new Rectangle(1, 1, A_WIDTH + 2 * A_WIDTH, A_HEIGHT);
assertEquals(expected, gridInfo.getCellsRectangle(cells));
}
{
Rectangle cells = new Rectangle(0, 0, 1, 2);
Rectangle expected = new Rectangle(1, 1, A_WIDTH, A_HEIGHT + A_HEIGHT);
assertEquals(expected, gridInfo.getCellsRectangle(cells));
}
}
// getComponentCells()
{
assertEquals(
new Rectangle(0, 0, 1, 1),
gridInfo.getComponentCells(panel.getChildrenWidgets().get(0)));
assertEquals(
new Rectangle(1, 0, 1, 1),
gridInfo.getComponentCells(panel.getChildrenWidgets().get(1)));
assertEquals(
new Rectangle(0, 1, 1, 1),
gridInfo.getComponentCells(panel.getChildrenWidgets().get(2)));
}
// getOccupied()
{
assertSame(panel.getChildrenWidgets().get(0), gridInfo.getOccupied(0, 0));
assertSame(panel.getChildrenWidgets().get(1), gridInfo.getOccupied(1, 0));
assertSame(panel.getChildrenWidgets().get(2), gridInfo.getOccupied(0, 1));
assertSame(null, gridInfo.getOccupied(1, 1));
}
// getInsets()
{
Insets insets = gridInfo.getInsets();
assertEquals(new Insets(), insets);
}
// virtual columns
{
assertTrue(gridInfo.hasVirtualColumns());
assertEquals(5, gridInfo.getVirtualColumnGap());
assertEquals(25, gridInfo.getVirtualColumnSize());
}
// virtual rows
{
assertTrue(gridInfo.hasVirtualRows());
assertEquals(5, gridInfo.getVirtualRowGap());
assertEquals(25, gridInfo.getVirtualRowSize());
}
}