Skip to content

Commit 68c744b

Browse files
AlexanderRasolkoiText-CI
authored andcommitted
Add tests in html2pdf for surrogate pairs. DEVSIX-3301
1 parent f7552ec commit 68c744b

16 files changed

+292
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package com.itextpdf.html2pdf;
2+
3+
import com.itextpdf.io.LogMessageConstant;
4+
import com.itextpdf.kernel.utils.CompareTool;
5+
import com.itextpdf.test.ExtendedITextTest;
6+
import com.itextpdf.test.annotations.LogMessage;
7+
import com.itextpdf.test.annotations.LogMessages;
8+
import com.itextpdf.test.annotations.type.IntegrationTest;
9+
import org.junit.Assert;
10+
import org.junit.BeforeClass;
11+
import org.junit.Test;
12+
import org.junit.experimental.categories.Category;
13+
14+
import java.io.File;
15+
import java.io.IOException;
16+
17+
@Category(IntegrationTest.class)
18+
public class SurrogatePairsTests extends ExtendedITextTest {
19+
public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/SurrogatePairsTests/";
20+
public static final String destinationFolder = "./target/test/com/itextpdf/html2pdf/SurrogatePairsTests/";
21+
private static final String TYPOGRAPHY_WARNING = "Cannot find pdfCalligraph module, which was implicitly required by one of the layout properties";
22+
23+
@BeforeClass
24+
public static void beforeClass() {
25+
createOrClearDestinationFolder(destinationFolder);
26+
}
27+
28+
@Test
29+
@LogMessages(messages = {
30+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
31+
public void surrogatePairFrom2Chars() throws IOException, InterruptedException {
32+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairFrom2Chars.html"),
33+
new File(destinationFolder + "surrogatePairFrom2Chars.pdf"));
34+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairFrom2Chars.pdf",
35+
sourceFolder + "cmp_surrogatePairFrom2Chars.pdf", destinationFolder));
36+
}
37+
38+
@Test
39+
@LogMessages(messages = {
40+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
41+
public void surrogatePair2Pairs() throws IOException, InterruptedException {
42+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePair2Pairs.html"),
43+
new File(destinationFolder + "surrogatePair2Pairs.pdf"));
44+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePair2Pairs.pdf",
45+
sourceFolder + "cmp_surrogatePair2Pairs.pdf", destinationFolder));
46+
}
47+
48+
@Test
49+
@LogMessages(messages = {
50+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
51+
public void surrogatePairFullCharacter() throws IOException, InterruptedException {
52+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairFullCharacter.html"),
53+
new File(destinationFolder + "surrogatePairFullCharacter.pdf"));
54+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairFullCharacter.pdf",
55+
sourceFolder + "cmp_surrogatePairFullCharacter.pdf", destinationFolder));
56+
}
57+
58+
@Test
59+
//TODO DEVSIX-3307
60+
@LogMessages(messages = {
61+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2),
62+
@LogMessage(messageTemplate = LogMessageConstant.FONT_SUBSET_ISSUE)})
63+
public void surrogatePairCombingFullSurrs() throws IOException, InterruptedException {
64+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombingFullSurrs.html"),
65+
new File(destinationFolder + "surrogatePairCombingFullSurrs.pdf"));
66+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombingFullSurrs.pdf",
67+
sourceFolder + "cmp_surrogatePairCombingFullSurrs.pdf", destinationFolder));
68+
}
69+
70+
@Test
71+
//TODO DEVSIX-3307
72+
@LogMessages(messages = {
73+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2),
74+
@LogMessage(messageTemplate = LogMessageConstant.FONT_SUBSET_ISSUE)})
75+
public void surrogatePairCombingFullSurrsWithNoSurrs() throws IOException, InterruptedException {
76+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombingFullSurrsWithNoSurrs.html"),
77+
new File(destinationFolder + "surrogatePairCombingFullSurrsWithNoSurrs.pdf"));
78+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombingFullSurrsWithNoSurrs.pdf",
79+
sourceFolder + "cmp_surrogatePairCombingFullSurrsWithNoSurrs.pdf", destinationFolder));
80+
}
81+
82+
@Test
83+
//TODO DEVSIX-3307
84+
@LogMessages(messages = {
85+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
86+
public void surrogatePairCombinationOf3TypesPairs() throws IOException, InterruptedException {
87+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombinationOf3TypesPairs.html"),
88+
new File(destinationFolder + "surrogatePairCombinationOf3TypesPairs.pdf"));
89+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombinationOf3TypesPairs.pdf",
90+
sourceFolder + "cmp_surrogatePairCombinationOf3TypesPairs.pdf", destinationFolder));
91+
}
92+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
This Font Software is licensed under the SIL Open Font License,
2+
Version 1.1.
3+
4+
This license is copied below, and is also available with a FAQ at:
5+
http://scripts.sil.org/OFL
6+
7+
-----------------------------------------------------------
8+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9+
-----------------------------------------------------------
10+
11+
PREAMBLE
12+
The goals of the Open Font License (OFL) are to stimulate worldwide
13+
development of collaborative font projects, to support the font
14+
creation efforts of academic and linguistic communities, and to
15+
provide a free and open framework in which fonts may be shared and
16+
improved in partnership with others.
17+
18+
The OFL allows the licensed fonts to be used, studied, modified and
19+
redistributed freely as long as they are not sold by themselves. The
20+
fonts, including any derivative works, can be bundled, embedded,
21+
redistributed and/or sold with any software provided that any reserved
22+
names are not used by derivative works. The fonts and derivatives,
23+
however, cannot be released under any other type of license. The
24+
requirement for fonts to remain under this license does not apply to
25+
any document created using the fonts or their derivatives.
26+
27+
DEFINITIONS
28+
"Font Software" refers to the set of files released by the Copyright
29+
Holder(s) under this license and clearly marked as such. This may
30+
include source files, build scripts and documentation.
31+
32+
"Reserved Font Name" refers to any names specified as such after the
33+
copyright statement(s).
34+
35+
"Original Version" refers to the collection of Font Software
36+
components as distributed by the Copyright Holder(s).
37+
38+
"Modified Version" refers to any derivative made by adding to,
39+
deleting, or substituting -- in part or in whole -- any of the
40+
components of the Original Version, by changing formats or by porting
41+
the Font Software to a new environment.
42+
43+
"Author" refers to any designer, engineer, programmer, technical
44+
writer or other person who contributed to the Font Software.
45+
46+
PERMISSION & CONDITIONS
47+
Permission is hereby granted, free of charge, to any person obtaining
48+
a copy of the Font Software, to use, study, copy, merge, embed,
49+
modify, redistribute, and sell modified and unmodified copies of the
50+
Font Software, subject to the following conditions:
51+
52+
1) Neither the Font Software nor any of its individual components, in
53+
Original or Modified Versions, may be sold by itself.
54+
55+
2) Original or Modified Versions of the Font Software may be bundled,
56+
redistributed and/or sold with any software, provided that each copy
57+
contains the above copyright notice and this license. These can be
58+
included either as stand-alone text files, human-readable headers or
59+
in the appropriate machine-readable metadata fields within text or
60+
binary files as long as those fields can be easily viewed by the user.
61+
62+
3) No Modified Version of the Font Software may use the Reserved Font
63+
Name(s) unless explicit written permission is granted by the
64+
corresponding Copyright Holder. This restriction only applies to the
65+
primary font name as presented to the users.
66+
67+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68+
Software shall not be used to promote, endorse or advertise any
69+
Modified Version, except to acknowledge the contribution(s) of the
70+
Copyright Holder(s) and the Author(s) or with their explicit written
71+
permission.
72+
73+
5) The Font Software, modified or unmodified, in part or in whole,
74+
must be distributed entirely under this license, and must not be
75+
distributed under any other license. The requirement for fonts to
76+
remain under this license does not apply to any document created using
77+
the Font Software.
78+
79+
TERMINATION
80+
This license becomes null and void if any of the above conditions are
81+
not met.
82+
83+
DISCLAIMER
84+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92+
OTHER DEALINGS IN THE FONT SOFTWARE.
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)