Browse Source

separate [Theory] for 48Bpp, that could be skipped on Linux!

af/merge-core
Anton Firszov 9 years ago
parent
commit
77b8b846f7
  1. 32
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  2. 7
      tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs

32
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; 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.Splash, TestImages.Png.Indexed, TestImages.Png.Interlaced, TestImages.Png.FilterVar,
TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.Rgb48Bpp, TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.SnakeGame
TestImages.Png.Rgb48BppInterlaced, TestImages.Png.SnakeGame
}; };
public static readonly string[] TestImages48Bpp =
{
TestImages.Png.Rgb48Bpp, TestImages.Png.Rgb48BppInterlaced
};
[Theory] [Theory]
[WithFileCollection(nameof(TestFiles), PixelTypes.Rgba32)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)]
public void Decode<TPixel>(TestImageProvider<TPixel> provider) public void Decode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
@ -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<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> 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] [Theory]
[WithFile(TestImages.Png.Splash, PixelTypes)] [WithFile(TestImages.Png.Splash, PixelTypes)]
public void Decoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider) public void Decoder_IsNotBoundToSinglePixelType<TPixel>(TestImageProvider<TPixel> provider)

7
tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs

@ -10,7 +10,9 @@ using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
namespace SixLabors.ImageSharp.Tests namespace SixLabors.ImageSharp.Tests
{ {
using System.Runtime.InteropServices;
public static class TestEnvironment public static class TestEnvironment
{ {
private const string ImageSharpSolutionFileName = "ImageSharp.sln"; private const string ImageSharpSolutionFileName = "ImageSharp.sln";
@ -129,5 +131,8 @@ namespace SixLabors.ImageSharp.Tests
IImageFormat format = Configuration.FindFormatByFileExtension(extension); IImageFormat format = Configuration.FindFormatByFileExtension(extension);
return format; return format;
} }
internal static bool IsLinux =>
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
} }
} }
Loading…
Cancel
Save