Skip to content

Commit d8e7ba9

Browse files
ars18wrwitext-teamcity
authored andcommitted
Add tests which introduce some new bugs related to table borders.
Autoported commit. Original commit hash: [2d6661306]
1 parent df4f56d commit d8e7ba9

File tree

4 files changed

+101
-1
lines changed

4 files changed

+101
-1
lines changed

itext.tests/itext.layout.tests/itext/layout/TableBorderTest.cs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,29 @@ public virtual void SplitCellsTest04() {
702702
CloseDocumentAndCompareOutputs(doc);
703703
}
704704

705+
/// <exception cref="System.IO.IOException"/>
706+
/// <exception cref="System.Exception"/>
707+
[NUnit.Framework.Test]
708+
[NUnit.Framework.Ignore("DEVSIX-1734")]
709+
public virtual void SplitCellsTest04A() {
710+
fileName = "splitCellsTest04A.pdf";
711+
Document doc = CreateDocument();
712+
doc.GetPdfDocument().SetDefaultPageSize(new PageSize(595, 80 + 72));
713+
String text = "When a man hath no freedom to fight for at home,\n" + " Let him combat for that of his neighbours;\n"
714+
+ "Let him think of the glories of Greece and of Rome,\n" + " And get knocked on the head for his labours.\n"
715+
+ "A\n" + "B\n" + "C\n" + "D";
716+
Table table = new Table(UnitValue.CreatePercentArray(1)).UseAllAvailableWidth();
717+
Cell cell;
718+
cell = new Cell().Add(new Paragraph(text));
719+
cell.SetBorderBottom(new SolidBorder(ColorConstants.RED, 20));
720+
cell.SetBorderTop(new SolidBorder(ColorConstants.GREEN, 20));
721+
table.AddCell(cell);
722+
table.AddFooterCell(new Cell().Add(new Paragraph("Footer")).SetBorderTop(new SolidBorder(ColorConstants.YELLOW
723+
, 20)));
724+
doc.Add(table);
725+
CloseDocumentAndCompareOutputs(doc);
726+
}
727+
705728
/// <exception cref="System.IO.IOException"/>
706729
/// <exception cref="System.Exception"/>
707730
[NUnit.Framework.Test]
@@ -832,6 +855,52 @@ public virtual void SplitCellsTest10() {
832855
CloseDocumentAndCompareOutputs(doc);
833856
}
834857

