Skip to content

Commit dab38ed

Browse files
Kate IvanovaiText-CI
authored andcommitted
Move HTML_Tables tests
DEVSIX-3038
1 parent dfebcb3 commit dab38ed

39 files changed

+667
-12
lines changed

src/test/java/com/itextpdf/html2pdf/element/TableTest.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ public void helloTableDocumentTest() throws IOException, InterruptedException {
8282
runTest("hello_table");
8383
}
8484

85+
@Test
86+
public void checkBasicTableFeatures() throws IOException, InterruptedException {
87+
runTest("checkBasicTableFeatures");
88+
}
89+
90+
@Test
91+
//TODO update after DEVSIX-2908
92+
public void check_th_align() throws IOException, InterruptedException {
93+
runTest("th_align");
94+
}
95+
8596
@Test
8697
public void helloTableFixed1DocumentTest() throws IOException, InterruptedException {
8798
runTest("hello_table_fixed1");
@@ -245,6 +256,39 @@ public void helloTableHeaderFooterDocumentTest() throws IOException, Interrupted
245256
runTest("hello_table_header_footer");
246257
}
247258

259+
@Test
260+
@LogMessages(messages = {
261+
@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.LAST_ROW_IS_NOT_COMPLETE),
262+
@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.RECTANGLE_HAS_NEGATIVE_SIZE)
263+
})
264+
//TODO update after DEVSIX-2395 and DEVSIX-2399
265+
public void checkHeaderFooterTaggedTables() throws IOException, InterruptedException {
266+
runTest("checkHeaderFooterTaggedTables");
267+
}
268+
269+
@Test
270+
@LogMessages(messages = {@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.RECTANGLE_HAS_NEGATIVE_SIZE, count = 3)})
271+
//TODO update after DEVSIX-2395 and DEVSIX-2399
272+
public void checkFloatInTdTagged() throws IOException, InterruptedException {
273+
runTest("checkFloatInTdTagged");
274+
}
275+
276+
@Test
277+
//TODO update after DEVSIX-2399
278+
public void checkDisplayInTableTagged() throws IOException, InterruptedException {
279+
runTest("checkDisplayInTableTagged");
280+
}
281+
282+
@Test
283+
@LogMessages(messages = {
284+
@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.TABLE_WIDTH_IS_MORE_THAN_EXPECTED_DUE_TO_MIN_WIDTH, count = 3),
285+
@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 2)
286+
})
287+
//TODO update after DEVSIX-2382
288+
public void checkLargeImagesInTable() throws IOException, InterruptedException {
289+
runTest("checkLargeImagesInTable");
290+
}
291+
248292
@Test
249293
public void helloTableColspanDocumentTest() throws IOException, InterruptedException {
250294
runTest("hello_table_colspan");
@@ -469,6 +513,14 @@ public void tableWidthMoreThan100PercentTest() throws IOException, InterruptedEx
469513
runTest("tableWidthMoreThan100Percent");
470514
}
471515

