Skip to content

Commit c807c7f

Browse files
committed
Add test for page counter + keep together case
DEVSIX-7785
1 parent 922093f commit c807c7f

File tree

3 files changed

+478
-12
lines changed

3 files changed

+478
-12
lines changed

src/test/java/com/itextpdf/html2pdf/css/CounterTest.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,69 @@ This file is part of the iText (R) project.
2323
package com.itextpdf.html2pdf.css;
2424

2525
import com.itextpdf.html2pdf.ExtendedHtmlConversionITextTest;
26+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
27+
import com.itextpdf.test.LogLevelConstants;
28+
import com.itextpdf.test.annotations.LogMessage;
29+
import com.itextpdf.test.annotations.LogMessages;
2630
import com.itextpdf.test.annotations.type.IntegrationTest;
31+
32+
import java.io.IOException;
2733
import org.junit.BeforeClass;
2834
import org.junit.Test;
2935
import org.junit.experimental.categories.Category;
3036

31-
import java.io.IOException;
32-
3337
@Category(IntegrationTest.class)
3438
public class CounterTest extends ExtendedHtmlConversionITextTest{
3539

36-
public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/css/CounterTest/";
37-
public static final String destinationFolder = "./target/test/com/itextpdf/html2pdf/css/CounterTest/";
40+
public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/html2pdf/css/CounterTest/";
41+
public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/html2pdf/css/CounterTest/";
3842

3943
@BeforeClass
4044
public static void beforeClass() {
41-
createOrClearDestinationFolder(destinationFolder);
45+
createOrClearDestinationFolder(DESTINATION_FOLDER);
4246
}
4347

4448
@Test
4549
public void counter01Test() throws IOException, InterruptedException {
46-
convertToPdfAndCompare("counter01", sourceFolder, destinationFolder);
50+
convertToPdfAndCompare("counter01", SOURCE_FOLDER, DESTINATION_FOLDER);
4751
}
4852

4953
@Test
5054
public void pageCounter01Test() throws IOException, InterruptedException {
51-
convertToPdfAndCompare("page_counter01", sourceFolder, destinationFolder);
55+
convertToPdfAndCompare("page_counter01", SOURCE_FOLDER, DESTINATION_FOLDER);
5256
}
5357

5458
@Test
5559
public void pageCounter02Test() throws IOException, InterruptedException {
56-
convertToPdfAndCompare("page_counter02", sourceFolder, destinationFolder);
60+
convertToPdfAndCompare("page_counter02", SOURCE_FOLDER, DESTINATION_FOLDER);
5761
}
5862

5963
@Test
6064
public void pageCounter03Test() throws IOException, InterruptedException {
61-
convertToPdfAndCompare("page_counter03", sourceFolder, destinationFolder);
65+
convertToPdfAndCompare("page_counter03", SOURCE_FOLDER, DESTINATION_FOLDER);
6266
}
6367

6468
@Test
6569
public void pageCounter04Test() throws IOException, InterruptedException {
66-
convertToPdfAndCompare("page_counter04", sourceFolder, destinationFolder);
70+
convertToPdfAndCompare("page_counter04", SOURCE_FOLDER, DESTINATION_FOLDER);
6771
}
6872

6973
@Test
7074
public void pageCounterSpacesInDeclarationTest() throws IOException, InterruptedException {
71-
convertToPdfAndCompare("page_counter_spaces_in_declaration", sourceFolder, destinationFolder);
75+
convertToPdfAndCompare("page_counter_spaces_in_declaration", SOURCE_FOLDER, DESTINATION_FOLDER);
76+
}
77+
78+
@Test
79+
@LogMessages(messages = {
80+
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 2, logLevel = LogLevelConstants.WARN)
81+
})
82+
public void pageCounterAndKeepTogetherTest() throws IOException, InterruptedException {
83+
convertToPdfAndCompare("pageCounterAndKeepTogetherTest", SOURCE_FOLDER, DESTINATION_FOLDER);
7284
}
7385

7486
@Test
7587
// TODO fix cmp after DEVSIX-5509 is done; currently total page count is incorrect
7688
public void pageCounterWithTrimmedLastPageTest() throws IOException, InterruptedException {
77-
convertToPdfAndCompare("page_counter_with_trimmed_last_page", sourceFolder, destinationFolder);
89+
convertToPdfAndCompare("page_counter_with_trimmed_last_page", SOURCE_FOLDER, DESTINATION_FOLDER);
7890
}
7991
}
Binary file not shown.

0 commit comments

Comments
 (0)