Exemplo n.º 1
0
  public void testHasChangesWhenaTextIsChanged() throws Exception {
    TextPanel.staticFontRenderingContext = new FontRenderContext(new AffineTransform(), true, true);
    panel.doLayout();

    panel.setText("blah");
    assertEquals(true, panel.needsLayout());

    panel.doLayout();
    panel.setText("blah");
    assertEquals(false, panel.needsLayout());

    panel.setText("new text");
    assertEquals(true, panel.needsLayout());
  }
Exemplo n.º 2
0
  public void testMarginStyleChanges() throws Exception {
    panel.doLayout();
    assertEquals(false, panel.needsLayout());

    checkLayoutOnStyle(Style.TOP_MARGIN);
    checkLayoutOnStyle(Style.RIGHT_MARGIN);
    checkLayoutOnStyle(Style.BOTTOM_MARGIN);
    checkLayoutOnStyle(Style.LEFT_MARGIN);

    checkLayoutOnStyle(Style.TOP_PADDING);
    checkLayoutOnStyle(Style.RIGHT_PADDING);
    checkLayoutOnStyle(Style.BOTTOM_PADDING);
    checkLayoutOnStyle(Style.LEFT_PADDING);

    //    checkLayoutOnStyle(Style.TOP_RIGHT_ROUNDED_CORNER_RADIUS);
    //    checkLayoutOnStyle(Style.BOTTOM_RIGHT_ROUNDED_CORNER_RADIUS);
    //    checkLayoutOnStyle(Style.BOTTOM_LEFT_ROUNDED_CORNER_RADIUS);
    //    checkLayoutOnStyle(Style.TOP_LEFT_ROUNDED_CORNER_RADIUS);

    checkLayoutOnStyle(Style.TOP_BORDER_WIDTH);
    checkLayoutOnStyle(Style.TOP_RIGHT_BORDER_WIDTH);
    checkLayoutOnStyle(Style.RIGHT_BORDER_WIDTH);
    checkLayoutOnStyle(Style.BOTTOM_RIGHT_BORDER_WIDTH);
    checkLayoutOnStyle(Style.BOTTOM_BORDER_WIDTH);
    checkLayoutOnStyle(Style.BOTTOM_LEFT_BORDER_WIDTH);
    checkLayoutOnStyle(Style.LEFT_BORDER_WIDTH);
    checkLayoutOnStyle(Style.TOP_LEFT_BORDER_WIDTH);
  }
Exemplo n.º 3
0
 private void checkLayoutOnStyle(StyleDescriptor styleDescriptor) {
   Box box = panel.getBoxInsidePadding();
   panel.styleChanged(styleDescriptor, new StaticPixelsAttribute(20));
   assertEquals(true, panel.needsLayout());
   panel.doLayout();
   assertNotSame(box, panel.getBoxInsidePadding());
   assertEquals(false, panel.needsLayout());
 }
Exemplo n.º 4
0
  public void testOnlyPaintWhenLaidOut() throws Exception {
    MockAfterPaintAction paintAction = new MockAfterPaintAction();
    panel.setAfterPaintAction(paintAction);

    panel.paintOn(new MockGraphics());
    assertEquals(false, paintAction.invoked);

    panel.doLayout();
    panel.paintOn(new MockGraphics());
    assertEquals(true, paintAction.invoked);
  }
Exemplo n.º 5
0
  public void testAfterPaintAction() throws Exception {
    MockAfterPaintAction action = new MockAfterPaintAction();
    panel.setAfterPaintAction(action);
    panel.setSize(100, 100);
    MockGraphics mockGraphics = new MockGraphics();
    mockGraphics.setClip(0, 0, 100, 100);
    panel.doLayout();
    panel.paintOn(mockGraphics);

    assertEquals(true, action.invoked);
  }
Exemplo n.º 6
0
 private void checkBorderChanged(StyleDescriptor styleDescriptor) {
   panel.styleChanged(styleDescriptor, new SimpleIntegerAttribute(5));
   assertEquals(true, panel.borderChanged());
   panel.doLayout();
   assertEquals(false, panel.borderChanged());
 }