Package org.docx4j.openpackaging.parts.WordprocessingML

Source Code of org.docx4j.openpackaging.parts.WordprocessingML.CxCyTest

package org.docx4j.openpackaging.parts.WordprocessingML;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.CxCy;
import org.junit.Test;


public class CxCyTest {
   
    @Test
    public void shouldNotResizeSmaller() {
//        calculate(10, 10, 10, 10, 10, 10);
        calculate(10, 10, 20, 20, 10, 10);
       
        calculate(30, 10, 20, 20, 20, 7);
        calculate(10, 30, 20, 20, 7, 20);
       
        calculate(20, 20, 10, 10, 10, 10);
       
        calculate(20, 20, 30, 10, 10, 10);
        calculate(20, 20, 10, 30, 10, 10);

        calculate(10, 30, 30, 10, 3, 10);
    }
    private void calculate(double imageWidth, double imageHeight, int slideWidth, int slideHeight, double expectedWidth, double expectedHeight) {
        // given
       
        // when
        CxCy scale = CxCy.scaleToFit(imageWidth, imageHeight, slideWidth, slideHeight);
       
        // then
        assertThat(scale.getCx(), is((long)expectedWidth));
        assertThat(scale.getCy(), is((long)expectedHeight));
    }

}
TOP

Related Classes of org.docx4j.openpackaging.parts.WordprocessingML.CxCyTest

TOP
Copyright © 2018 www.massapi.com. 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.