Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Apr 17, 2024
2 parents fa2a742 + 4b105e0 commit e992dd0
Show file tree
Hide file tree
Showing 52 changed files with 717 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using iText.Commons.Actions.Contexts;
using iText.Test;

namespace iText.Kernel.Pdf {
[NUnit.Framework.Category("UnitTest")]
public class DocumentPropertiesUnitTest : ExtendedITextTest {
[NUnit.Framework.Test]
public virtual void SetEventCountingMetaInfoTest() {
DocumentProperties documentProperties = new DocumentProperties();
documentProperties.SetEventCountingMetaInfo(new DocumentPropertiesUnitTest.TestMetaInfo());
NUnit.Framework.Assert.IsTrue(documentProperties.IsEventCountingMetaInfoSet());
}

[NUnit.Framework.Test]
public virtual void MetaInfoIsNotSetTest() {
DocumentProperties documentProperties = new DocumentProperties();
NUnit.Framework.Assert.IsFalse(documentProperties.IsEventCountingMetaInfoSet());
}

private class TestMetaInfo : IMetaInfo {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ public virtual void ShouldTableElementBeCopiedTdTdTest() {
public virtual void ShouldTableElementBeCopiedTrTdTest() {
PdfDictionary obj = new PdfDictionary(tr);
PdfDictionary parent = new PdfDictionary(td);
NUnit.Framework.Assert.IsFalse(StructureTreeCopier.ShouldTableElementBeCopied(obj, parent));
NUnit.Framework.Assert.IsTrue(StructureTreeCopier.ShouldTableElementBeCopied(obj, parent));
}

[NUnit.Framework.Test]
public virtual void ShouldTableElementBeCopiedTrTrTest() {
PdfDictionary obj = new PdfDictionary(tr);
PdfDictionary parent = new PdfDictionary(tr);
NUnit.Framework.Assert.IsFalse(StructureTreeCopier.ShouldTableElementBeCopied(obj, parent));
NUnit.Framework.Assert.IsTrue(StructureTreeCopier.ShouldTableElementBeCopied(obj, parent));
}

[NUnit.Framework.Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,72 @@ public virtual void TdInsideTdTableTest() {

[NUnit.Framework.Test]
public virtual void EmptyTrTableTest() {
// TODO DEVSIX-5974 Empty tr isn't copied.
MergeAndCompareTagStructures("emptyTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void SplitEmptyTrTableFirstPageTest() {
MergeAndCompareTagStructures("splitTableWithEmptyTrFirstPage.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void SplitEmptyTrTableSecondPageTest() {
MergeAndCompareTagStructures("splitTableWithEmptyTrSecondPage.pdf", 2, 2);
}

[NUnit.Framework.Test]
public virtual void SplitEmptyTrTableFullTest() {
MergeAndCompareTagStructures("splitTableWithEmptyTrFull.pdf", 1, 2);
}

[NUnit.Framework.Test]
public virtual void EmptyFirstTrTableTest() {
MergeAndCompareTagStructures("emptyFirstTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void EmptyLastTrTableTest() {
MergeAndCompareTagStructures("emptyLastTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void EmptyTwoAdjacentTrTableTest() {
MergeAndCompareTagStructures("emptyTwoAdjacentTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void EmptyAllTrTableTest() {
MergeAndCompareTagStructures("emptyAllTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void EmptySingleTrTableTest() {
MergeAndCompareTagStructures("emptySingleTrTable.pdf", 1, 1);
}

[NUnit.Framework.Test]
public virtual void SplitAndMergeEmptyTrTableTest() {
String sourceFilename = sourceFolder + "splitTableWithEmptyTrFull.pdf";
String firstPageFilename = destinationFolder + "firstPageDoc.pdf";
String secondPageFilename = destinationFolder + "secondPageDoc.pdf";
String resultFilename = destinationFolder + "splitAndMergeEmptyTrTable.pdf";
String cmpFilename = sourceFolder + "cmp_splitAndMergeEmptyTrTable.pdf";
PdfDocument sourceDoc = new PdfDocument(new PdfReader(sourceFilename));
PdfDocument firstPageDoc = new PdfDocument(new PdfWriter(firstPageFilename));
PdfMerger mergerFirstPage = new PdfMerger(firstPageDoc);
mergerFirstPage.Merge(sourceDoc, 1, 1);
mergerFirstPage.Close();
PdfDocument secondPageDoc = new PdfDocument(new PdfWriter(secondPageFilename));
PdfMerger mergerSecondPage = new PdfMerger(secondPageDoc);
mergerSecondPage.Merge(sourceDoc, 2, 2);
mergerSecondPage.Close();
IList<FileInfo> sources = new List<FileInfo>();
sources.Add(new FileInfo(firstPageFilename));
sources.Add(new FileInfo(secondPageFilename));
MergePdfs(sources, resultFilename, new PdfMergerProperties(), false);
NUnit.Framework.Assert.IsNull(new CompareTool().CompareTagStructures(resultFilename, cmpFilename));
}

[NUnit.Framework.Test]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.NAME_ALREADY_EXISTS_IN_THE_NAME_TREE, Count = 2)]
public virtual void MergeOutlinesNamedDestinations() {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 21 additions & 9 deletions itext.tests/itext.layout.tests/itext/layout/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,6 @@ public virtual void TableWithEmptyLastRowTest() {
}

[NUnit.Framework.Test]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING)]
public virtual void TableWithEmptyRowsBetweenFullRowsTest() {
String testName = "tableWithEmptyRowsBetweenFullRowsTest.pdf";
String outFileName = destinationFolder + testName;
Expand All @@ -1716,8 +1715,6 @@ public virtual void TableWithEmptyRowsBetweenFullRowsTest() {
}

[NUnit.Framework.Test]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING, Count = 2
)]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.LAST_ROW_IS_NOT_COMPLETE)]
public virtual void TableWithEmptyRowAfterJustOneCellTest() {
String testName = "tableWithEmptyRowAfterJustOneCellTest.pdf";
Expand All @@ -1739,8 +1736,6 @@ public virtual void TableWithEmptyRowAfterJustOneCellTest() {
}

[NUnit.Framework.Test]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING, Count = 39
)]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.LAST_ROW_IS_NOT_COMPLETE)]
public virtual void TableWithAlternatingRowsTest() {
String testName = "tableWithAlternatingRowsTest.pdf";
Expand Down Expand Up @@ -1782,8 +1777,27 @@ public virtual void ColoredTableWithColoredCellsTest() {
}

[NUnit.Framework.Test]
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING, Count = 2
)]
public virtual void TableWithEmptyRowsAndSpansTest() {
String testName = "tableWithEmptyRowsAndSpansTest.pdf";
String outFileName = destinationFolder + testName;
String cmpFileName = sourceFolder + "cmp_" + testName;
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
Document doc = new Document(pdfDoc);
Table table = new Table(UnitValue.CreatePercentArray(new float[] { 30, 30, 30 }));
table.AddCell(new Cell().Add(new Paragraph("Hello")));
table.AddCell(new Cell().Add(new Paragraph("Lovely")));
table.AddCell(new Cell().Add(new Paragraph("World")));
StartSeveralEmptyRows(table);
table.AddCell(new Cell(2, 2).Add(new Paragraph("Hello")));
table.AddCell(new Cell().Add(new Paragraph("Lovely")));
table.AddCell(new Cell().Add(new Paragraph("World")));
doc.Add(table);
doc.Close();
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
, testName + "_diff"));
}

[NUnit.Framework.Test]
public virtual void TableWithEmptyRowsAndSeparatedBordersTest() {
String testName = "tableWithEmptyRowsAndSeparatedBordersTest.pdf";
String outFileName = destinationFolder + testName;
Expand All @@ -1804,8 +1818,6 @@ public virtual void TableWithEmptyRowsAndSeparatedBordersTest() {
}

[NUnit.Framework.Test]
// TODO DEVSIX-6020:Border-collapsing doesn't work in case startNewRow has been called
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING)]
public virtual void TableWithCollapsedBordersTest() {
String testName = "tableWithCollapsedBordersTest.pdf";
String outFileName = destinationFolder + testName;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e992dd0

Please sign in to comment.