Skip to content

Commit 248b08b

Browse files
Evgeniy PrudnikoviText-CI
authored andcommitted
Add ticket number and tests for the corresponding TODOs
DEVSIX-6453 Autoported commit. Original commit hash: [c5c3c19e8]
1 parent 0e9ba65 commit 248b08b

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

itext.tests/itext.layout.tests/itext/layout/renderer/BlockRendererTest.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,33 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
23+
using System;
24+
using iText.Kernel.Colors;
2325
using iText.Kernel.Geom;
26+
using iText.Kernel.Pdf;
27+
using iText.Kernel.Utils;
28+
using iText.Layout;
2429
using iText.Layout.Element;
2530
using iText.Layout.Layout;
2631
using iText.Layout.Properties;
2732
using iText.Test;
33+
using iText.Test.Attributes;
2834

2935
namespace iText.Layout.Renderer {
3036
public class BlockRendererTest : ExtendedITextTest {
37+
public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
38+
.CurrentContext.TestDirectory) + "/resources/itext/layout/BlockRendererTest/";
39+
40+
public static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
41+
+ "/test/itext/layout/BlockRendererTest/";
42+
43+
[NUnit.Framework.OneTimeSetUp]
44+
public static void BeforeClass() {
45+
CreateOrClearDestinationFolder(DESTINATION_FOLDER);
46+
}
47+
3148
[NUnit.Framework.Test]
32-
public virtual void ApplyMinHeightForSpecificDimensionsCausingFloatPrecisionError() {
49+
public virtual void ApplyMinHeightForSpecificDimensionsCausingFloatPrecisionErrorTest() {
3350
float divHeight = 42.55f;
3451
Div div = new Div();
3552
div.SetHeight(UnitValue.CreatePointValue(divHeight));
@@ -42,5 +59,35 @@ public virtual void ApplyMinHeightForSpecificDimensionsCausingFloatPrecisionErro
4259
, 0, leftHeight));
4360
NUnit.Framework.Assert.IsNull(renderer);
4461
}
62+
63+
[NUnit.Framework.Test]
64+
[LogMessage(iText.IO.Logs.IoLogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, Count = 2, LogLevel
65+
= LogLevelConstants.ERROR)]
66+
public virtual void ParentBoxWrapAroundChildBoxesTest() {
67+
// TODO DEVSIX-6488 all elements should be layouted first in case when parent box should wrap around child boxes
68+
String cmpFileName = SOURCE_FOLDER + "cmp_parentBoxWrapAroundChildBoxes.pdf";
69+
String outFile = DESTINATION_FOLDER + "parentBoxWrapAroundChildBoxes.pdf";
70+
int enoughDivsToOccupyWholePage = 30;
71+
Document document = new Document(new PdfDocument(new PdfWriter(outFile)));
72+
Div div = new Div();
73+
div.SetBackgroundColor(ColorConstants.CYAN);
74+
div.SetProperty(Property.POSITION, LayoutPosition.ABSOLUTE);
75+
Div childDiv = new Div();
76+
childDiv.Add(new Paragraph("ChildDiv"));
77+
childDiv.SetBackgroundColor(ColorConstants.YELLOW);
78+
childDiv.SetWidth(100);
79+
for (int i = 0; enoughDivsToOccupyWholePage > i; i++) {
80+
div.Add(childDiv);
81+
}
82+
Div divThatDoesntFitButItsWidthShouldBeConsidered = new Div();
83+
divThatDoesntFitButItsWidthShouldBeConsidered.Add(new Paragraph("ChildDiv1"));
84+
divThatDoesntFitButItsWidthShouldBeConsidered.SetBackgroundColor(ColorConstants.GREEN);
85+
divThatDoesntFitButItsWidthShouldBeConsidered.SetWidth(200);
86+
div.Add(divThatDoesntFitButItsWidthShouldBeConsidered);
87+
document.Add(div);
88+
document.Close();
89+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFileName, DESTINATION_FOLDER)
90+
);
91+
}
4592
}
4693
}

itext/itext.layout/itext/layout/renderer/BlockRenderer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
239239
FloatingHelper.IncludeChildFloatsInOccupiedArea(floatRendererAreas, this, nonChildFloatingRendererAreas);
240240
FixOccupiedAreaIfOverflowedX(overflowX, layoutBox);
241241
if (result.GetSplitRenderer() != null) {
242-
// Use occupied area's bbox width so that for absolutely positioned renderers we do not align using full width
243-
// in case when parent box should wrap around child boxes.
244-
// TODO in the latter case, all elements should be layouted first so that we know maximum width needed to place all children and then apply horizontal alignment
242+
// TODO DEVSIX-6488 all elements should be layouted first in case when parent box should wrap around child boxes
245243
AlignChildHorizontally(result.GetSplitRenderer(), occupiedArea.GetBBox());
246244
}
247245
// Save the first renderer to produce LayoutResult.NOTHING
@@ -296,9 +294,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
296294
if (result.GetStatus() == LayoutResult.FULL) {
297295
DecreaseLayoutBoxAfterChildPlacement(layoutBox, result, childRenderer);
298296
if (childRenderer.GetOccupiedArea() != null) {
299-
// Use occupied area's bbox width so that for absolutely positioned renderers we do not align using full width
300-
// in case when parent box should wrap around child boxes.
301-
// TODO in the latter case, all elements should be layouted first so that we know maximum width needed to place all children and then apply horizontal alignment
297+
// TODO DEVSIX-6488 all elements should be layouted first in case when parent box should wrap around child boxes
302298
AlignChildHorizontally(childRenderer, occupiedArea.GetBBox());
303299
}
304300
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9f10d145c03f6cdc3328431d5efb0d360738f703
1+
c5c3c19e8a28347e933a571ceca3dc2c711f5624

0 commit comments

Comments
 (0)