From 106fa8d85ea9c040526ba672c822ecf599536b6a Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 19 Aug 2017 15:39:05 +0200 Subject: [PATCH] separate [Theory] for 48Bpp, that could be skipped on Linux! --- .../Formats/Png/PngDecoderTests.cs | 32 ++++++++++++++++--- .../TestUtilities/TestEnvironment.cs | 7 +++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index eff705d819..3e4415a4d9 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -17,15 +17,20 @@ namespace SixLabors.ImageSharp.Tests { private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32 | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; - public static readonly string[] TestFiles = + public static readonly string[] CommonTestImages = { TestImages.Png.Splash, TestImages.Png.Indexed, TestImages.Png.Interlaced, TestImages.Png.FilterVar, - TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.Rgb48Bpp, - TestImages.Png.Rgb48BppInterlaced, TestImages.Png.SnakeGame + TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.SnakeGame }; + public static readonly string[] TestImages48Bpp = + { + TestImages.Png.Rgb48Bpp, TestImages.Png.Rgb48BppInterlaced + }; + + [Theory] - [WithFileCollection(nameof(TestFiles), PixelTypes.Rgba32)] + [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] public void Decode(TestImageProvider provider) where TPixel : struct, IPixel { @@ -36,6 +41,25 @@ namespace SixLabors.ImageSharp.Tests } } + // TODO: We need to decode these into Rgba64 properly, and do 'CompareToOriginal' in a Rgba64 mode! (See #285) + [Theory] + [WithFileCollection(nameof(TestImages48Bpp), PixelTypes.Rgba32)] + public void Decode_48Bpp(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage(new PngDecoder())) + { + image.DebugSave(provider); + + // Workaround a bug in mono-s System.Drawing PNG decoder. It can't deal with 48Bpp png-s :( + if (!TestEnvironment.IsLinux) + { + image.CompareToOriginal(provider, ImageComparer.Exact); + } + } + } + + [Theory] [WithFile(TestImages.Png.Splash, PixelTypes)] public void Decoder_IsNotBoundToSinglePixelType(TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 1f8930f84b..7265fd9a1c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -10,7 +10,9 @@ using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; namespace SixLabors.ImageSharp.Tests -{ +{ + using System.Runtime.InteropServices; + public static class TestEnvironment { private const string ImageSharpSolutionFileName = "ImageSharp.sln"; @@ -129,5 +131,8 @@ namespace SixLabors.ImageSharp.Tests IImageFormat format = Configuration.FindFormatByFileExtension(extension); return format; } + + internal static bool IsLinux => + System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux); } } \ No newline at end of file