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 ImageSharp.PixelFormats;
using SixLabors.Primitives; using SixLabors.Primitives;
using Xunit; using Xunit;
/// <summary> /// <summary>
/// Class to perform simple image comparisons. /// Class to perform simple image comparisons.
/// </summary> /// </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 /// 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"/> /// The default undefined value is <see cref="DefaultScalingFactor"/>
/// </param> /// </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 TPixelA : struct, IPixel<TPixelA>
where TPixelB : struct, IPixel<TPixelB> 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] [Theory]
[WithTestPatternImages(nameof(RotateFlipValues), 100, 50, DefaultPixelType)] [WithTestPatternImages(nameof(RotateFlipValues), 100, 50, DefaultPixelType)]
[WithTestPatternImages(nameof(RotateFlipValues), 50, 100, 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> where TPixel : struct, IPixel<TPixel>
{ {
using (Image<TPixel> image = provider.GetImage()) 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()) using (PixelAccessor<TPixel> pixels = image.Lock())
{ {
BlackWhiteChecker(pixels); // top left BlackWhiteChecker(pixels); // top left
VirticalBars(pixels); // top right VerticalBars(pixels); // top right
TransparentGradients(pixels); // bottom left TransparentGradients(pixels); // bottom left
Rainbow(pixels); // bottom right Rainbow(pixels); // bottom right
} }
@ -71,7 +71,7 @@ namespace ImageSharp.Tests
/// Fills the top right quadrant with alternating solid vertical bars. /// Fills the top right quadrant with alternating solid vertical bars.
/// </summary> /// </summary>
/// <param name="pixels"></param> /// <param name="pixels"></param>
private static void VirticalBars(PixelAccessor<TPixel> pixels) private static void VerticalBars(PixelAccessor<TPixel> pixels)
{ {
// topLeft // topLeft
int left = pixels.Width / 2; 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> /// <typeparam name="TPixel">The pixel format</typeparam>
/// <param name="image">The image</param> /// <param name="image">The image</param>
/// <param name="provider">The image provider</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="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>( public static Image<TPixel> DebugSave<TPixel>(
this Image<TPixel> image, this Image<TPixel> image,
ITestImageProvider provider, ITestImageProvider provider,
object settings = null, object testOutputDetails = null,
string extension = "png", string extension = "png",
bool grayscale = false) bool grayscale = false)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
@ -36,37 +37,59 @@ namespace ImageSharp.Tests
{ {
return image; return image;
} }
// We are running locally then we want to save it out // We are running locally then we want to save it out
provider.Utility.SaveTestOutputFile( provider.Utility.SaveTestOutputFile(
image, image,
extension, extension,
testOutputDetails: settings, testOutputDetails: testOutputDetails,
grayscale: grayscale); grayscale: grayscale);
return image; 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>( public static Image<TPixel> CompareToReferenceOutput<TPixel>(
this Image<TPixel> image, this Image<TPixel> image,
ITestImageProvider provider, ITestImageProvider provider,
object settings = null, object testOutputDetails = null,
string extension = "png", string extension = "png",
bool monochrome1Bpp = false, bool grayscale = false,
float imageTheshold = ImageComparer.DefaultImageThreshold, float imageTheshold = ImageComparer.DefaultImageThreshold,
byte segmentThreshold = ImageComparer.DefaultSegmentThreshold, byte segmentThreshold = ImageComparer.DefaultSegmentThreshold,
int scalingFactor = ImageComparer.DefaultScalingFactor) int scalingFactor = ImageComparer.DefaultScalingFactor)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
string referenceOutputFile = provider.Utility.GetReferenceOutputFileName(extension, settings); string referenceOutputFile = provider.Utility.GetReferenceOutputFileName(extension, testOutputDetails);
if (!TestEnvironment.RunsOnCI) if (!TestEnvironment.RunsOnCI)
{ {
provider.Utility.SaveTestOutputFile( provider.Utility.SaveTestOutputFile(
image, image,
extension, extension,
testOutputDetails: settings, testOutputDetails: testOutputDetails,
grayscale: monochrome1Bpp); grayscale: grayscale);
} }
if (!File.Exists(referenceOutputFile)) if (!File.Exists(referenceOutputFile))

Loading…
Cancel
Save