Exemplo n.º 1
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.º 2
0
  public void testWidthOrHeightChanges() throws Exception {
    panel.styleChanged(Style.WIDTH, new StaticDimensionAttribute(20));
    assertEquals(true, panel.sizeChangePending());
    panel.resetPendingSizeChange();
    assertEquals(false, panel.sizeChangePending());

    panel.styleChanged(Style.HEIGHT, new StaticDimensionAttribute(20));
    assertEquals(true, panel.sizeChangePending());
    panel.resetPendingSizeChange();
    assertEquals(false, panel.sizeChangePending());
  }
Exemplo n.º 3
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.º 4
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.º 5
0
  public void testShouldPropagateConsumableAreaChangeForBorderChange() throws Exception {
    MockPanel child = new MockPanel();
    panel.add(child);

    panel.styleChanged(Style.TOP_BORDER_WIDTH, new SimpleIntegerAttribute(5));

    assertEquals(true, child.consumableAreaChangedCalled);
  }
Exemplo n.º 6
0
  public void testShouldPropagateConsumableAreaChangeForWidthChange() throws Exception {
    MockPanel child = new MockPanel();
    panel.add(child);

    panel.styleChanged(Style.WIDTH, new StaticDimensionAttribute(20));

    assertEquals(true, child.consumableAreaChangedCalled);
  }
Exemplo n.º 7
0
  public void testShouldNotBuildBufferWhenTransparencyChanges() throws Exception {
    SimpleCache<limelight.ui.Panel, BufferedImage> cache =
        new SimpleCache<limelight.ui.Panel, BufferedImage>();
    Context.instance().bufferedImageCache = cache;
    cache.cache(panel, new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));

    panel.styleChanged(Style.TRANSPARENCY, new SimplePercentageAttribute(20));
    assertNotNull(cache.retrieve(panel));
  }
Exemplo n.º 8
0
  public void testShouldBuildBufferWhenStyleChanges() throws Exception {
    SimpleCache<limelight.ui.Panel, BufferedImage> cache =
        new SimpleCache<limelight.ui.Panel, BufferedImage>();
    Context.instance().bufferedImageCache = cache;
    cache.cache(panel, new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));

    panel.styleChanged(Style.WIDTH, new StaticDimensionAttribute(20));
    assertEquals(null, cache.retrieve(panel));
  }
Exemplo n.º 9
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.º 10
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.º 11
0
 private void checkBorderChanged(StyleDescriptor styleDescriptor) {
   panel.styleChanged(styleDescriptor, new SimpleIntegerAttribute(5));
   assertEquals(true, panel.borderChanged());
   panel.doLayout();
   assertEquals(false, panel.borderChanged());
 }