From 4b56f23c7caeeb955e100cad38c964329dd4c502 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 24 Nov 2017 01:42:56 +0100 Subject: [PATCH] testing with all resamplers --- .../Processors/Transforms/RotateTests.cs | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index 49fe8952be..c30770ada9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -8,6 +8,9 @@ using Xunit; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms { + using System; + using System.Reflection; + public class RotateTests : FileTestBase { public static readonly TheoryData RotateFloatValues @@ -26,6 +29,25 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms RotateType.Rotate270 }; + public static readonly TheoryData ResmplerNames = new TheoryData + { + nameof(KnownResamplers.Bicubic), + nameof(KnownResamplers.Box), + nameof(KnownResamplers.CatmullRom), + nameof(KnownResamplers.Hermite), + nameof(KnownResamplers.Lanczos2), + nameof(KnownResamplers.Lanczos3), + nameof(KnownResamplers.Lanczos5), + nameof(KnownResamplers.Lanczos8), + nameof(KnownResamplers.MitchellNetravali), + nameof(KnownResamplers.NearestNeighbor), + nameof(KnownResamplers.Robidoux), + nameof(KnownResamplers.RobidouxSharp), + nameof(KnownResamplers.Spline), + nameof(KnownResamplers.Triangle), + nameof(KnownResamplers.Welch), + }; + [Theory] [WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)] [WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)] @@ -40,15 +62,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms } [Theory] - [WithTestPatternImages(nameof(RotateFloatValues), 100, 50, DefaultPixelType)] - [WithTestPatternImages(nameof(RotateFloatValues), 50, 100, DefaultPixelType)] - public void RotateWithSampler(TestImageProvider provider, float value) + [WithTestPatternImages(nameof(ResmplerNames), 100, 50, DefaultPixelType)] + [WithTestPatternImages(nameof(ResmplerNames), 50, 100, DefaultPixelType)] + public void RotateWithSampler(TestImageProvider provider, string resamplerName) where TPixel : struct, IPixel { + IResampler resampler = GetResampler(resamplerName); + using (Image image = provider.GetImage()) { - image.Mutate(x => x.Rotate(value, KnownResamplers.Triangle)); - image.DebugSave(provider, string.Join("_", value, "triangle")); + image.Mutate(x => x.Rotate(50, resampler)); + image.DebugSave(provider, resamplerName); } } @@ -64,5 +88,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms image.DebugSave(provider, value); } } + + private static IResampler GetResampler(string name) + { + PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); + + if (property == null) + { + throw new Exception("Invalid property name!"); + } + + return (IResampler) property.GetValue(null); + } } } \ No newline at end of file