|
1 | 1 | package com.itextpdf.layout;
|
2 | 2 |
|
3 |
| -import com.itextpdf.kernel.geom.PageSize; |
| 3 | +import com.itextpdf.io.LogMessageConstant; |
4 | 4 | import com.itextpdf.kernel.color.Color;
|
| 5 | +import com.itextpdf.kernel.geom.PageSize; |
5 | 6 | import com.itextpdf.kernel.pdf.PdfDocument;
|
6 | 7 | import com.itextpdf.kernel.pdf.PdfWriter;
|
7 | 8 | import com.itextpdf.kernel.utils.CompareTool;
|
8 |
| -import com.itextpdf.test.annotations.type.IntegrationTest; |
| 9 | +import com.itextpdf.layout.border.SolidBorder; |
9 | 10 | import com.itextpdf.layout.element.AreaBreak;
|
10 | 11 | import com.itextpdf.layout.element.Paragraph;
|
11 | 12 | import com.itextpdf.layout.element.Text;
|
12 | 13 | import com.itextpdf.test.ExtendedITextTest;
|
13 |
| - |
| 14 | +import com.itextpdf.test.annotations.LogMessage; |
| 15 | +import com.itextpdf.test.annotations.LogMessages; |
| 16 | +import com.itextpdf.test.annotations.type.IntegrationTest; |
14 | 17 |
|
15 | 18 | import java.io.FileOutputStream;
|
16 | 19 | import java.io.IOException;
|
17 | 20 |
|
18 | 21 | import org.junit.Assert;
|
19 | 22 | import org.junit.BeforeClass;
|
| 23 | +import org.junit.Ignore; |
20 | 24 | import org.junit.Test;
|
21 | 25 | import org.junit.experimental.categories.Category;
|
22 | 26 |
|
@@ -66,4 +70,63 @@ public void rendererTest01() throws IOException, InterruptedException {
|
66 | 70 | Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
|
67 | 71 | }
|
68 | 72 |
|
| 73 | + @Test |
| 74 | + @LogMessages(messages = { |
| 75 | + @LogMessage(messageTemplate = LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES) |
| 76 | + }) |
| 77 | + public void emptyParagraphsTest01() throws IOException, InterruptedException { |
| 78 | + String outFileName = destinationFolder + "emptyParagraphsTest01.pdf"; |
| 79 | + String cmpFileName = sourceFolder + "cmp_emptyParagraphsTest01.pdf"; |
| 80 | + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileOutputStream(outFileName))); |
| 81 | + |
| 82 | + Document document = new Document(pdfDocument); |
| 83 | + |
| 84 | + // the next 3 lines should not cause any effect |
| 85 | + document.add(new Paragraph()); |
| 86 | + document.add(new Paragraph().setBackgroundColor(Color.GREEN)); |
| 87 | + document.add(new Paragraph().setBorder(new SolidBorder(Color.BLUE, 3))); |
| 88 | + |
| 89 | + document.add(new Paragraph("Hello! I'm the first paragraph added to the document. Am i right?")); |
| 90 | + document.add(new Paragraph().setHeight(50)); |
| 91 | + document.add(new Paragraph("Hello! I'm the second paragraph added to the document. Am i right?")); |
| 92 | + |
| 93 | + document.close(); |
| 94 | + |
| 95 | + Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); |
| 96 | + } |
| 97 | + |
| 98 | + @Test |
| 99 | + @Ignore |
| 100 | + public void emptyParagraphsTest02() throws IOException, InterruptedException { |
| 101 | + String outFileName = destinationFolder + "emptyParagraphsTest02.pdf"; |
| 102 | + String cmpFileName = sourceFolder + "cmp_emptyParagraphsTest02.pdf"; |
| 103 | + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileOutputStream(outFileName))); |
| 104 | + |
| 105 | + Document document = new Document(pdfDocument); |
| 106 | + |
| 107 | + document.add(new Paragraph("\n\n\n")); |
| 108 | + document.add(new Paragraph("a\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nb\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nc\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nd\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ne")); |
| 109 | + |
| 110 | + document.close(); |
| 111 | + |
| 112 | + Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + @Ignore |
| 117 | + public void emptyParagraphsTest03() throws IOException, InterruptedException { |
| 118 | + String outFileName = destinationFolder + "emptyParagraphsTest03.pdf"; |
| 119 | +// String cmpFileName = sourceFolder + "cmp_emptyParagraphsTest03.pdf"; |
| 120 | + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileOutputStream(outFileName))); |
| 121 | + |
| 122 | + Document document = new Document(pdfDocument); |
| 123 | + |
| 124 | + document.add(new Paragraph("c\nb")); |
| 125 | +// document.add(new Paragraph("a a\nb")); |
| 126 | + |
| 127 | + document.close(); |
| 128 | + |
| 129 | +// Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); |
| 130 | + } |
| 131 | + |
69 | 132 | }
|
0 commit comments