858+
/// <exception cref="System.IO.IOException"/>
859+
/// <exception cref="System.Exception"/>
860+
[NUnit.Framework.Test]
861+
public virtual void SplitCellsTest10A() {
862+
// TODO DEVSIX-1735
863+
fileName = "splitCellsTest10A.pdf";
864+
Document doc = CreateDocument();
865+
doc.GetPdfDocument().SetDefaultPageSize(new PageSize(130, 140));
866+
String textAlphabet = "Cell";
867+
Table table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth().SetWidth(UnitValue.CreatePercentValue
868+
(100)).SetFixedLayout();
869+
table.AddCell(new Cell().Add(new Paragraph(textAlphabet + "1")).SetBackgroundColor(ColorConstants.YELLOW));
870+
table.AddCell(new Cell(2, 1).Add(new Paragraph(textAlphabet + "222222222")).SetBackgroundColor(ColorConstants
871+
.YELLOW));
872+
table.AddCell(new Cell().Add(new Paragraph(textAlphabet + "3")).SetBackgroundColor(ColorConstants.YELLOW));
873+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.YELLOW).Add(new Paragraph(textAlphabet + "4")).
874+
SetKeepTogether(true));
875+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.YELLOW).Add(new Paragraph(textAlphabet + "5")).
876+
SetKeepTogether(true));
877+
doc.Add(table);
878+
CloseDocumentAndCompareOutputs(doc);
879+
}
880+
881+
/// <exception cref="System.IO.IOException"/>
882+
/// <exception cref="System.Exception"/>
883+
[NUnit.Framework.Test]
884+
[NUnit.Framework.Ignore("DEVSIX-1736")]
885+
public virtual void SplitCellsTest10B() {
886+
fileName = "splitCellsTest10B.pdf";
887+
Document doc = CreateDocument();
888+
doc.GetPdfDocument().SetDefaultPageSize(new PageSize(130, 110));
889+
String textAlphabet = "Cell";
890+
Table table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth().SetWidth(UnitValue.CreatePercentValue
891+
(100)).SetFixedLayout();
892+
table.AddCell(new Cell().Add(new Paragraph(textAlphabet + "1")).SetBackgroundColor(ColorConstants.YELLOW));
893+
table.AddCell(new Cell(2, 1).Add(new Paragraph(textAlphabet + "222222222")).SetBackgroundColor(ColorConstants
894+
.YELLOW));
895+
table.AddCell(new Cell().Add(new Paragraph(textAlphabet + "3")).SetBackgroundColor(ColorConstants.YELLOW));
896+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.YELLOW).Add(new Paragraph(textAlphabet + "4")).
897+
SetKeepTogether(true));
898+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.YELLOW).Add(new Paragraph(textAlphabet + "5")).
899+
SetKeepTogether(true));
900+
doc.Add(table);
901+
CloseDocumentAndCompareOutputs(doc);
902+
}
903+
835904
/// <exception cref="System.IO.IOException"/>
836905
/// <exception cref="System.Exception"/>
837906
[NUnit.Framework.Test]
@@ -1187,6 +1256,37 @@ public virtual void TableWithHeaderFooterTest11() {
11871256
, testName + "_diff"));
11881257
}
11891258

1259+
/// <exception cref="System.IO.IOException"/>
1260+
/// <exception cref="System.Exception"/>
1261+
[NUnit.Framework.Test]
1262+
public virtual void TableWithHeaderFooterTest11A() {
1263+
// TODO DEVSIX-1737
1264+
String testName = "tableWithHeaderFooterTest11A.pdf";
1265+
String outFileName = destinationFolder + testName;
1266+
String cmpFileName = sourceFolder + "cmp_" + testName;
1267+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
1268+
Document doc = new Document(pdfDoc);
1269+
Table table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth();
1270+
table.SetBorder(new SolidBorder(90));
1271+
table.AddFooterCell(new Cell(1, 3).SetHeight(150).Add(new Paragraph("Footer")));
1272+
table.AddHeaderCell(new Cell(1, 3).SetHeight(30).Add(new Paragraph("Header")));
1273+
for (int i = 0; i < 11; i++) {
1274+
table.AddCell(new Cell().Add(new Paragraph(i + ": Bazz :")).SetBorder(new SolidBorder(ColorConstants.BLACK
1275+
, 10)));
1276+
table.AddCell(new Cell().Add(new Paragraph("To infinity")).SetBorder(new SolidBorder(ColorConstants.YELLOW
1277+
, 30)));
1278+
table.AddCell(new Cell().Add(new Paragraph(" and beyond!")).SetBorder(new SolidBorder(ColorConstants.RED,
1279+
20)));
1280+
}
1281+
table.SetSkipLastFooter(true);
1282+
doc.Add(table);
1283+
doc.Add(new Table(UnitValue.CreatePercentArray(1)).UseAllAvailableWidth().SetBorder(new SolidBorder(ColorConstants
1284+
.ORANGE, 2)).AddCell("Is my occupied area correct?"));
1285+
doc.Close();
1286+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
1287+
, testName + "_diff"));
1288+
}
1289+
11901290
/// <exception cref="System.IO.IOException"/>
11911291
/// <exception cref="System.Exception"/>
11921292
[NUnit.Framework.Test]
Binary file not shown.

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4ec0044c1e2a1027658ec01d0775165f9d52c9ae
1+
2d666130660cb73d6689051dc55e98e46ae8cb83

0 commit comments

Comments
 (0)