Use image comparison for Pdfium test

This commit is contained in:
Ben Olden-Cooligan 2019-04-13 17:53:45 -04:00
parent ded344fd12
commit afb07f9b97
7 changed files with 39 additions and 4 deletions

View File

@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NAPS2.Images.Storage;
using NAPS2.ImportExport.Pdf;
using NAPS2.Sdk.Tests.Asserts;
using Xunit;
namespace NAPS2.Sdk.Tests.ImportExport
@ -15,13 +17,14 @@ namespace NAPS2.Sdk.Tests.ImportExport
var path = Path.Combine(FolderPath, "word.pdf");
File.WriteAllBytes(path, PdfiumTestsData.word);
IImage expectedPage1 = new GdiImage(PdfiumTestsData.word_p1);
IImage expectedPage2 = new GdiImage(PdfiumTestsData.word_p2);
var images = PdfiumPdfRenderer.Render(path, 300).ToList();
Assert.Equal(2, images.Count);
Assert.Equal(images[0].Width, (int)(8.5 * 300));
Assert.Equal(images[0].Height, 11 * 300);
Assert.Equal(images[0].HorizontalResolution, 300);
Assert.Equal(images[0].VerticalResolution, 300);
ImageAsserts.Similar(images[0], expectedPage1, 3);
ImageAsserts.Similar(images[1], expectedPage2, 3);
}
}
}

View File

@ -69,5 +69,25 @@ namespace NAPS2.Sdk.Tests.ImportExport {
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap word_p1 {
get {
object obj = ResourceManager.GetObject("word_p1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap word_p2 {
get {
object obj = ResourceManager.GetObject("word_p2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -121,4 +121,10 @@
<data name="word" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\word.pdf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="word_p1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\word_p1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="word_p2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\word_p2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -256,6 +256,12 @@
<TargetPath>_osx\libpdfium.dylib</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<None Include="Resources\word_p1.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\word_p2.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB