Browse Source

there is no need for separate Apply****InBox tests,

having one in FilterTest is sufficient
pull/404/head
Anton Firszov 8 years ago
parent
commit
38a3e38c35
  1. 20
      tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs
  2. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs
  3. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs
  4. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs
  5. 31
      tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs
  6. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs
  7. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs
  8. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs
  9. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs
  10. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs
  11. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs
  12. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs
  13. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs
  14. 19
      tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs
  15. 3
      tests/ImageSharp.Tests/TestUtilities/TestUtils.cs
  16. 2
      tests/Images/External

20
tests/ImageSharp.Tests/Processing/Processors/Filters/BlackWhiteTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -19,23 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(ctx => ctx.BlackWhite());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplyBlackWhiteFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
// TODO: We need a DRY-refactor on these tests for all Filter tests!
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.BlackWhite(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
@ -26,22 +24,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
{
provider.RunValidatingProcessorTest(ctx => ctx.Brightness(value), value);
}
[Theory]
[WithTestPatternImages(nameof(BrightnessValues), 48, 48, PixelTypes.Rgba32)]
public void ApplyBrightnessFilterInBox<TPixel>(TestImageProvider<TPixel> provider, float value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Brightness(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs

@ -3,9 +3,7 @@
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.Filters
@ -33,22 +31,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString());
}
[Theory]
[WithTestPatternImages(nameof(ColorBlindnessFilters), 48, 48, PixelTypes.Rgba32)]
public void ApplyColorBlindnessFilterInBox<TPixel>(TestImageProvider<TPixel> provider, ColorBlindness colorBlindness)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.ColorBlindness(colorBlindness, bounds));
image.DebugSave(provider, colorBlindness.ToString());
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
@ -26,22 +24,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
{
provider.RunValidatingProcessorTest(x => x.Contrast(value), value);
}
[Theory]
[WithTestPatternImages(nameof(ContrastValues), 48, 48, PixelTypes.Rgba32)]
public void ApplyContrastFilterInBox<TPixel>(TestImageProvider<TPixel> provider, float value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Contrast(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

31
tests/ImageSharp.Tests/Processing/Processors/Filters/FilterTest.cs

@ -21,10 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
public void ApplyFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
Matrix4x4 brightness = MatrixFilters.CreateBrightnessFilter(0.9F);
Matrix4x4 hue = MatrixFilters.CreateHueFilter(180F);
Matrix4x4 saturation = MatrixFilters.CreateSaturateFilter(1.5F);
Matrix4x4 m = brightness * hue * saturation;
Matrix4x4 m = CreateCombinedTestFilterMatrix();
provider.RunValidatingProcessorTest(x => x.Filter(m));
}
@ -34,19 +31,19 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
public void ApplyFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2);
Matrix4x4 brightness = MatrixFilters.CreateBrightnessFilter(0.9F);
Matrix4x4 hue = MatrixFilters.CreateHueFilter(180F);
Matrix4x4 saturation = MatrixFilters.CreateSaturateFilter(1.5F);
image.Mutate(x => x.Filter(brightness * hue * saturation, bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
Matrix4x4 m = CreateCombinedTestFilterMatrix();
provider.RunRectangleConstrainedValidatingProcessorTest((x, b) => x.Filter(m, b));
}
private static Matrix4x4 CreateCombinedTestFilterMatrix()
{
Matrix4x4 brightness = MatrixFilters.CreateBrightnessFilter(0.9F);
Matrix4x4 hue = MatrixFilters.CreateHueFilter(180F);
Matrix4x4 saturation = MatrixFilters.CreateSaturateFilter(1.5F);
Matrix4x4 m = brightness * hue * saturation;
return m;
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs

@ -4,9 +4,7 @@
using SixLabors.ImageSharp.Advanced;
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.Filters
@ -31,22 +29,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Grayscale(value), value);
}
[Theory]
[WithTestPatternImages(nameof(GrayscaleModeTypes), 48, 48, PixelTypes.Rgba32)]
public void ApplyGrayscaleFilterInBox<TPixel>(TestImageProvider<TPixel> provider, GrayscaleMode value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Grayscale(value, bounds));
image.DebugSave(provider, value.ToString());
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -26,22 +24,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Hue(value), value);
}
[Theory]
[WithTestPatternImages(nameof(HueValues), 48, 48, PixelTypes.Rgba32)]
public void ApplyHueFilterInBox<TPixel>(TestImageProvider<TPixel> provider, int value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Hue(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/InvertTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
@ -19,22 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
{
provider.RunValidatingProcessorTest(x => x.Invert());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplyInvertFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Invert(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/KodachromeTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -19,22 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Kodachrome());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplyKodachromeFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Kodachrome(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/LomographTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -19,22 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Lomograph());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplyLomographFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Lomograph(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
@ -26,22 +24,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects
{
provider.RunValidatingProcessorTest(x => x.Opacity(value), value);
}
[Theory]
[WithTestPatternImages(nameof(AlphaValues), 48, 48, PixelTypes.Rgba32)]
public void ApplyAlphaFilterInBox<TPixel>(TestImageProvider<TPixel> provider, float value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Opacity(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/PolaroidTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -19,22 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Polaroid());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplyPolaroidFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Polaroid(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -26,22 +24,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Saturate(value), value);
}
[Theory]
[WithTestPatternImages(nameof(SaturationValues), 48, 48, PixelTypes.Rgba32)]
public void ApplySaturationFilterInBox<TPixel>(TestImageProvider<TPixel> provider, float value)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Saturate(value, bounds));
image.DebugSave(provider, value);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

19
tests/ImageSharp.Tests/Processing/Processors/Filters/SepiaTest.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
@ -19,22 +17,5 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters
{
provider.RunValidatingProcessorTest(x => x.Sepia());
}
[Theory]
[WithTestPatternImages(48, 48, PixelTypes.Rgba32)]
public void ApplySepiaFilterInBox<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> source = provider.GetImage())
using (Image<TPixel> image = source.Clone())
{
var bounds = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Sepia(bounds));
image.DebugSave(provider);
ImageComparer.Tolerant().VerifySimilarityIgnoreRegion(source, image, bounds);
}
}
}
}

3
tests/ImageSharp.Tests/TestUtilities/TestUtils.cs

@ -165,6 +165,9 @@ namespace SixLabors.ImageSharp.Tests
}
}
/// <summary>
/// Same as <see cref="RunValidatingProcessorTest{TPixel}"/> but with an additional <see cref="Rectangle"/> parameter passed to 'process'
/// </summary>
internal static void RunRectangleConstrainedValidatingProcessorTest<TPixel>(
this TestImageProvider<TPixel> provider,
Action<IImageProcessingContext<TPixel>, Rectangle> process,

2
tests/Images/External

@ -1 +1 @@
Subproject commit e12e75f12925de1b88dc7e564c509ee896aa5f53
Subproject commit ddc4045926bb0331be8c1785d9adf5f76dc4e52e
Loading…
Cancel
Save