#13 handle special case cff file and reduce duplication in integration tests

This commit is contained in:
Eliot Jones
2018-11-25 12:36:38 +00:00
parent 8a0c51eaa2
commit 243f3dc099
26 changed files with 105 additions and 77 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

View File

@@ -1,16 +1,12 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Xunit;
public class FarmerMacTests
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "FarmerMac.pdf");
return IntegrationHelpers.GetDocumentPath("FarmerMac.pdf");
}
[Fact]

View File

@@ -0,0 +1,20 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
internal static class IntegrationHelpers
{
public static string GetDocumentPath(string name, bool isPdf = true)
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
if (!name.EndsWith(".pdf") && isPdf)
{
name += ".pdf";
}
return Path.Combine(documentFolder, name);
}
}
}

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using System.Linq;
using Content;
@@ -10,9 +9,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Judgement Document.pdf");
return IntegrationHelpers.GetDocumentPath("Judgement Document.pdf");
}
[Fact]

View File

@@ -2,7 +2,6 @@
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
@@ -10,9 +9,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "ICML03-081.pdf");
return IntegrationHelpers.GetDocumentPath("ICML03-081.pdf");
}
[Fact]

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Content;
using Xunit;
@@ -9,9 +8,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Multiple Page - from Mortality Statistics.pdf");
return IntegrationHelpers.GetDocumentPath("Multiple Page - from Mortality Statistics.pdf");
}
[Fact]

View File

@@ -1,16 +1,12 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Xunit;
public class OldGutnishTests
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Old Gutnish Internet Explorer.pdf");
return IntegrationHelpers.GetDocumentPath("Old Gutnish Internet Explorer.pdf");
}
[Fact]

View File

@@ -2,7 +2,6 @@
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
@@ -10,9 +9,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Pig Production Handbook.pdf");
return IntegrationHelpers.GetDocumentPath("Pig Production Handbook.pdf");
}
[Fact]

View File

@@ -1,16 +1,12 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Xunit;
public class PigReproductionPowerpointTests
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Pig Reproduction Powerpoint.pdf");
return IntegrationHelpers.GetDocumentPath("Pig Reproduction Powerpoint.pdf");
}
[Fact]

View File

@@ -1,16 +1,12 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Xunit;
public class PlosOneTests
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "journal.pone.0196757.pdf");
return IntegrationHelpers.GetDocumentPath("journal.pone.0196757.pdf");
}
[Fact]

View File

@@ -0,0 +1,25 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using Xunit;
public class PopBugzilla37292Tests
{
private static string GetFilename()
{
return IntegrationHelpers.GetDocumentPath("pop-bugzilla37292.pdf");
}
[Fact]
public void CanReadPages()
{
using (var document = PdfDocument.Open(GetFilename(), new ParsingOptions { UseLenientParsing = false }))
{
for (var i = 0; i < document.NumberOfPages; i++)
{
var page = document.GetPage(i + 1);
Assert.NotNull(page.Letters);
}
}
}
}
}

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Content;
using Xunit;
@@ -9,9 +8,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Form Content - from itext 1_1.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Form Content - from itext 1_1.pdf");
}
[Fact]

View File

@@ -2,7 +2,6 @@
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
@@ -10,9 +9,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Simple - from inkscape.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Simple - from inkscape.pdf");
}
[Fact]

View File

@@ -11,9 +11,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Non Latin - from acrobat distiller.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Non Latin - from acrobat distiller.pdf");
}
[Fact]
@@ -152,7 +150,7 @@
218.6352 90.65997 9.990005 d 19 FFJICI+TimesNewRomanPSMT
228.6252 90.65997 4.994995 . 19 FFJICI+TimesNewRomanPSMT";
var result = data.Split(new[] {"\r", "\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries)
var result = data.Split(new[] { "\r", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
.Select(AssertablePositionData.Parse)
.ToList();

View File

@@ -17,9 +17,7 @@ namespace UglyToad.PdfPig.Tests.Integration
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Simple - from google drive.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Simple - from google drive.pdf");
}
[Fact]

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using System.Linq;
using Content;
@@ -10,9 +9,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Simple - from open office.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Simple - from open office.pdf");
}
[Fact]

View File

@@ -1,7 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Content;
using Xunit;
@@ -9,9 +7,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Single Page Type 1 Font.pdf");
return IntegrationHelpers.GetDocumentPath("Single Page Type 1 Font.pdf");
}
[Fact]

View File

@@ -1,7 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Content;
using Xunit;
@@ -9,9 +7,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "2006_Swedish_Touring_Car_Championship.pdf");
return IntegrationHelpers.GetDocumentPath("2006_Swedish_Touring_Car_Championship.pdf");
}
[Fact]

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using Content;
using Xunit;
@@ -9,9 +8,7 @@
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Two Page Text Only - from libre office.pdf");
return IntegrationHelpers.GetDocumentPath("Two Page Text Only - from libre office.pdf");
}
[Fact]

View File

@@ -1,6 +1,5 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using System;
using System.IO;
using System.Linq;
using Content;
@@ -10,9 +9,7 @@ namespace UglyToad.PdfPig.Tests.Integration
{
private static string GetFilename()
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents"));
return Path.Combine(documentFolder, "Type0 Font.pdf");
return IntegrationHelpers.GetDocumentPath("Type0 Font.pdf");
}
[Fact]
@@ -57,8 +54,8 @@ namespace UglyToad.PdfPig.Tests.Integration
{
var page = document.GetPage(1);
Assert.True((bool) page.Letters.Any(x => x.GlyphRectangle.Width != 0));
Assert.True((bool) page.Letters.Any(x => x.GlyphRectangle.Height != 0));
Assert.Contains(page.Letters, x => x.GlyphRectangle.Width != 0);
Assert.Contains(page.Letters, x => x.GlyphRectangle.Height != 0);
}
}
}

View File

@@ -59,7 +59,7 @@
[Fact]
public void RotatedTextLibreOffice()
{
Run(@"Rotated Text Libre Office", 841);
Run("Rotated Text Libre Office", 841);
}
[Fact]
@@ -68,6 +68,18 @@
Run(PigProduction, 680);
}
[Fact]
public void PopBugzilla37292()
{
Run("pop-bugzilla37292");
}
[Fact]
public void MultiPageMortalityStatistics()
{
Run("Multiple Page - from Mortality Statistics");
}
private static void Run(string file, int imageHeight = 792)
{
var pdfFileName = GetFilename(file);