Skip to content

Commit 4be2456

Browse files
yulian-gaponenkoiText-CI
authored andcommitted
Move tests for flattening of rotated fields to a separate class
DEVSIX-1741 Autoported commit. Original commit hash: [9842aa398]
1 parent 114ec43 commit 4be2456

File tree

35 files changed

+93
-89
lines changed

35 files changed

+93
-89
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2018 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using System;
44+
using iText.Forms.Fields;
45+
using iText.IO.Util;
46+
using iText.Kernel.Pdf;
47+
using iText.Kernel.Utils;
48+
using iText.Test;
49+
50+
namespace iText.Forms {
51+
public class FlatteningRotatedTest : ExtendedITextTest {
52+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
53+
.CurrentContext.TestDirectory) + "/resources/itext/forms/FlatteningRotatedTest/";
54+
55+
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
56+
+ "/test/itext/forms/FlatteningRotatedTest/";
57+
58+
[NUnit.Framework.OneTimeSetUp]
59+
public static void BeforeClass() {
60+
CreateOrClearDestinationFolder(destinationFolder);
61+
}
62+
63+
/// <exception cref="System.IO.IOException"/>
64+
/// <exception cref="System.Exception"/>
65+
[NUnit.Framework.Test]
66+
public virtual void FormFlatteningTest_DefaultAppearanceGeneration_Rot() {
67+
String srcFilePatternPattern = "FormFlatteningDefaultAppearance_{0}_";
68+
String destPatternPattern = "FormFlatteningDefaultAppearance_{0}_";
69+
String[] rotAngle = new String[] { "0", "90", "180", "270" };
70+
foreach (String angle in rotAngle) {
71+
String srcFilePattern = MessageFormatUtil.Format(srcFilePatternPattern, angle);
72+
String destPattern = MessageFormatUtil.Format(destPatternPattern, angle);
73+
for (int i = 0; i < 360; i += 90) {
74+
String src = sourceFolder + srcFilePattern + i + ".pdf";
75+
String dest = destinationFolder + destPattern + i + "_flattened.pdf";
76+
String cmp = sourceFolder + "cmp_" + srcFilePattern + i + ".pdf";
77+
PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
78+
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
79+
foreach (PdfFormField field in form.GetFormFields().Values) {
80+
field.SetValue("Test");
81+
}
82+
form.FlattenFields();
83+
doc.Close();
84+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
85+
}
86+
}
87+
}
88+
}
89+
}

itext.tests/itext.forms.tests/itext/forms/FormFieldFlatteningTest.cs

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ source product.
4141
4242
*/
4343
using System;
44-
using iText.Forms.Fields;
4544
using iText.Kernel.Pdf;
4645
using iText.Kernel.Utils;
4746
using iText.Test;
4847

4948
namespace iText.Forms {
5049
public class FormFieldFlatteningTest : ExtendedITextTest {
51-
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
52-
.CurrentContext.TestDirectory) + "/resources/itext/forms/FormFieldFlatteningTest/";
53-
5450
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
5551
+ "/test/itext/forms/FormFieldFlatteningTest/";
5652

53+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
54+
.CurrentContext.TestDirectory) + "/resources/itext/forms/FormFieldFlatteningTest/";
55+
5756
[NUnit.Framework.OneTimeSetUp]
5857
public static void BeforeClass() {
5958
CreateDestinationFolder(destinationFolder);
@@ -91,90 +90,6 @@ public virtual void FormFlatteningChoiceFieldTest01() {
9190
}
9291
}
9392

94-
/// <exception cref="System.IO.IOException"/>
95-
/// <exception cref="System.Exception"/>
96-
[NUnit.Framework.Test]
97-
public virtual void FormFlatteningTest_DefaultAppearanceGeneration_Rot0() {
98-
String srcFilePattern = "FormFlatteningDefaultAppearance_0_";
99-
String destPattern = "FormFlatteningDefaultAppearance_0_";
100-
for (int i = 0; i < 360; i += 90) {
101-
String src = sourceFolder + srcFilePattern + i + ".pdf";
102-
String dest = destinationFolder + destPattern + i + "_flattened.pdf";
103-
String cmp = sourceFolder + "cmp_" + srcFilePattern + i + ".pdf";
104-
PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
105-
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
106-
foreach (PdfFormField field in form.GetFormFields().Values) {
107-
field.SetValue("Test");
108-
}
109-
form.FlattenFields();
110-
doc.Close();
111-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
112-
}
113-
}
114-
115-
/// <exception cref="System.IO.IOException"/>
116-
/// <exception cref="System.Exception"/>
117-
[NUnit.Framework.Test]
118-
public virtual void FormFlatteningTest_DefaultAppearanceGeneration_Rot90() {
119-
String srcFilePattern = "FormFlatteningDefaultAppearance_90_";
120-
String destPattern = "FormFlatteningDefaultAppearance_90_";
121-
for (int i = 0; i < 360; i += 90) {
122-
String src = sourceFolder + srcFilePattern + i + ".pdf";
123-
String dest = destinationFolder + destPattern + i + "_flattened.pdf";
124-
String cmp = sourceFolder + "cmp_" + srcFilePattern + i + ".pdf";
125-
PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
126-
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
127-
foreach (PdfFormField field in form.GetFormFields().Values) {
128-
field.SetValue("Test");
129-
}
130-
form.FlattenFields();
131-
doc.Close();
132-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
133-
}
134-
}
135-
136-
/// <exception cref="System.IO.IOException"/>
137-
/// <exception cref="System.Exception"/>
138-
[NUnit.Framework.Test]
139-
public virtual void FormFlatteningTest_DefaultAppearanceGeneration_Rot180() {
140-
String srcFilePattern = "FormFlatteningDefaultAppearance_180_";
141-
String destPattern = "FormFlatteningDefaultAppearance_180_";
142-
for (int i = 0; i < 360; i += 90) {
143-
String src = sourceFolder + srcFilePattern + i + ".pdf";
144-
String dest = destinationFolder + destPattern + i + "_flattened.pdf";
145-
String cmp = sourceFolder + "cmp_" + srcFilePattern + i + ".pdf";
146-
PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
147-
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
148-
foreach (PdfFormField field in form.GetFormFields().Values) {
149-
field.SetValue("Test");
150-
}
151-
form.FlattenFields();
152-
doc.Close();
153-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
154-
}
155-
}
156-
157-
/// <exception cref="System.IO.IOException"/>
158-
/// <exception cref="System.Exception"/>
159-
[NUnit.Framework.Test]
160-
public virtual void FormFlatteningTest_DefaultAppearanceGeneration_Rot270() {
161-
String srcFilePattern = "FormFlatteningDefaultAppearance_270_";
162-
String destPattern = "FormFlatteningDefaultAppearance_270_";
163-
for (int i = 0; i < 360; i += 90) {
164-
String src = sourceFolder + srcFilePattern + i + ".pdf";
165-
String dest = destinationFolder + destPattern + i + "_flattened.pdf";
166-
String cmp = sourceFolder + "cmp_" + srcFilePattern + i + ".pdf";
167-
PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
168-
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
169-
foreach (PdfFormField field in form.GetFormFields().Values) {
170-
field.SetValue("Test");
171-
}
172-
form.FlattenFields();
173-
doc.Close();
174-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
175-
}
176-
}
177-
17893
/// <exception cref="System.IO.IOException"/>
17994
/// <exception cref="System.Exception"/>
18095
[NUnit.Framework.Test]

0 commit comments

Comments
 (0)