Skip to content

Commit 021f107

Browse files
author
Alexandr Fedorov
committed
Add tests for pseudo class css parsing
DEVSIX-8925
1 parent 588ccc2 commit 021f107

11 files changed

+121
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,36 @@ public void pseudoContentWithAutoWidthAndHeightTest() throws IOException, Interr
6262
convertToPdfAndCompare("pseudoContentWithAutoWidthAndHeightTest", SOURCE_FOLDER, DESTINATION_FOLDER);
6363
}
6464

65+
@Test
66+
public void cssWithListOfSelectorsInPseudoClassTest() throws IOException, InterruptedException {
67+
convertToPdfAndCompare("pseudoClassTest", SOURCE_FOLDER, DESTINATION_FOLDER);
68+
}
69+
70+
@Test
71+
public void invalidPseudoClassWithCommaSelectorTest() throws IOException, InterruptedException {
72+
convertToPdfAndCompare("invalidPseudoClassWithCommaSelector", SOURCE_FOLDER, DESTINATION_FOLDER);
73+
}
74+
75+
@Test
76+
public void differentArgumentsInNotClassTest() throws IOException, InterruptedException {
77+
convertToPdfAndCompare("invalidPseudoClassWithCommaSelector", SOURCE_FOLDER, DESTINATION_FOLDER);
78+
}
79+
80+
@Test
81+
public void notFirstPseudoClassTest() throws IOException, InterruptedException {
82+
convertToPdfAndCompare("notFirstPseudoClassTest", SOURCE_FOLDER, DESTINATION_FOLDER);
83+
}
84+
85+
@Test
86+
public void addingNewContentInPseudoClassTest() throws IOException, InterruptedException {
87+
convertToPdfAndCompare("addingNewContentInPseudoClassTest", SOURCE_FOLDER, DESTINATION_FOLDER);
88+
}
89+
90+
@Test
91+
public void complexPseudoClassTest() throws IOException, InterruptedException {
92+
convertToPdfAndCompare("complexPseudoClassTest", SOURCE_FOLDER, DESTINATION_FOLDER);
93+
}
94+
6595
@Test
6696
public void beforeAfterPseudoTest01() throws IOException, InterruptedException {
6797
convertToPdfAndCompare("beforeAfterPseudoTest01", SOURCE_FOLDER, DESTINATION_FOLDER);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
b:not(:last-of-type)::after {
6+
content: "!!!";
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<p>
12+
<b>Mars</b> is one of the most Earth-like planets. <b>Mars</b> day is almost the same as an Earth day, only
13+
<strong>37 minutes</strong> longer.
14+
</p>
15+
</body>
16+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
strong:not([data-time="37"], :empty, b.warning) {
6+
color: forestgreen;
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<p>
12+
<b>Mars</b> is one of the most Earth-like planets. <b>Mars</b> day is almost the same as an Earth day, only
13+
<strong>37 minutes</strong> longer.
14+
</p>
15+
</body>
16+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
p:not(.irrelevant),,, {
6+
font-weight: bold;
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<p>
12+
<b>Mars</b> is one of the most Earth-like planets. <b>Mars</b> day is almost the same as an Earth day, only
13+
<strong>37 minutes</strong> longer.
14+
</p>
15+
</body>
16+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
b:not(:first-of-type) {
6+
color: red;
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<p>
12+
<b>Mars</b> is one of the most Earth-like planets. <b>Mars</b> day is almost the same as an Earth day, only
13+
<strong>37 minutes</strong> longer.
14+
</p>
15+
</body>
16+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
p:not(.irrelevant) {
6+
font-weight: bold;
7+
}
8+
p > strong,
9+
p > b.important {
10+
color: crimson;
11+
}
12+
p > :not(strong, b.important) {
13+
color: darkmagenta;
14+
}
15+
</style>
16+
</head>
17+
<body>
18+
<p>
19+
<b>Mars</b> is one of the most Earth-like planets. <b>Mars</b> day is almost the same as an Earth day, only
20+
<strong>37 minutes</strong> longer.
21+
</p>
22+
<p class="irrelevant">
23+
<b class="important">NASA</b>'s Jet <del>Momentum</del> Propulsion Laboratory is designing mission concepts to survive
24+
the <b>Venus</b> extreme temperatures and atmospheric pressure.
25+
</p>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)