diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 5dac59d69..dd3019029 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -3,15 +3,33 @@ // Licensed under the Apache License, Version 2.0. // +// ReSharper disable InconsistentNaming namespace ImageSharp.Tests { using System.Text; using Xunit; using ImageSharp.Formats; + using ImageSharp.PixelFormats; public class GifDecoderTests { + private const PixelTypes PixelTypes = Tests.PixelTypes.StandardImageClass | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; + + public static readonly string[] TestFiles = { TestImages.Gif.Giphy, TestImages.Gif.Rings, TestImages.Gif.Trans }; + + [Theory] + [WithFileCollection(nameof(TestFiles), PixelTypes)] + public void DecodeAndReSave(TestImageProvider imageProvider) + where TPixel : struct, IPixel + { + using (Image image = imageProvider.GetImage()) + { + imageProvider.Utility.SaveTestOutputFile(image, "bmp"); + imageProvider.Utility.SaveTestOutputFile(image, "gif"); + } + } + [Fact] public void Decode_IgnoreMetadataIsFalse_CommentsAreRead() { diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 897778bc3..c657cde96 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -9,9 +9,23 @@ namespace ImageSharp.Tests using Xunit; using ImageSharp.Formats; + using ImageSharp.PixelFormats; public class GifEncoderTests { + private const PixelTypes PixelTypes = Tests.PixelTypes.StandardImageClass | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes)] + public void EncodeGeneratedPatterns(TestImageProvider provider) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage()) + { + provider.Utility.SaveTestOutputFile(image, "gif", new GifEncoder()); + } + } + [Fact] public void Encode_IgnoreMetadataIsFalse_CommentsAreWritten() { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index e03d42c9a..d97b258dd 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -9,9 +9,29 @@ namespace ImageSharp.Tests using Xunit; using ImageSharp.Formats; + using ImageSharp.PixelFormats; public class PngDecoderTests { + private const PixelTypes PixelTypes = Tests.PixelTypes.StandardImageClass | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; + + public static readonly string[] TestFiles = + { + TestImages.Png.Splash, TestImages.Png.Indexed, TestImages.Png.Interlaced, TestImages.Png.FilterVar, + TestImages.Png.ChunkLength1, TestImages.Png.ChunkLength2 + }; + + [Theory] + [WithFileCollection(nameof(TestFiles), PixelTypes)] + public void DecodeAndReSave(TestImageProvider imageProvider) + where TPixel : struct, IPixel + { + using (Image image = imageProvider.GetImage()) + { + imageProvider.Utility.SaveTestOutputFile(image, "bmp"); + } + } + [Fact] public void Decode_IgnoreMetadataIsFalse_TextChunckIsRead() { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index ae4dfc1e9..195eaba10 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -7,6 +7,7 @@ using ImageSharp.Formats; namespace ImageSharp.Tests { + using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -17,6 +18,29 @@ namespace ImageSharp.Tests public class PngEncoderTests : FileTestBase { + private const PixelTypes PixelTypes = Tests.PixelTypes.StandardImageClass | Tests.PixelTypes.RgbaVector | Tests.PixelTypes.Argb32; + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes, PngColorType.RgbWithAlpha)] + [WithTestPatternImages(100, 100, PixelTypes, PngColorType.Rgb)] + [WithTestPatternImages(100, 100, PixelTypes, PngColorType.Palette)] + [WithTestPatternImages(100, 100, PixelTypes, PngColorType.Grayscale)] + [WithTestPatternImages(100, 100, PixelTypes, PngColorType.GrayscaleWithAlpha)] + public void EncodeGeneratedPatterns(TestImageProvider provider, PngColorType pngColorType) + where TPixel : struct, IPixel + { + using (Image image = provider.GetImage()) + { + PngEncoderOptions options = new PngEncoderOptions() + { + PngColorType = pngColorType + }; + provider.Utility.TestName += "_" + pngColorType; + + provider.Utility.SaveTestOutputFile(image, "png", new PngEncoder(), options); + } + } + [Theory] [WithBlankImages(1, 1, PixelTypes.All)] public void WritesFileMarker(TestImageProvider provider)