Skip to content

Commit 2a2bcba

Browse files
AlexanderRasolkoKate Ivanova
authored andcommitted
Move HighlightItemsTest from samples-internal repository
DEVSIX-3828
1 parent 8abd5c4 commit 2a2bcba

17 files changed

+75
-0
lines changed

kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,81 @@ public void highlightNotDefTest() throws IOException, InterruptedException {
170170
Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff"));
171171
}
172172

173+
@Test
174+
public void fillStandardEncodingType1NoDescriptorTest() throws IOException, InterruptedException {
175+
String input = sourceFolder + "fillStandardEncodingType1NoDescriptorTest.pdf";
176+
String output = outputPath + "fillStandardEncodingType1NoDescriptorTest.pdf";
177+
String cmp = sourceFolder + "cmp_fillStandardEncodingType1NoDescriptorTest.pdf";
178+
parseAndHighlight(input, output, true);
179+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
180+
}
181+
182+
@Test
183+
public void fillStandardEncodingTrueTypeFontDescriptorTest() throws IOException, InterruptedException {
184+
String input = sourceFolder + "fillStandardEncodingTrueTypeFontDescriptorTest.pdf";
185+
String output = outputPath + "fillStandardEncodingTrueTypeFontDescriptorTest.pdf";
186+
String cmp = sourceFolder + "cmp_fillStandardEncodingTrueTypeFontDescriptorTest.pdf";
187+
parseAndHighlight(input, output, true);
188+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
189+
}
190+
191+
@Test
192+
public void fillStandardEncodingType1FontDescriptorTest() throws IOException, InterruptedException {
193+
String input = sourceFolder + "fillStandardEncodingType1FontDescriptorTest.pdf";
194+
String output = outputPath + "fillStandardEncodingType1FontDescriptorTest.pdf";
195+
String cmp = sourceFolder + "cmp_fillStandardEncodingType1FontDescriptorTest.pdf";
196+
parseAndHighlight(input, output, true);
197+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
198+
}
199+
200+
@Test
201+
// As the negative ascent is not covered by pdf specification in details,
202+
// we work with it as usual (which results with not very beautiful view).
203+
public void incorrectAscentFontDescriptorTest() throws IOException, InterruptedException {
204+
String input = sourceFolder + "incorrectAscentFontDescriptorTest.pdf";
205+
String output = outputPath + "incorrectAscentFontDescriptorTest.pdf";
206+
String cmp = sourceFolder + "cmp_incorrectAscentFontDescriptorTest.pdf";
207+
parseAndHighlight(input, output, true);
208+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
209+
}
210+
211+
@Test
212+
public void incorrectDescentFontDescriptorTest() throws IOException, InterruptedException {
213+
String input = sourceFolder + "incorrectDescentFontDescriptorTest.pdf";
214+
String output = outputPath + "incorrectDescentFontDescriptorTest.pdf";
215+
String cmp = sourceFolder + "cmp_incorrectDescentFontDescriptorTest.pdf";
216+
parseAndHighlight(input, output, true);
217+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
218+
}
219+
220+
@Test
221+
public void fontDictWidthArrayMissingWidthTest() throws IOException, InterruptedException {
222+
String input = sourceFolder + "fontDictWidthArrayMissingWidthTest.pdf";
223+
String output = outputPath + "fontDictWidthArrayMissingWidthTest.pdf";
224+
String cmp = sourceFolder + "cmp_fontDictWidthArrayMissingWidthTest.pdf";
225+
parseAndHighlight(input, output, true);
226+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
227+
}
228+
229+
@Test
230+
public void trueTypeCIDFontWithDWWithoutProperWidthGlyphTest() throws IOException, InterruptedException {
231+
String input = sourceFolder + "trueTypeCIDFontWithDWWithoutProperWidthGlyphTest.pdf";
232+
String output = outputPath + "trueTypeCIDFontWithDWWithoutProperWidthGlyphTest.pdf";
233+
String cmp = sourceFolder + "cmp_trueTypeCIDFontWithDWWithoutProperWidthGlyphTest.pdf";
234+
parseAndHighlight(input, output, true);
235+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
236+
}
237+
238+
@Test
239+
//TODO: DEVSIX-4784 (incorrect displaying of highlights)
240+
public void invalidHighlightTest() throws IOException, InterruptedException {
241+
String input = sourceFolder + "invalidHighlight.pdf";
242+
String output = outputPath + "invalidHighlightOutput.pdf";
243+
String cmp = sourceFolder + "cmp_invalidHighlight.pdf";
244+
parseAndHighlight(input, output, true);
245+
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
246+
}
247+
173248
private void parseAndHighlight(String input, String output, boolean singleCharacters) throws IOException {
174249
PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
175250

0 commit comments

Comments
 (0)