mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-13 06:27:11 +03:00
Use image comparison for Pdfium test
This commit is contained in:
parent
ded344fd12
commit
afb07f9b97
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
@ -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.
BIN
NAPS2.Sdk.Tests/Resources/word_p1.jpg
Normal file
BIN
NAPS2.Sdk.Tests/Resources/word_p1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 242 KiB |
BIN
NAPS2.Sdk.Tests/Resources/word_p2.jpg
Normal file
BIN
NAPS2.Sdk.Tests/Resources/word_p2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 242 KiB |
Loading…
Reference in New Issue
Block a user