Skip to content

Commit b815a31

Browse files
vitali-priText-CI
authored andcommitted
Create an automated test for rectangles drawn with zero-width line
The test contans wrong cmp file. It must be replaced after the bug is fixed. DEVSIX-7136 Autoported commit. Original commit hash: [71b02a0]
1 parent 5aa744c commit b815a31

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.IO;
3+
using iText.Kernel.Colors;
4+
using iText.Kernel.Geom;
5+
using iText.Kernel.Pdf;
6+
using iText.Kernel.Pdf.Canvas;
7+
using iText.Kernel.Utils;
8+
using iText.Test;
9+
10+
namespace iText.PdfCleanup {
11+
[NUnit.Framework.Category("Integration test")]
12+
public class RectangleTest : ExtendedITextTest {
13+
private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
14+
.CurrentContext.TestDirectory) + "/resources/itext/pdfcleanup/RectangleTest/";
15+
16+
private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
17+
+ "/test/itext/pdfcleanup/RectangleTest/";
18+
19+
[NUnit.Framework.OneTimeSetUp]
20+
public static void BeforeClass() {
21+
CreateDestinationFolder(DESTINATION_FOLDER);
22+
}
23+
24+
[NUnit.Framework.Test]
25+
public virtual void ZeroWidthLineTest() {
26+
// TODO DEVSIX-7136 Rectangles drawn with zero-width line disappear on sweeping
27+
String outPdf = DESTINATION_FOLDER + "zeroWidthLine.pdf";
28+
String cmpPdf = SOURCE_FOLDER + "cmp_zeroWidthLine.pdf";
29+
MemoryStream outDocBaos = new MemoryStream();
30+
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outDocBaos))) {
31+
PdfPage page = pdfDocument.AddNewPage();
32+
PdfCanvas canvas = new PdfCanvas(page);
33+
canvas.SetStrokeColor(DeviceRgb.BLUE).SetLineWidth(0).Rectangle(new Rectangle(350, 400, 100, 100)).Stroke(
34+
);
35+
canvas.SetStrokeColor(DeviceRgb.RED).SetLineWidth(0).MoveTo(100, 100).LineTo(100, 200).LineTo(200, 200).LineTo
36+
(200, 100).ClosePath().Stroke();
37+
}
38+
PdfDocument pdfDocument_1 = new PdfDocument(new PdfReader(new MemoryStream(outDocBaos.ToArray())), new PdfWriter
39+
(outPdf));
40+
iText.PdfCleanup.PdfCleanUpTool workingTool = new iText.PdfCleanup.PdfCleanUpTool(pdfDocument_1);
41+
Rectangle area = new Rectangle(0, 50, 150, 150);
42+
workingTool.AddCleanupLocation(new iText.PdfCleanup.PdfCleanUpLocation(1, area, ColorConstants.RED));
43+
workingTool.CleanUp();
44+
pdfDocument_1.Close();
45+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"
46+
));
47+
}
48+
}
49+
}
Binary file not shown.

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a4dca4b65397e057b6074bafc1364fbccd27a4c5
1+
71b02a0eff454c35950520b27be77c57f9096e15

0 commit comments

Comments
 (0)