Package com.eclipsesource.tabris.passepartout.internal.instruction

Examples of com.eclipsesource.tabris.passepartout.internal.instruction.MarginInstruction


public class MarginInstructionTest {

  @Test( expected = IllegalArgumentException.class )
  public void testFailsWithNullTop() {
    new MarginInstruction( null, mock( Unit.class ), mock( Unit.class ), mock( Unit.class ) );
  }
View Full Code Here


    new MarginInstruction( null, mock( Unit.class ), mock( Unit.class ), mock( Unit.class ) );
  }

  @Test( expected = IllegalArgumentException.class )
  public void testFailsWithNullRight() {
    new MarginInstruction( mock( Unit.class ), null, mock( Unit.class ), mock( Unit.class ) );
  }
View Full Code Here

    new MarginInstruction( mock( Unit.class ), null, mock( Unit.class ), mock( Unit.class ) );
  }

  @Test( expected = IllegalArgumentException.class )
  public void testFailsWithNullBottom() {
    new MarginInstruction( mock( Unit.class ), mock( Unit.class ), null, mock( Unit.class ) );
  }
View Full Code Here

    new MarginInstruction( mock( Unit.class ), mock( Unit.class ), null, mock( Unit.class ) );
  }

  @Test( expected = IllegalArgumentException.class )
  public void testFailsWithNullLeft() {
    new MarginInstruction( mock( Unit.class ), mock( Unit.class ), mock( Unit.class ), null );
  }
View Full Code Here

    new MarginInstruction( mock( Unit.class ), mock( Unit.class ), mock( Unit.class ), null );
  }

  @Test
  public void testUsesOriginalBoundsWithUnsupportedUnit() {
    MarginInstruction instruction = new MarginInstruction( mock( Unit.class ),
                                                                     mock( Unit.class ),
                                                                     mock( Unit.class ),
                                                                     mock( Unit.class ) );

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

    assertEquals( 0, bounds.getX() );
    assertEquals( 0, bounds.getY() );
    assertEquals( 100, bounds.getWidth() );
    assertEquals( 100, bounds.getHeight() );
View Full Code Here

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

  @Test
  public void testUsesPixelToComputeMargins() {
    MarginInstruction instruction = new MarginInstruction( new Pixel( 5 ),
                                                                     new Pixel( 5 ),
                                                                     new Pixel( 5 ),
                                                                     new Pixel( 5 ) );

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

    assertEquals( 5, bounds.getX() );
    assertEquals( 5, bounds.getY() );
    assertEquals( 90, bounds.getWidth() );
    assertEquals( 90, bounds.getHeight() );
View Full Code Here

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

  @Test
  public void testUsesEmToComputeMargins() {
    MarginInstruction instruction = new MarginInstruction( new Em( BigDecimal.ONE ),
                                                                     new Em( BigDecimal.ONE ),
                                                                     new Em( BigDecimal.ONE ),
                                                                     new Em( BigDecimal.ONE ) );

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

    assertEquals( 10, bounds.getX() );
    assertEquals( 10, bounds.getY() );
    assertEquals( 80, bounds.getWidth() );
    assertEquals( 80, bounds.getHeight() );
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() );
    assertEquals( 80, bounds.getWidth() );
    assertEquals( 80, bounds.getHeight() );
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() );
    assertEquals( 10, bounds.getY() );
    assertEquals( 80, bounds.getWidth() );
    assertEquals( 80, bounds.getHeight() );
View Full Code Here

  @Test
  public void testComputesBoundsWithMarginInstrutions() {
    Layouter layouter = new Layouter( createEnvironment( new Bounds( 0, 0, 600, 200 ) ), createConfig() );
    ArrayList<Instruction> instructions = new ArrayList<Instruction>();
    instructions.add( new MarginInstruction( px( 5 ), px( 10 ), px( 20 ), px( 30 ) ) );

    Bounds bounds = layouter.computeBounds( new Bounds( 0, 0, 100, 100 ), instructions );

    assertEquals( new Bounds( 30, 5, 110, 75 ), bounds );
  }
View Full Code Here

TOP

Related Classes of com.eclipsesource.tabris.passepartout.internal.instruction.MarginInstruction

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.