////////////////////////////////////////////////////////////////////////////
/**
* Test for {@link LayoutPanelInfo#getLocationHint(WidgetInfo, int, int)}.
*/
public void test_getLocationHint() throws Exception {
RootLayoutPanelInfo frame =
parseJavaInfo(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootLayoutPanel rootPanel = RootLayoutPanel.get();",
" {",
" Button button = new Button();",
" rootPanel.add(button);",
" }",
" {",
" Button button_LW_TH = new Button();",
" rootPanel.add(button_LW_TH);",
" rootPanel.setWidgetLeftWidth(button_LW_TH, 1.0, Unit.MM, 1.0, Unit.CM);",
" rootPanel.setWidgetTopHeight(button_LW_TH, 2.0, Unit.PX, 1.0, Unit.CM);",
" }",
" {",
" Button button_LR_TB = new Button();",
" rootPanel.add(button_LR_TB);",
" rootPanel.setWidgetLeftRight(button_LR_TB, 1.0, Unit.MM, 1.0, Unit.CM);",
" rootPanel.setWidgetTopBottom(button_LR_TB, 2.0, Unit.CM, 1.0, Unit.CM);",
" }",
" {",
" Button button_RW_BH = new Button();",
" rootPanel.add(button_RW_BH);",
" rootPanel.setWidgetRightWidth(button_RW_BH, 10.0, Unit.PX, 100, Unit.PX);",
" rootPanel.setWidgetBottomHeight(button_RW_BH, 20.0, Unit.PX, 50, Unit.PX);",
" }",
" }",
"}");
frame.refresh();
//
{
WidgetInfo button = getJavaInfoByName("button");
assertEquals("100.0px x 50.0px", frame.getLocationHint(button, 100, 50));
assertEquals(false, frame.getLocationHint_isTrailing(button, true));
assertEquals(false, frame.getLocationHint_isTrailing(button, false));
}
{
WidgetInfo button = getJavaInfoByName("button_LW_TH");
assertEquals(MM_100 + "mm" + " x 50.0px", frame.getLocationHint(button, 100, 50));
assertEquals(false, frame.getLocationHint_isTrailing(button, true));
assertEquals(false, frame.getLocationHint_isTrailing(button, false));
}
{
WidgetInfo button = getJavaInfoByName("button_LR_TB");
assertEquals(MM_50 + "mm" + " x " + CM_100 + "cm", frame.getLocationHint(button, 50, 100));
assertEquals(false, frame.getLocationHint_isTrailing(button, true));
assertEquals(false, frame.getLocationHint_isTrailing(button, false));
}
{
WidgetInfo button = getJavaInfoByName("button_RW_BH");
assertEquals(
"80.0px x 40.0px",
frame.getLocationHint(button, 450 - (100 + 80), 300 - (50 + 40)));
assertEquals(true, frame.getLocationHint_isTrailing(button, true));
assertEquals(true, frame.getLocationHint_isTrailing(button, false));
}
}