Exemplo n.º 1
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.º 2
0
  public void testAlignmentChangeShouldInvokeLayout() throws Exception {
    panel.resetLayout();

    panel.styleChanged(Style.HORIZONTAL_ALIGNMENT, null);
    assertEquals(true, panel.needsLayout());

    panel.resetLayout();
    panel.styleChanged(Style.VERTICAL_ALIGNMENT, null);

    assertEquals(true, panel.needsLayout());
  }
Exemplo n.º 3
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.º 4
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.º 5
0
  public void testChangingTextColor() throws Exception {
    panel.setText("foo");
    panel.resetLayout();

    panel.styleChanged(Style.TEXT_COLOR, Style.TEXT_COLOR.compile("red"));

    assertEquals(true, panel.needsLayout());
  }
Exemplo n.º 6
0
  public void testChangingFontStyle() throws Exception {
    panel.setText("foo");
    panel.resetLayout();
    panel.resetPendingSizeChange();

    panel.styleChanged(Style.FONT_STYLE, Style.FONT_STYLE.compile("italic"));

    assertEquals(true, panel.needsLayout());
    assertEquals(true, panel.sizeChangePending());
  }
Exemplo n.º 7
0
  public void testChangingSizeToZeroWillReLayoutGrandDaddy() throws Exception {
    PropPanel child = new PropPanel(new MockProp());
    PropPanel grandChild = new PropPanel(new MockProp());
    panel.add(child);
    child.add(grandChild);
    child.resetLayout();
    panel.resetLayout();

    grandChild.styleChanged(Style.HEIGHT, new StaticDimensionAttribute(0));

    assertEquals(true, panel.needsLayout());
  }
Exemplo n.º 8
0
  public void testRequiredLayoutTriggeredWhilePerformingLayoutStillGetsRegistered()
      throws Exception {
    for (int i = 0; i < 100; i++) panel.add(new PropPanel(new MockProp()));
    panel.markAsNeedingLayout();
    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                panel.doLayout();
              }
            });
    thread.start();

    while (panel.getChildren().get(0).needsLayout()) Thread.yield();
    panel.markAsNeedingLayout();
    thread.join();

    assertEquals(true, panel.needsLayout());
  }
Exemplo n.º 9
0
  public void testHasChangesWhenaStyleIsChanged() throws Exception {
    style.setWidth("100%");

    assertEquals(true, panel.needsLayout());
  }