Browse Source

validating tests for CropProcessor

af/merge-core
Anton Firszov 8 years ago
parent
commit
61529a35dc
  1. 1
      src/ImageSharp/Common/Helpers/ParallelFor.cs
  2. 24
      tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs
  3. 2
      tests/Images/External

1
src/ImageSharp/Common/Helpers/ParallelFor.cs

@ -2,7 +2,6 @@
using System.Buffers;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Memory;
using SixLabors.Memory;
namespace SixLabors.ImageSharp

24
tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs

@ -1,24 +1,34 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
[GroupOutput("Transforms")]
public class CropTest : FileTestBase
{
[Theory]
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)]
public void ImageShouldCrop<TPixel>(TestImageProvider<TPixel> provider)
[WithTestPatternImages(70, 30, PixelTypes.Rgba32, 0, 0, 70, 30)]
[WithTestPatternImages(50, 50, PixelTypes.Rgba32, -1, -1, 100, 200)]
[WithTestPatternImages(30, 70, PixelTypes.Rgba32, 7, 13, 20, 50)]
public void Crop<TPixel>(TestImageProvider<TPixel> provider, int x, int y, int w, int h)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Mutate(x => x.Crop(image.Width / 2, image.Height / 2));
image.DebugSave(provider);
}
var rect = new Rectangle(x, y, w, h);
FormattableString info = $"X{x}Y{y}.W{w}H{h}";
provider.RunValidatingProcessorTest(
ctx => ctx.Crop(rect),
info,
appendPixelTypeToFileName: false,
comparer: ImageComparer.Exact);
}
}
}

2
tests/Images/External

@ -1 +1 @@
Subproject commit 6abc3bc0ac253a24c9e88e68d7b7d853350a85da
Subproject commit 2841a79efd68d47c6552ce857869eb0d80f8de75
Loading…
Cancel
Save