Browse Source

Add test + references

pull/2322/head
James Jackson-South 3 years ago
parent
commit
8a291f61fe
  1. 38
      tests/ImageSharp.Tests/Drawing/DrawImageTests.cs
  2. 3
      tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_10_10.png
  3. 3
      tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_25_50.png
  4. 3
      tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_50_25.png
  5. 3
      tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_50_50.png

38
tests/ImageSharp.Tests/Drawing/DrawImageTests.cs

@ -138,6 +138,33 @@ public class DrawImageTests
appendSourceFileOrDescription: false);
}
[Theory]
[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 10, 10)]
[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 50, 25)]
[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 25, 50)]
[WithSolidFilledImages(100, 100, "White", PixelTypes.Rgba32, 50, 50)]
public void WorksWithDifferentBounds(TestImageProvider<Rgba32> provider, int width, int height)
{
using Image<Rgba32> background = provider.GetImage();
using Image<Rgba32> overlay = new(50, 50);
Assert.True(overlay.DangerousTryGetSinglePixelMemory(out Memory<Rgba32> overlayMem));
overlayMem.Span.Fill(Color.Black);
background.Mutate(c => c.DrawImage(overlay, new Rectangle(0, 0, width, height), PixelColorBlendingMode.Normal, 1F));
background.DebugSave(
provider,
testOutputDetails: $"{width}_{height}",
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
background.CompareToReferenceOutput(
provider,
testOutputDetails: $"{width}_{height}",
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
}
[Theory]
[WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)]
public void DrawTransformed<TPixel>(TestImageProvider<TPixel> provider)
@ -158,12 +185,12 @@ public class DrawImageTests
Point position = new((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2);
image.Mutate(x => x.DrawImage(blend, position, .75F));
image.DebugSave(provider, appendSourceFileOrDescription: false, appendPixelTypeToFileName: false);
image.DebugSave(provider, appendPixelTypeToFileName: false, appendSourceFileOrDescription: false);
image.CompareToReferenceOutput(
ImageComparer.TolerantPercentage(0.002f),
provider,
appendSourceFileOrDescription: false,
appendPixelTypeToFileName: false);
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false);
}
[Theory]
@ -179,9 +206,6 @@ public class DrawImageTests
Assert.Contains("does not overlap", ex.ToString());
void Test()
{
background.Mutate(context => context.DrawImage(overlay, new Point(x, y), new GraphicsOptions()));
}
void Test() => background.Mutate(context => context.DrawImage(overlay, new Point(x, y), new GraphicsOptions()));
}
}

3
tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_10_10.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f353ee06664a6ff27c533af63cffb9eac4917103ba0b7fff9084fb4d2d42fed7
size 155

3
tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_25_50.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:af198da8f611eb97f3e4e358cb097cd292771d52e991de76495f073c1f1b9338
size 154

3
tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_50_25.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:35bda87f28e03c5ed0d45412e367fae9b04b7684f5242dc20e7709e8ed71cd86
size 156

3
tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/WorksWithDifferentBounds_50_50.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f8b9ff745592bb0e0a365cb0985a5519bf567fc73a09211c88bcda51356f9202
size 155
Loading…
Cancel
Save