Skip to content

Commit 01f5e64

Browse files
author
Andrei Stryhelski
committed
Add column-gap tests
DEVSIX-7558
1 parent 0042bf6 commit 01f5e64

27 files changed

+858
-43
lines changed

src/test/java/com/itextpdf/html2pdf/css/multicol/ColumnCountTest.java

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public void convertBasicPTest() throws IOException, InterruptedException {
6363

6464
@Test
6565
public void diffElementsInsidePTest() throws IOException, InterruptedException {
66-
convertToPdfAndCompare("diffElementsInsidePTest", SOURCE_FOLDER, DESTINATION_FOLDER, false,
67-
new ConverterProperties().setMulticolEnabled(true).setBaseUri(SOURCE_FOLDER));
66+
runTest("diffElementsInsidePTest");
6867
}
6968

7069
//TODO: DEVSIX-7591 support nested multicol layouting
@@ -91,20 +90,17 @@ public void convertBasicTableTest() throws IOException, InterruptedException {
9190

9291
@Test
9392
public void tableColspanTest() throws IOException, InterruptedException {
94-
convertToPdfAndCompare("tableColspanTest",
95-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
93+
runTest("tableColspanTest");
9694
}
9795

9896
@Test
9997
public void tableRowspanTest() throws IOException, InterruptedException {
100-
convertToPdfAndCompare("tableRowspanTest",
101-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
98+
runTest("tableRowspanTest");
10299
}
103100

104101
@Test
105102
public void tableColspanRowspanTest() throws IOException, InterruptedException {
106-
convertToPdfAndCompare("tableColspanRowspanTest",
107-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
103+
runTest("tableColspanRowspanTest");
108104
}
109105

110106
//TODO: DEVSIX-7591 Support nested multicol layouting
@@ -153,99 +149,84 @@ public void convertImagesWithDifferentColValuesTest() throws IOException, Interr
153149
runTest("imagesWithDifferentColValuesTest");
154150
}
155151

156-
private void runTest(String testName) throws IOException, InterruptedException {
157-
convertToPdfAndCompare(testName,
158-
SOURCE_FOLDER, DESTINATION_FOLDER, false,
159-
new ConverterProperties().setMulticolEnabled(true).setBaseUri(SOURCE_FOLDER));
160-
}
161-
162-
163152
@Test
164153
public void paddingsMarginsBorderBackgrounds() throws IOException, InterruptedException {
165-
convertToPdfAndCompare("paddingsMarginsBorderBackgrounds",
166-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
154+
runTest("paddingsMarginsBorderBackgrounds");
167155
}
168156

169157

170158
@Test
171159
public void borderOnlyTest() throws IOException, InterruptedException {
172-
convertToPdfAndCompare("borderOnly",
173-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
160+
runTest("borderOnly");
174161
}
175162

176163

177164
@Test
178165
public void paddingOnlyTest() throws IOException, InterruptedException {
179-
convertToPdfAndCompare("paddingOnly",
180-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
166+
runTest("paddingOnly");
181167
}
182168

183169

184170
@Test
185171
public void marginOnlyTest() throws IOException, InterruptedException {
186-
convertToPdfAndCompare("marginOnly",
187-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
172+
runTest("marginOnly");
188173
}
189174

190175

191176
@Test
192177
public void splitInnerParagraphBetweenColumns() throws IOException, InterruptedException {
193-
convertToPdfAndCompare("splitInnerParagraphBetweenColumns",
194-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
178+
runTest("splitInnerParagraphBetweenColumns");
195179
}
196180

197181
@Test
198182
public void splitInnerParagraphWithoutMarginBetweenColumns() throws IOException, InterruptedException {
199-
convertToPdfAndCompare("splitInnerParagraphWithoutMarginBetweenColumns",
200-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
183+
runTest("splitInnerParagraphWithoutMarginBetweenColumns");
201184
}
202185

203186
@Test
204187
public void splitEmptyBlockElementsBetweenColumns() throws IOException, InterruptedException {
205-
convertToPdfAndCompare("splitEmptyBlockElementsBetweenColumns",
206-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
188+
runTest("splitEmptyBlockElementsBetweenColumns");
207189
}
208190

209191

210192
@Test
211193
public void splitEmptyParagraphElementsBetweenColumns() throws IOException, InterruptedException {
212-
convertToPdfAndCompare("splitEmptyParagraphElementsBetweenColumns",
213-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
194+
runTest("splitEmptyParagraphElementsBetweenColumns");
214195
}
215196

216197
@Test
217198
public void splitEmptyContinuousBlockElementBetweenColumns() throws IOException, InterruptedException {
218-
convertToPdfAndCompare("splitEmptyContinuousBlockElementBetweenColumns",
219-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
199+
runTest("splitEmptyContinuousBlockElementBetweenColumns");
220200
}
221201

222202
@Test
223203
public void basicHiTest() throws IOException, InterruptedException {
224-
convertToPdfAndCompare("basicHiTest",
225-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
204+
runTest("basicHiTest");
226205
}
227206

228207
@Test
229208
public void basicFooterHeaderTest() throws IOException, InterruptedException {
230-
convertToPdfAndCompare("basicFooterHeaderTest",
231-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
209+
runTest("basicFooterHeaderTest");
232210
}
233211

234212
@Test
235213
public void basicDlTest() throws IOException, InterruptedException {
236-
convertToPdfAndCompare("basicDlTest",
237-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
214+
runTest("basicDlTest");
238215
}
239216

240217
@Test
241218
public void basicInlineElementsTest() throws IOException, InterruptedException {
242-
convertToPdfAndCompare("basicInlineElementsTest",
243-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
219+
runTest("basicInlineElementsTest");
244220
}
245221

246222
@Test
247223
public void basicBlockquoteTest() throws IOException, InterruptedException {
248-
convertToPdfAndCompare("basicBlockquoteTest",
249-
SOURCE_FOLDER, DESTINATION_FOLDER, false, new ConverterProperties().setMulticolEnabled(true));
224+
runTest("basicBlockquoteTest");
225+
}
226+
227+
private void runTest(String testName) throws IOException, InterruptedException {
228+
convertToPdfAndCompare(testName,
229+
SOURCE_FOLDER, DESTINATION_FOLDER, false,
230+
new ConverterProperties().setMulticolEnabled(true).setBaseUri(SOURCE_FOLDER));
250231
}
251232
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2023 Apryse Group NV
4+
Authors: Apryse Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
package com.itextpdf.html2pdf.css.multicol;
24+
25+
import com.itextpdf.html2pdf.ConverterProperties;
26+
import com.itextpdf.html2pdf.ExtendedHtmlConversionITextTest;
27+
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
28+
import com.itextpdf.test.annotations.LogMessage;
29+
import com.itextpdf.test.annotations.LogMessages;
30+
import com.itextpdf.test.annotations.type.IntegrationTest;
31+
32+
import java.io.IOException;
33+
import org.junit.BeforeClass;
34+
import org.junit.Test;
35+
import org.junit.experimental.categories.Category;
36+
37+
@Category(IntegrationTest.class)
38+
public class ColumnGapTest extends ExtendedHtmlConversionITextTest {
39+
public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/html2pdf/css/multicol/ColumnGapTest/";
40+
public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/html2pdf/css/multicol/ColumnGapTest/";
41+
42+
@BeforeClass
43+
public static void beforeClass() {
44+
createOrClearDestinationFolder(DESTINATION_FOLDER);
45+
}
46+
47+
@Test
48+
public void convertBasicTest() throws IOException, InterruptedException {
49+
runTest("basicTest");
50+
}
51+
52+
@Test
53+
public void convertLargeColumnGapValueTest() throws IOException, InterruptedException {
54+
runTest("largeColumnGapValueTest");
55+
}
56+
57+
@Test
58+
@LogMessages(messages = @LogMessage(messageTemplate =
59+
Html2PdfLogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION, count = 2))
60+
public void convertNegativeColumnGapValueTest() throws IOException, InterruptedException {
61+
runTest("negativeColumnGapValueTest");
62+
}
63+
64+
@Test
65+
public void convertSmallColumnGapValueTest() throws IOException, InterruptedException {
66+
runTest("smallColumnGapValueTest");
67+
}
68+
69+
@Test
70+
public void convertFloatColumnGapValueTest() throws IOException, InterruptedException {
71+
runTest("floatColumnGapValueTest");
72+
}
73+
74+
@Test
75+
@LogMessages(messages = @LogMessage(messageTemplate =
76+
Html2PdfLogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION, count = 2))
77+
public void convertDifferentUnitsTest() throws IOException, InterruptedException {
78+
runTest("differentUnitsTest");
79+
}
80+
81+
@Test
82+
public void convertColumnsAndGapTest() throws IOException, InterruptedException {
83+
runTest("columnsAndGapTest");
84+
}
85+
86+
@Test
87+
public void convertMarginTest() throws IOException, InterruptedException {
88+
runTest("marginTest");
89+
}
90+
91+
@Test
92+
public void convertPaddingTest() throws IOException, InterruptedException {
93+
runTest("paddingTest");
94+
}
95+
96+
@Test
97+
public void convertMixedElementsTest() throws IOException, InterruptedException {
98+
runTest("mixedElementsTest");
99+
}
100+
101+
@Test
102+
public void convertNestedElementsTest() throws IOException, InterruptedException {
103+
runTest("nestedElementsTest");
104+
}
105+
106+
@Test
107+
public void convertGapShorthandTest() throws IOException, InterruptedException {
108+
runTest("gapShorthandTest");
109+
}
110+
111+
private void runTest(String testName) throws IOException, InterruptedException {
112+
convertToPdfAndCompare(testName,
113+
SOURCE_FOLDER, DESTINATION_FOLDER, false,
114+
new ConverterProperties().setMulticolEnabled(true).setBaseUri(SOURCE_FOLDER));
115+
}
116+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head> </head>
4+
<body>
5+
<h2>Basic column-gap test</h2>
6+
<h3>column-count: 3; column-gap: 100px</h3>
7+
<div style="column-count: 3; column-gap: 100px; border: solid">
8+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
9+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
10+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
11+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
12+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
13+
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
14+
est laborum.
15+
</div>
16+
<h3>columns: 4; column-gap: 150px</h3>
17+
<div style="columns: 4; column-gap: 150px; border: solid">
18+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
19+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
20+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
21+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
22+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
23+
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
24+
est laborum.
25+
</div>
26+
<h3>columns: 7; column-gap: 30px</h3>
27+
<div style="columns: 7; column-gap: 30px; border: solid">
28+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
29+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
30+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
31+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
32+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
33+
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
34+
est laborum.
35+
</div>
36+
<h3>column-count: 12; column-gap: 50px</h3>
37+
<div style="column-count: 12; column-gap: 50px; border: solid">
38+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
39+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
40+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
41+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
42+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
43+
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
44+
est laborum.
45+
</div>
46+
</body>
47+
</html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)