Skip to content

Commit

Permalink
Fix mac tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Apr 1, 2024
1 parent 1b154c8 commit 459f305
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions NAPS2.Sdk.Tests/Images/MacImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace NAPS2.Sdk.Tests.Images;

public class MacImageTests : ContextualTests
{
private readonly ImageContext _imageContext = new MacImageContext();

[Theory]
[InlineData(ImagePixelFormat.ARGB32)]
[InlineData(ImagePixelFormat.RGB24)]
Expand All @@ -21,7 +19,7 @@ public void UsesCorrectPixelFormat(ImagePixelFormat pixelFormat)
var nsImage = new NSImage();
var rep = MacBitmapHelper.CreateRep(100, 100, pixelFormat);
nsImage.AddRepresentation(rep);
var image = new MacImage(_imageContext, nsImage);
var image = new MacImage(nsImage);
Assert.Equal(pixelFormat, image.PixelFormat);
Assert.Equal(rep.Handle, image.Rep.Handle);
}
Expand All @@ -30,7 +28,7 @@ public void UsesCorrectPixelFormat(ImagePixelFormat pixelFormat)
public void ThrowsOnNoReps()
{
var nsImage = new NSImage();
Assert.Throws<ArgumentException>(() => new MacImage(_imageContext, nsImage));
Assert.Throws<ArgumentException>(() => new MacImage(nsImage));
}

[Fact]
Expand All @@ -39,7 +37,7 @@ public void ThrowsOnMultipleReps()
var nsImage = new NSImage();
nsImage.AddRepresentation(MacBitmapHelper.CreateRep(100, 100, ImagePixelFormat.ARGB32));
nsImage.AddRepresentation(MacBitmapHelper.CreateRep(100, 100, ImagePixelFormat.ARGB32));
Assert.Throws<ArgumentException>(() => new MacImage(_imageContext, nsImage));
Assert.Throws<ArgumentException>(() => new MacImage(nsImage));
}

[Theory]
Expand All @@ -55,7 +53,7 @@ public void ConvertsUnexpectedColorSpace(ImagePixelFormat pixelFormat)
: NSColorSpace.GenericGrayColorSpace;
rep = rep.ConvertingToColorSpace(colorSpace, NSColorRenderingIntent.Default);
nsImage.AddRepresentation(rep);
var image = new MacImage(_imageContext, nsImage);
var image = new MacImage(nsImage);
Assert.NotEqual(rep.Handle, image.Rep.Handle);
Assert.Equal(pixelFormat, image.PixelFormat);
}
Expand All @@ -66,7 +64,7 @@ public void ConvertsBlackColorSpace()
var nsImage = new NSImage();
var rep = new NSBitmapImageRep(IntPtr.Zero, 100, 100, 1, 1, false, false, NSColorSpace.DeviceBlack, 13, 1);
nsImage.AddRepresentation(rep);
var image = new MacImage(_imageContext, nsImage);
var image = new MacImage(nsImage);
Assert.NotEqual(rep.Handle, image.Rep.Handle);
Assert.Equal(ImagePixelFormat.Gray8, image.PixelFormat);
}
Expand All @@ -78,7 +76,7 @@ public void ConvertsUnsupportedPixelFormat()
var nsImage = new NSImage();
var rep = Create64BitRepFromImage(referenceImage);
nsImage.AddRepresentation(rep);
var image = new MacImage(_imageContext, nsImage);
var image = new MacImage(nsImage);
Assert.NotEqual(rep.Handle, image.Rep.Handle);
ImageAsserts.Similar(referenceImage, image);
}
Expand Down

0 comments on commit 459f305

Please sign in to comment.