Package com.eclipsesource.tabris.passepartout.internal.unit

Examples of com.eclipsesource.tabris.passepartout.internal.unit.Percentage


    assertTrue( complies );
  }

  @Test
  public void testCompliesWithWidthSmallerThanMaxWidthPercentage() {
    MaxWidthCondition condition = new MaxWidthCondition( new Percentage( BigDecimal.valueOf( 50 ) ) );
    Bounds bounds = new Bounds( 10, 10, 100, 0 );
    Bounds referenceBounds = new Bounds( 10, 10, 200, 0 );

    boolean complies = condition.compliesWith( new UIEnvironmentImpl( bounds, referenceBounds, 16 ) );
View Full Code Here


    assertTrue( complies );
  }

  @Test
  public void testCompliesNotWithWidthBiggerThanMaxWidthPercentage() {
    MaxWidthCondition condition = new MaxWidthCondition( new Percentage( BigDecimal.valueOf( 40 ) ) );
    Bounds bounds = new Bounds( 10, 10, 100, 0 );
    Bounds referenceBounds = new Bounds( 10, 10, 200, 0 );

    boolean complies = condition.compliesWith( new UIEnvironmentImpl( bounds, referenceBounds, 16 ) );
View Full Code Here

    assertFalse( complies );
  }

  @Test
  public void testCompliesWithWidthBiggerThanMinWidthInPercentage() {
    MinWidthCondition condition = new MinWidthCondition( new Percentage( BigDecimal.valueOf( 10 ) ) );
    Bounds bounds = new Bounds( 10, 10, 11, 0 );
    Bounds referenceBounds = new Bounds( 10, 10, 100, 0 );

    boolean complies = condition.compliesWith( new UIEnvironmentImpl( bounds, referenceBounds, 16 ) );
View Full Code Here

    assertTrue( complies );
  }

  @Test
  public void testCompliesWithWidthSameThanMinWidthInPercentage() {
    MinWidthCondition condition = new MinWidthCondition( new Percentage( BigDecimal.valueOf( 10 ) ) );
    Bounds bounds = new Bounds( 10, 10, 10, 0 );
    Bounds referenceBounds = new Bounds( 10, 10, 100, 0 );

    boolean complies = condition.compliesWith( new UIEnvironmentImpl( bounds, referenceBounds, 16 ) );
View Full Code Here

    assertTrue( complies );
  }

  @Test
  public void testCompliesNotWithWidthSmallerThanMinWidthInPercentage() {
    MinWidthCondition condition = new MinWidthCondition( new Percentage( BigDecimal.valueOf( 10 ) ) );
    Bounds bounds = new Bounds( 10, 10, 9, 0 );
    Bounds referenceBounds = new Bounds( 10, 10, 100, 0 );

    boolean complies = condition.compliesWith( new UIEnvironmentImpl( bounds, referenceBounds, 16 ) );
View Full Code Here

    assertEquals( 80, bounds.getHeight() );
  }

  @Test
  public void testUsesPercentageToComputeMargins() {
    MarginInstruction instruction = new MarginInstruction( new Percentage( BigDecimal.valueOf( 10 ) ),
                                                                     new Percentage( BigDecimal.valueOf( 10 ) ),
                                                                     new Percentage( BigDecimal.valueOf( 10 ) ),
                                                                     new Percentage( BigDecimal.valueOf( 10 ) ) );

    Bounds bounds = instruction.computeBounds( new Bounds( 0, 0, 100, 100 ), 16 );

    assertEquals( 10, bounds.getX() );
    assertEquals( 10, bounds.getY() );
View Full Code Here

    assertEquals( 80, bounds.getHeight() );
  }

  @Test
  public void testUsesMixedUnitsToComputeMargins() {
    MarginInstruction instruction = new MarginInstruction( new Percentage( BigDecimal.valueOf( 10 ) ),
                                                                     new Em( BigDecimal.ONE ),
                                                                     new Percentage( BigDecimal.valueOf( 10 ) ),
                                                                     new Pixel( 10 ) );

    Bounds bounds = instruction.computeBounds( new Bounds( 0, 0, 100, 100 ), 10 );

    assertEquals( 10, bounds.getX() );
View Full Code Here

    assertEquals( 150, actualHeight );
  }

  @Test
  public void testCalculatesHeightWithPercentage() {
    HeightInstruction instruction = new HeightInstruction( new Percentage( BigDecimal.valueOf( 50 ) ) );

    int height = instruction.computeHeight( new Bounds( 0, 0, 100, 100 ), 16 );

    assertEquals( 50, height );
  }
View Full Code Here

    assertEquals( 50, height );
  }

  @Test
  public void testCalculatesHeightWithPercentageAndZeroParentBounds() {
    HeightInstruction instruction = new HeightInstruction( new Percentage( BigDecimal.valueOf( 50 ) ) );

    int height = instruction.computeHeight( new Bounds( 0, 0, 0, 0 ), 16 );

    assertEquals( 0, height );
  }
View Full Code Here

public class UnitUtilTest {

  @Test
  public void testCalculatesPercentage() {
    int pixel = UnitUtil.percentageToPixel( new Percentage( BigDecimal.TEN ), 100 );

    assertEquals( 10, pixel );
  }
View Full Code Here

TOP

Related Classes of com.eclipsesource.tabris.passepartout.internal.unit.Percentage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.