Skip to content

Commit b8803cf

Browse files
committed
Update tests after implementing SymbolicFontSelectorStrategy
DEVSIX-2052
1 parent cb5a2bb commit b8803cf

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,30 @@ This file is part of the iText (R) project.
2424

2525
import com.itextpdf.html2pdf.ConverterProperties;
2626
import com.itextpdf.html2pdf.HtmlConverter;
27-
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
2827
import com.itextpdf.html2pdf.exceptions.Html2PdfException;
28+
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
2929
import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
3030
import com.itextpdf.io.logs.IoLogMessageConstant;
3131
import com.itextpdf.io.util.UrlUtil;
3232
import com.itextpdf.kernel.utils.CompareTool;
3333
import com.itextpdf.layout.font.FontProvider;
34+
import com.itextpdf.layout.font.selectorstrategy.BestMatchFontSelectorStrategy.BestMatchFontSelectorStrategyFactory;
3435
import com.itextpdf.styledxmlparser.css.media.MediaDeviceDescription;
3536
import com.itextpdf.styledxmlparser.css.media.MediaType;
3637
import com.itextpdf.test.ExtendedITextTest;
3738
import com.itextpdf.test.annotations.LogMessage;
3839
import com.itextpdf.test.annotations.LogMessages;
3940
import com.itextpdf.test.annotations.type.IntegrationTest;
41+
42+
import java.io.ByteArrayOutputStream;
43+
import java.io.File;
44+
import java.io.IOException;
4045
import org.junit.Assert;
4146
import org.junit.BeforeClass;
4247
import org.junit.Ignore;
4348
import org.junit.Test;
4449
import org.junit.experimental.categories.Category;
4550

46-
import java.io.ByteArrayOutputStream;
47-
import java.io.File;
48-
import java.io.IOException;
49-
5051
@Category(IntegrationTest.class)
5152
public class FontFaceTest extends ExtendedITextTest {
5253
public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/css/FontFaceTest/";
@@ -290,19 +291,20 @@ public void doNotDownloadUnusedFontTest() throws IOException, InterruptedExcepti
290291
}
291292

292293
@Test
293-
//TODO: update after DEVSIX-2052
294294
public void correctUrlWithUsedUnicodeRangeTest() throws IOException, InterruptedException {
295-
runTest("correctUrlWithUsedUnicodeRangeTest");
295+
FontProvider fontProvider = new DefaultFontProvider();
296+
fontProvider.setFontSelectorStrategyFactory(new BestMatchFontSelectorStrategyFactory());
297+
runTest("correctUrlWithUsedUnicodeRangeTest", fontProvider);
296298
}
297299

298300
@Test
299-
//TODO: update after DEVSIX-2052
300301
public void correctUnicodeRangeSignificantTest() throws IOException, InterruptedException {
301-
runTest("correctUnicodeRangeSignificantTest");
302+
FontProvider fontProvider = new DefaultFontProvider();
303+
fontProvider.setFontSelectorStrategyFactory(new BestMatchFontSelectorStrategyFactory());
304+
runTest("correctUnicodeRangeSignificantTest", fontProvider);
302305
}
303306

304307
@Test
305-
// TODO DEVSIX-2052
306308
public void overwrittenUnicodeRangeTextInLineTest() throws IOException, InterruptedException {
307309
runTest("overwrittenUnicodeRangeTextInLineTest");
308310
}
@@ -327,7 +329,7 @@ public void unusedFontWithUnicodeRangeTest() throws IOException, InterruptedExce
327329
runTest("unusedFontWithUnicodeRangeTest");
328330
}
329331

330-
private void runTest(String name) throws IOException, InterruptedException {
332+
private void runTest(String name, FontProvider fontProvider) throws IOException, InterruptedException {
331333
String htmlPath = sourceFolder + name + ".html";
332334
String pdfPath = destinationFolder + name + ".pdf";
333335
String cmpPdfPath = sourceFolder + "cmp_" + name + ".pdf";
@@ -336,9 +338,13 @@ private void runTest(String name) throws IOException, InterruptedException {
336338

337339
ConverterProperties converterProperties = new ConverterProperties()
338340
.setMediaDeviceDescription(new MediaDeviceDescription(MediaType.PRINT))
339-
.setFontProvider(new DefaultFontProvider());
341+
.setFontProvider(fontProvider);
340342
HtmlConverter.convertToPdf(new File(htmlPath), new File(pdfPath), converterProperties);
341343
Assert.assertFalse("Temporary font was found.", converterProperties.getFontProvider().getFontSet().contains("droid serif"));
342344
Assert.assertNull(new CompareTool().compareByContent(pdfPath, cmpPdfPath, destinationFolder, diffPrefix));
343345
}
346+
347+
private void runTest(String name) throws IOException, InterruptedException {
348+
runTest(name, new DefaultFontProvider());
349+
}
344350
}

0 commit comments

Comments
 (0)