Browse Source

turning PorterDuffOutputIsCorrect() into a [Theory]

af/merge-core
Anton Firszov 9 years ago
parent
commit
37e6c6aac8
  1. 27
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs

27
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs

@ -1,18 +1,19 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using Xunit;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
{ {
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using Xunit;
public class PorterDuffCompositorTests public class PorterDuffCompositorTests
{ {
// TODO: Add other modes to compare. // TODO: Add other modes to compare.
private static PixelBlenderMode[] CompositingOperators = public static readonly TheoryData<PixelBlenderMode> CompositingOperators =
new TheoryData<PixelBlenderMode>
{ {
PixelBlenderMode.Src, PixelBlenderMode.Src,
PixelBlenderMode.Atop, PixelBlenderMode.Atop,
@ -28,8 +29,9 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
PixelBlenderMode.Xor PixelBlenderMode.Xor
}; };
[Fact] [Theory]
public void PorterDuffOutputIsCorrect() [MemberData(nameof(CompositingOperators))]
public void PorterDuffOutputIsCorrect(PixelBlenderMode mode)
{ {
string path = TestEnvironment.CreateOutputDirectory("PorterDuff"); string path = TestEnvironment.CreateOutputDirectory("PorterDuff");
var srcFile = TestFile.Create(TestImages.Png.PDSrc); var srcFile = TestFile.Create(TestImages.Png.PDSrc);
@ -38,13 +40,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
using (Image<Rgba32> src = srcFile.CreateImage()) using (Image<Rgba32> src = srcFile.CreateImage())
using (Image<Rgba32> dest = destFile.CreateImage()) using (Image<Rgba32> dest = destFile.CreateImage())
{ {
foreach (PixelBlenderMode m in CompositingOperators) using (Image<Rgba32> res = dest.Clone(x => x.Blend(src, new GraphicsOptions { BlenderMode = mode })))
{
using (Image<Rgba32> res = dest.Clone(x => x.Blend(src, new GraphicsOptions { BlenderMode = m })))
{ {
// TODO: Generate reference files once this works. // TODO: Generate reference files once this works.
res.Save($"{path}/{m}.png"); res.Save($"{path}/{mode}.png");
}
} }
} }
} }

Loading…
Cancel
Save