516+
@Test
517+
@LogMessages(messages = {@LogMessage(messageTemplate = LogMessageConstant.PADDING_VALUE_IN_PERCENT_NOT_SUPPORTED, count = 63)})
518+
//https://codepen.io/heypablete/pen/qdIsm
519+
//TODO: update after DEVSIX-1101
520+
public void checkResponsiveTableExample() throws IOException, InterruptedException {
521+
runTest("checkResponsiveTableExample");
522+
}
523+
472524
private void runTest(String testName) throws IOException, InterruptedException {
473525
runTest(testName, false);
474526
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<html>
2+
<head>
3+
<title>BASIC table features within pdfHTML</title>
4+
<style>
5+
table, td {
6+
border: 2px solid green;
7+
}
8+
th {
9+
border: 1px solid brown;
10+
background-color:yellow;
11+
}
12+
table#table01 tr:nth-child(even) {
13+
background-color: #eee;
14+
}
15+
table#ttable01 tr:nth-child(odd) {
16+
background-color: #fff;
17+
}
18+
p {
19+
color: gray;
20+
}
21+
22+
</style>
23+
</head>
24+
<body>
25+
<table id="table01" width="100%">
26+
<tr>
27+
<th scope="col">TH 1 col</th>
28+
<th scope="col">TH 2 col</th>
29+
<th scope="col">TH 3 col</th>
30+
<th scope="col">TH 4 col</th>
31+
<th scope="col">TH 5 col</th>
32+
</tr>
33+
<tr>
34+
<th scope="row">TH 1 row</th>
35+
<td colspan="2" style="background-color:yellow;">TD colspan 2</td>
36+
<td style="border-style: dotted dashed;">TD border-style</td>
37+
<td style="text-align: right;">TD text-align right</td>
38+
</tr>
39+
<tr>
40+
<th scope="row">TH 2 row</th>
41+
<td rowspan="2" style="background-color:orange;">TD rowspan 2</td>
42+
<td style="border-style: none;">TD border-style none</td>
43+
<td style="text-align: center;">TD text-align center</td>
44+
<td style="text-align: right;">TD text-align right</td>
45+
</tr>
46+
<tr>
47+
<th scope="row">TH 3 row</th>
48+
<td style="border-style: double;">TD border-style double</td>
49+
<td>
50+
<div style="background-color: yellow; width:50px">div with style inside td width 50</div>
51+
</td>
52+
<td>TD this cell contains<br><br>two br tags</td>
53+
</tr>
54+
<tr>
55+
<th scope="row">TH 4 row</th>
56+
<td><p>Paragraph inside td. Paragraph inside td. Paragraph inside td. Paragraph inside td. Paragraph inside td.</p></td>
57+
<td style="border-style: double;">TD border-style doub;e</td>
58+
<td>
59+
<div style="background-color: yellow; width:250px">div with style inside td width 250</div>
60+
</td>
61+
<td>Multiple rows should be here. Multiple rows should be here. Multiple rows should be here.
62+
</td>
63+
</tr>
64+
<tr>
65+
<th scope="row">TH 5 row</th>
66+
<td></td>
67+
<td>Image in div inside<div><img src="image.png" width="200"></div></td>
68+
<td>
69+
<img src="image.png" width="200"></div>
70+
</td>
71+
<td></td>
72+
</tr>
73+
</table>
74+
</body>
75+
</html>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<html>
2+
<head>
3+
<title>Header, Footer table features within pdfHTML</title>
4+
<style>
5+
table { display: table; }
6+
thead { display: table-header-group; }
7+
tbody { display: table-row-group; }
8+
tfoot { display: table-footer-group; }
9+
tr { display: table-row; }
10+
th, td { display: table-cell; }
11+
table.inline, thead.inline, tbody.inline, tfoot.inline, tr.inline, th.inline, td.inline {
12+
display: inline;
13+
}
14+
table.block, thead.block, tbody.block, tfoot.block, tr.block, th.block, td.block {
15+
display: block;
16+
}
17+
th {
18+
padding: 15px;
19+
margin: 15px;
20+
border: 3px solid #aaa;
21+
background-color: #aaa;
22+
}
23+
td {
24+
padding: 15px;
25+
margin: 15px;
26+
border: 3px solid #ddd;
27+
}
28+
29+
</style>
30+
</head>
31+
<body>
32+
<table>
33+
<thead>
34+
<tr>
35+
<th>Table 1</th>
36+
<th>FOR DEFAULT</th>
37+
<th>Table Dislay settings</th>
38+
</tr>
39+
</thead>
40+
<tbody>
41+
<tr>
42+
<td>Table Cell 1</td>
43+
<td>Table Cell 2</td>
44+
<td>Table Cell 3</td>
45+
</tr>
46+
</tbody>
47+
<tfoot>
48+
<tr>
49+
<td colspan="3">Footer Cell</td>
50+
</tr>
51+
</tfoot>
52+
</table>
53+
<br>
54+
<br>
55+
<table class="inline">
56+
<thead class="inline">
57+
<tr class="inline">
58+
<th class="inline">Table 2</th>
59+
<th class="inline">For Display </th>
60+
<th class="inline">INLINE</th>
61+
<th class="inline">Table </th>
62+
</tr>
63+
</thead>
64+
<tbody class="inline">
65+
<tr class="inline">
66+
<td class="inline">Table Cell 1</td>
67+
<td class="inline">Table Cell 2</td>
68+
<td class="inline">Table Cell 3</td>
69+
<td class="inline">Table Cell 4</td>
70+
</tr>
71+
</tbody>
72+
<tfoot class="inline">
73+
<tr class="inline">
74+
<td class="inline" colspan="4">Footer Cell</td>
75+
</tr>
76+
</tfoot>
77+
</table>
78+
<br>
79+
<br>
80+
<br>
81+
<br>
82+
<br>
83+
<br>
84+
<table class="block">
85+
<thead class="block">
86+
<tr class="block">
87+
<th class="block">Table 3 for</th>
88+
<th class="block">Display BLOCK</th>
89+
</tr>
90+
</thead>
91+
<tbody class="block">
92+
<tr class="block">
93+
<td class="block">Table Cell 1 </td>
94+
<td class="block">Table Cell 2</td>
95+
</tr>
96+
</tbody>
97+
<tfoot class="block">
98+
<tr class="block">
99+
<td class="block" colspan="2">Footer Cell</td>
100+
</tr>
101+
</tfoot>
102+
</table>
103+
</body>
104+
</html>
105+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<html>
2+
<head>
3+
<title>Header, Footer table features within pdfHTML</title>
4+
<style>
5+
table { display: table; }
6+
thead { display: table-header-group; }
7+
tbody { display: table-row-group; }
8+
tfoot { display: table-footer-group; }
9+
tr { display: table-row; }
10+
th, td { display: table-cell; }
11+
table.inline, thead.inline, tbody.inline, tfoot.inline, tr.inline, th.inline, td.inline {
12+
display: inline;
13+
}
14+
table.block, thead.block, tbody.block, tfoot.block, tr.block, th.block, td.block {
15+
display: block;
16+
}
17+
td.floatLeft {
18+
box-sizing: border-box;
19+
width: 25%;
20+
float: left;
21+
padding: 10px;
22+
}
23+
td:nth-child(2), td:nth-child(3), td:nth-child(4) {
24+
padding: 10px;
25+
background-color:yellow;
26+
}
27+
td {
28+
padding: 15px;
29+
margin: 15px;
30+
border: 3px solid #ddd;
31+
}
32+
33+
</style>
34+
</head>
35+
<body>
36+
<table>
37+
<thead>
38+
<tr>
39+
<th>Table 1</th>
40+
<th>FOR DEFAULT</th>
41+
<th>Table Dislay settings</th>
42+
</tr>
43+
</thead>
44+
<tbody>
45+
<tr>
46+
<td class="floatLeft">Table Cell 1 ( float: left;)</td>
47+
<td>Table Cell 2</td>
48+
<td>Table Cell 3</td>
49+
</tr>
50+
</tbody>
51+
<tfoot>
52+
<tr>
53+
<td colspan="3" class="floatLeft">Footer Cell ( float: left;)</td>
54+
</tr>
55+
</tfoot>
56+
</table>
57+
<br>
58+
<br>
59+
<table class="inline">
60+
<thead class="inline">
61+
<tr class="inline">
62+
<th class="inline">Table 2</th>
63+
<th class="inline">For Display </th>
64+
<th class="inline">INLINE</th>
65+
<th class="inline">Table </th>
66+
</tr>
67+
</thead>
68+
<tbody class="inline">
69+
<tr class="inline">
70+
<td class="inline" class="floatLeft">Table Cell 1(float: left;)</td>
71+
<td class="inline">Table Cell 2</td>
72+
<td class="inline">Table Cell 3</td>
73+
<td class="inline">Table Cell 4</td>
74+
</tr>
75+
</tbody>
76+
<tfoot class="inline">
77+
<tr class="inline">
78+
<td class="inline" class="floatLeft" colspan="4">Footer Cell (float: left;)</td>
79+
</tr>
80+
</tfoot>
81+
</table>
82+
<br>
83+
<br>
84+
<br>
85+
<br>
86+
<br>
87+
<br>
88+
<table class="block">
89+
<thead class="block">
90+
<tr class="block">
91+
<th class="block">Table 3 for</th>
92+
<th class="block">Display BLOCK</th>
93+
</tr>
94+
</thead>
95+
<tbody class="block">
96+
<tr class="block">
97+
<td class="block" class="floatLeft">Table Cell 1 (float: left;)</td>
98+
<td class="block">Table Cell 2</td>
99+
</tr>
100+
</tbody>
101+
<tfoot class="block">
102+
<tr class="block">
103+
<td class="block" class="floatLeft" colspan="2">Footer Cell float: left</td>
104+
</tr>
105+
</tfoot>
106+
</table>
107+
</body>
108+
</html>
109+

0 commit comments

Comments
 (0)