From e01cc2bb1639fda94da1bd58c0e265ae46dbe7f8 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 15 Aug 2017 15:34:34 +0200 Subject: [PATCH] docs & formatting --- tests/ImageSharp.Tests/ImageComparer.cs | 10 ++++- .../Processors/Transforms/RotateFlipTests.cs | 2 +- .../ImageProviders/TestPatternProvider.cs | 4 +- .../TestUtilities/TestImageExtensions.cs | 41 +++++++++++++++---- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/tests/ImageSharp.Tests/ImageComparer.cs b/tests/ImageSharp.Tests/ImageComparer.cs index 7df7a14c4..53e5f609c 100644 --- a/tests/ImageSharp.Tests/ImageComparer.cs +++ b/tests/ImageSharp.Tests/ImageComparer.cs @@ -11,7 +11,7 @@ namespace ImageSharp.Tests using ImageSharp.PixelFormats; using SixLabors.Primitives; using Xunit; - + /// /// Class to perform simple image comparisons. /// @@ -42,7 +42,13 @@ namespace ImageSharp.Tests /// This is a sampling factor we sample a grid of average pixels width by high /// The default undefined value is /// - public static void EnsureProcessorChangesAreConstrained(Image expected, Image actual, Rectangle bounds, float imageTheshold = DefaultImageThreshold, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor) + public static void EnsureProcessorChangesAreConstrained( + Image expected, + Image actual, + Rectangle bounds, + float imageTheshold = DefaultImageThreshold, + byte segmentThreshold = DefaultSegmentThreshold, + int scalingFactor = DefaultScalingFactor) where TPixelA : struct, IPixel where TPixelB : struct, IPixel { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index 452b39cfc..6179bfb18 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -27,7 +27,7 @@ namespace ImageSharp.Tests.Processing.Processors.Transforms [Theory] [WithTestPatternImages(nameof(RotateFlipValues), 100, 50, DefaultPixelType)] [WithTestPatternImages(nameof(RotateFlipValues), 50, 100, DefaultPixelType)] - public void ImageShouldRotateFlip(TestImageProvider provider, RotateType rotateType, FlipType flipType) + public void RotateFlip(TestImageProvider provider, RotateType rotateType, FlipType flipType) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs index f25beb726..66fc7408e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs @@ -62,7 +62,7 @@ namespace ImageSharp.Tests using (PixelAccessor pixels = image.Lock()) { BlackWhiteChecker(pixels); // top left - VirticalBars(pixels); // top right + VerticalBars(pixels); // top right TransparentGradients(pixels); // bottom left Rainbow(pixels); // bottom right } @@ -71,7 +71,7 @@ namespace ImageSharp.Tests /// Fills the top right quadrant with alternating solid vertical bars. /// /// - private static void VirticalBars(PixelAccessor pixels) + private static void VerticalBars(PixelAccessor pixels) { // topLeft int left = pixels.Width / 2; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 35a84b86b..fbeb1d4d4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -22,12 +22,13 @@ namespace ImageSharp.Tests /// The pixel format /// The image /// The image provider - /// The settings + /// Details to be concatenated to the test output file, describing the parameters of the test. /// The extension + /// /// A boolean indicating whether we should save a smaller in size. public static Image DebugSave( this Image image, ITestImageProvider provider, - object settings = null, + object testOutputDetails = null, string extension = "png", bool grayscale = false) where TPixel : struct, IPixel @@ -36,37 +37,59 @@ namespace ImageSharp.Tests { return image; } - // We are running locally then we want to save it out provider.Utility.SaveTestOutputFile( image, extension, - testOutputDetails: settings, + testOutputDetails: testOutputDetails, grayscale: grayscale); return image; } + /// + /// Compares the image against the expected Reference output, throws an exception if the images are not similar enough. + /// The output file should be named identically to the output produced by . + /// + /// The pixel format + /// The image + /// The image provider + /// Details to be concatenated to the test output file, describing the parameters of the test. + /// The extension + /// A boolean indicating whether we should debug save + compare against a grayscale image, smaller in size. + /// + /// The threshold for the percentage difference where the images are asumed to be the same. + /// The default/undefined value is + /// + /// + /// The threshold of the individual segments before it acumulates towards the overall difference. + /// The default undefined value is + /// + /// + /// This is a sampling factor we sample a grid of average pixels width by high + /// The default undefined value is + /// + /// public static Image CompareToReferenceOutput( this Image image, ITestImageProvider provider, - object settings = null, + object testOutputDetails = null, string extension = "png", - bool monochrome1Bpp = false, + bool grayscale = false, float imageTheshold = ImageComparer.DefaultImageThreshold, byte segmentThreshold = ImageComparer.DefaultSegmentThreshold, int scalingFactor = ImageComparer.DefaultScalingFactor) where TPixel : struct, IPixel { - string referenceOutputFile = provider.Utility.GetReferenceOutputFileName(extension, settings); + string referenceOutputFile = provider.Utility.GetReferenceOutputFileName(extension, testOutputDetails); if (!TestEnvironment.RunsOnCI) { provider.Utility.SaveTestOutputFile( image, extension, - testOutputDetails: settings, - grayscale: monochrome1Bpp); + testOutputDetails: testOutputDetails, + grayscale: grayscale); } if (!File.Exists(referenceOutputFile))