|
|
|
@ -11,6 +11,8 @@ using Xunit; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Tests |
|
|
|
{ |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using SixLabors.ImageSharp.Formats.Png; |
|
|
|
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
|
|
|
|
|
|
|
@ -55,7 +57,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
|
|
|
|
public static readonly string[] CommonTestImages = |
|
|
|
{ |
|
|
|
TestImages.Png.Splash, TestImages.Png.Indexed, |
|
|
|
TestImages.Png.Splash, |
|
|
|
TestImages.Png.Indexed, |
|
|
|
TestImages.Png.FilterVar, |
|
|
|
TestImages.Png.Bad.ChunkLength1, |
|
|
|
TestImages.Png.Bad.CorruptedChunk, |
|
|
|
@ -67,6 +70,9 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
TestImages.Png.SnakeGame, |
|
|
|
TestImages.Png.Banner7Adam7InterlaceMode, |
|
|
|
TestImages.Png.Banner8Index, |
|
|
|
|
|
|
|
TestImages.Png.Bad.ChunkLength2, |
|
|
|
TestImages.Png.VimImage2, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -78,42 +84,42 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
|
|
|
|
// This is a workaround for Mono-s decoder being incompatible with ours and GDI+.
|
|
|
|
// We shouldn't mix these with the Interleaved cases (which are also failing with Mono System.Drawing). Let's go AAA!
|
|
|
|
public static readonly string[] WindowsOnlyTestImages = |
|
|
|
private static readonly string[] SkipOnMono = |
|
|
|
{ |
|
|
|
TestImages.Png.Bad.ChunkLength2, |
|
|
|
TestImages.Png.VimImage2, |
|
|
|
TestImages.Png.Splash, |
|
|
|
TestImages.Png.Indexed, |
|
|
|
TestImages.Png.Bad.ChunkLength1, |
|
|
|
TestImages.Png.VersioningImage1, |
|
|
|
TestImages.Png.Banner7Adam7InterlaceMode, |
|
|
|
}; |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] |
|
|
|
public void Decode<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
private static bool SkipVerification(ITestImageProvider provider) |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage(new PngDecoder())) |
|
|
|
{ |
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToOriginal(provider, ImageComparer.Exact); |
|
|
|
} |
|
|
|
string fn = provider.SourceFileOrDescription; |
|
|
|
|
|
|
|
// This is a workaround for Mono-s decoder being incompatible with ours and GDI+.
|
|
|
|
// We shouldn't mix these with the Interleaved cases (which are also failing with Mono System.Drawing). Let's go AAA!
|
|
|
|
return (TestEnvironment.IsLinux || TestEnvironment.IsMono) && SkipOnMono.Contains(fn); |
|
|
|
} |
|
|
|
|
|
|
|
// This is a workaround for Mono-s decoder being incompatible with ours and GDI+.
|
|
|
|
// We shouldn't mix these with the Interleaved cases (which are also failing with Mono System.Drawing). Let's go AAA!
|
|
|
|
[Theory] |
|
|
|
[WithFileCollection(nameof(WindowsOnlyTestImages), PixelTypes.Rgba32)] |
|
|
|
public void Decode_WindowsOnlyTestImages<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
[WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] |
|
|
|
public void Decode<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage(new PngDecoder())) |
|
|
|
{ |
|
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
if (!TestEnvironment.IsLinux) |
|
|
|
if (!SkipVerification(provider)) |
|
|
|
{ |
|
|
|
image.CompareToOriginal(provider, ImageComparer.Exact); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Png.Interlaced, PixelTypes.Rgba32)] |
|
|
|
public void Decode_Interlaced_DoesNotThrow<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
@ -148,7 +154,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
image.DebugSave(provider); |
|
|
|
|
|
|
|
// Workaround a bug in mono-s System.Drawing PNG decoder. It can't deal with 48Bpp png-s :(
|
|
|
|
if (!TestEnvironment.IsLinux) |
|
|
|
if (!TestEnvironment.IsLinux && !TestEnvironment.IsMono) |
|
|
|
{ |
|
|
|
image.CompareToOriginal(provider, ImageComparer.Exact); |
|
|
|
} |
|
|
|
|