|
| 1 | +package com.itextpdf.layout.renderer; |
| 2 | + |
| 3 | +import com.itextpdf.kernel.geom.Rectangle; |
| 4 | +import com.itextpdf.layout.element.Div; |
| 5 | +import com.itextpdf.layout.layout.LayoutArea; |
| 6 | +import com.itextpdf.layout.property.OverflowPropertyValue; |
| 7 | +import com.itextpdf.layout.property.UnitValue; |
| 8 | +import com.itextpdf.test.ExtendedITextTest; |
| 9 | +import com.itextpdf.test.annotations.type.IntegrationTest; |
| 10 | + |
| 11 | +import org.junit.Assert; |
| 12 | +import org.junit.Test; |
| 13 | +import org.junit.experimental.categories.Category; |
| 14 | + |
| 15 | +@Category(IntegrationTest.class) |
| 16 | +public class BlockRendererTest extends ExtendedITextTest { |
| 17 | + |
| 18 | + @Test |
| 19 | + public void applyMinHeightForSpecificDimensionsCausingFloatPrecisionError () { |
| 20 | + float divHeight = 42.55f; |
| 21 | + |
| 22 | + Div div = new Div(); |
| 23 | + div.setHeight(UnitValue.createPointValue(divHeight)); |
| 24 | + |
| 25 | + float occupiedHeight = 17.981995f; |
| 26 | + float leftHeight = 24.567993f; |
| 27 | + |
| 28 | + Assert.assertTrue(occupiedHeight + leftHeight < divHeight); |
| 29 | + |
| 30 | + BlockRenderer blockRenderer = (BlockRenderer) div.createRendererSubTree(); |
| 31 | + blockRenderer.occupiedArea = new LayoutArea(1, new Rectangle(0, 267.9681f, 0, occupiedHeight)); |
| 32 | + AbstractRenderer renderer = blockRenderer.applyMinHeight(OverflowPropertyValue.FIT, |
| 33 | + new Rectangle(0, 243.40012f, 0, leftHeight)); |
| 34 | + Assert.assertNull(renderer); |
| 35 | + } |
| 36 | +} |
0 commit comments