//
// IGridInfo
//
////////////////////////////////////////////////////////////////////////////
public void test_IGridInfo_noSpans() throws Exception {
PanelInfo panel =
parseJavaInfo(
"public class Test extends Panel {",
" public Test() {",
" setLayout(new TableLayout(2));",
" {",
" Label label_1 = new Label('A');",
" add(label_1);",
" }",
" {",
" Label label_2 = new Label('AA');",
" add(label_2);",
" }",
" {",
" Label label_3 = new Label('A');",
" add(label_3);",
" }",
" }",
"}");
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();