Browse Source

docs & formatting

pull/298/head
Anton Firszov 9 years ago
parent
commit
e01cc2bb16
  1. 10
      tests/ImageSharp.Tests/ImageComparer.cs
  2. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs
  3. 4
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  4. 41
      tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

10
tests/ImageSharp.Tests/ImageComparer.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Tests
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
/// <summary>
/// Class to perform simple image comparisons.
/// </summary>
@ -42,7 +42,13 @@ namespace ImageSharp.Tests
/// This is a sampling factor we sample a grid of average pixels <paramref name="scalingFactor"/> width by <paramref name="scalingFactor"/> high
/// The default undefined value is <see cref="DefaultScalingFactor"/>
/// </param>
public static void EnsureProcessorChangesAreConstrained<TPixelA, TPixelB>(Image<TPixelA> expected, Image<TPixelB> actual, Rectangle bounds, float imageTheshold = DefaultImageThreshold, byte segmentThreshold = DefaultSegmentThreshold, int scalingFactor = DefaultScalingFactor)
public static void EnsureProcessorChangesAreConstrained<TPixelA, TPixelB>(
Image<TPixelA> expected,
Image<TPixelB> actual,
Rectangle bounds,
float imageTheshold = DefaultImageThreshold,
byte segmentThreshold = DefaultSegmentThreshold,
int scalingFactor = DefaultScalingFactor)
where TPixelA : struct, IPixel<TPixelA>
where TPixelB : struct, IPixel<TPixelB>
{

2
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<TPixel>(TestImageProvider<TPixel> provider, RotateType rotateType, FlipType flipType)
public void RotateFlip<TPixel>(TestImageProvider<TPixel> provider, RotateType rotateType, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())

4
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs

@ -62,7 +62,7 @@ namespace ImageSharp.Tests
using (PixelAccessor<TPixel> 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.
/// </summary>
/// <param name="pixels"></param>
private static void VirticalBars(PixelAccessor<TPixel> pixels)
private static void VerticalBars(PixelAccessor<TPixel> pixels)
{
// topLeft
int left = pixels.Width / 2;

41
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

@ -22,12 +22,13 @@ namespace ImageSharp.Tests
/// <typeparam name="TPixel">The pixel format</typeparam>
/// <param name="image">The image</param>
/// <param name="provider">The image provider</param>
/// <param name="settings">The settings</param>
/// <param name="testOutputDetails">Details to be concatenated to the test output file, describing the parameters of the test.</param>
/// <param name="extension">The extension</param>
/// /// <param name="grayscale">A boolean indicating whether we should save a smaller in size.</param>
public static Image<TPixel> DebugSave<TPixel>(
this Image<TPixel> image,
ITestImageProvider provider,
object settings = null,
object testOutputDetails = null,
string extension = "png",
bool grayscale = false)
where TPixel : struct, IPixel<TPixel>
@ -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;
}
/// <summary>
/// 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 <see cref="DebugSave{TPixel}(Image{TPixel}, ITestImageProvider, object, string, bool)"/>.
/// </summary>
/// <typeparam name="TPixel">The pixel format</typeparam>
/// <param name="image">The image</param>
/// <param name="provider">The image provider</param>
/// <param name="testOutputDetails">Details to be concatenated to the test output file, describing the parameters of the test.</param>
/// <param name="extension">The extension</param>
/// <param name="grayscale">A boolean indicating whether we should debug save + compare against a grayscale image, smaller in size.</param>
/// <param name="imageTheshold">
/// The threshold for the percentage difference where the images are asumed to be the same.
/// The default/undefined value is <see cref="ImageComparer.DefaultImageThreshold"/>
/// </param>
/// <param name="segmentThreshold">
/// The threshold of the individual segments before it acumulates towards the overall difference.
/// The default undefined value is <see cref="ImageComparer.DefaultSegmentThreshold"/>
/// </param>
/// <param name="scalingFactor">
/// This is a sampling factor we sample a grid of average pixels <paramref name="scalingFactor"/> width by <paramref name="scalingFactor"/> high
/// The default undefined value is <see cref="ImageComparer.DefaultScalingFactor"/>
/// </param>
/// <returns></returns>
public static Image<TPixel> CompareToReferenceOutput<TPixel>(
this Image<TPixel> 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<TPixel>
{
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))

Loading…
Cancel
Save