Layouts { public static int widthOrDefault(PanelDefinition def) { Integer width = toInteger(def.getWidthAsInt()); return width == null ? DEFAULT_CHILD_SIZE : width; }  static void setToFillParent(Widget w); static String getContainmentHierarchy(Widget w); static String getContainmentHierarchy(Widget w,
                                                 boolean setDebugIds); static String getContainedHierarchy(final Widget startAt); static int widthOrHeight(CompassPosition position,
                                    PanelDefinition definition); static int heightOrDefault(PanelDefinition def); static int widthOrDefault(PanelDefinition def); static boolean disableNearestScrollPanel(Widget w); static final int DEFAULT_CHILD_SIZE; }
@Test public void widthOrDefault() { when(panelDef.getWidthAsInt()).thenReturn(42); Integer width = Layouts.widthOrDefault(panelDef); assertEquals(42, width.intValue()); when(panelDef.getWidthAsInt()).thenReturn(-1); width = Layouts.widthOrDefault(panelDef); assertEquals(Layouts.DEFAULT_CHILD_SIZE, width.intValue()); }