Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Microsoft.Maui-dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maui.Controls.Sample.Embedd
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls.ManualTests", "src\Controls\tests\ManualTests\Controls.ManualTests.csproj", "{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils.MagickNet", "src\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj", "{6840F154-F7E6-4E03-9767-D2722ECEA483}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils", "src\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj", "{8E18E72E-9C53-4F20-B8C1-2677BF813DD3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -623,6 +627,14 @@ Global
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Release|Any CPU.Build.0 = Release|Any CPU
{6840F154-F7E6-4E03-9767-D2722ECEA483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6840F154-F7E6-4E03-9767-D2722ECEA483}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6840F154-F7E6-4E03-9767-D2722ECEA483}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6840F154-F7E6-4E03-9767-D2722ECEA483}.Release|Any CPU.Build.0 = Release|Any CPU
{8E18E72E-9C53-4F20-B8C1-2677BF813DD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E18E72E-9C53-4F20-B8C1-2677BF813DD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E18E72E-9C53-4F20-B8C1-2677BF813DD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E18E72E-9C53-4F20-B8C1-2677BF813DD3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -734,6 +746,8 @@ Global
{55905937-1399-46DB-BA38-E426801CB759} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9} = {E1082E26-D700-4127-9329-66D673FD2D55}
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C} = {25D0D27A-C5FE-443D-8B65-D6C987F4A80E}
{6840F154-F7E6-4E03-9767-D2722ECEA483} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{8E18E72E-9C53-4F20-B8C1-2677BF813DD3} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
14 changes: 8 additions & 6 deletions Microsoft.Maui-mac.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
"src\\BlazorWebView\\tests\\DeviceTests\\MauiBlazorWebView.DeviceTests.csproj",
"src\\Controls\\Foldable\\src\\Controls.Foldable.csproj",
"src\\Controls\\Maps\\src\\Controls.Maps.csproj",
"src\\Controls\\samples\\Controls.Sample.Embedding\\Maui.Controls.Sample.Embedding.csproj",
"src\\Controls\\samples\\Controls.Sample.Profiling\\Maui.Controls.Sample.Profiling.csproj",
"src\\Controls\\samples\\Controls.Sample.Sandbox\\Maui.Controls.Sample.Sandbox.csproj",
"src\\Controls\\samples\\Controls.Sample\\Maui.Controls.Sample.csproj",
"src\\Controls\\samples\\Controls.Sample.Embedding\\Maui.Controls.Sample.Embedding.csproj",
"src\\Controls\\tests\\TestCases.HostApp\\Controls.TestCases.HostApp.csproj",
"src\\Controls\\src\\Build.Tasks\\Controls.Build.Tasks.csproj",
"src\\Controls\\src\\Core.Design\\Controls.Core.Design.csproj",
"src\\Controls\\src\\Core\\Controls.Core.csproj",
Expand All @@ -23,15 +22,16 @@
"src\\Controls\\tests\\Core.UnitTests\\Controls.Core.UnitTests.csproj",
"src\\Controls\\tests\\CustomAttributes\\Controls.CustomAttributes.csproj",
"src\\Controls\\tests\\DeviceTests\\Controls.DeviceTests.csproj",
"src\\Controls\\tests\\SourceGen.UnitTests\\SourceGen.UnitTests.csproj",
"src\\Controls\\tests\\TestCases.Android.Tests\\Controls.TestCases.Android.Tests.csproj",
"src\\Controls\\tests\\TestCases.HostApp\\Controls.TestCases.HostApp.csproj",
"src\\Controls\\tests\\TestCases.iOS.Tests\\Controls.TestCases.iOS.Tests.csproj",
"src\\Controls\\tests\\TestCases.Mac.Tests\\Controls.TestCases.Mac.Tests.csproj",
"src\\Controls\\tests\\TestCases.Shared.Tests\\Controls.TestCases.Shared.Tests.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.ExternalAssembly\\Controls.Xaml.UnitTests.ExternalAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.InternalsVisibleAssembly\\Controls.Xaml.UnitTests.InternalsVisibleAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.InternalsHiddenAssembly\\Controls.Xaml.UnitTests.InternalsHiddenAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.InternalsVisibleAssembly\\Controls.Xaml.UnitTests.InternalsVisibleAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests\\Controls.Xaml.UnitTests.csproj",
"src\\Controls\\tests\\SourceGen.UnitTests\\SourceGen.UnitTests.csproj",
"src\\Core\\maps\\src\\Maps.csproj",
"src\\Core\\src\\Core.csproj",
"src\\Core\\tests\\Benchmarks\\Core.Benchmarks.csproj",
Expand All @@ -55,11 +55,13 @@
"src\\TestUtils\\src\\DeviceTests.Runners.SourceGen\\TestUtils.DeviceTests.Runners.SourceGen.csproj",
"src\\TestUtils\\src\\DeviceTests.Runners\\TestUtils.DeviceTests.Runners.csproj",
"src\\TestUtils\\src\\DeviceTests\\TestUtils.DeviceTests.csproj",
"src\\TestUtils\\src\\Microsoft.Maui.IntegrationTests\\Microsoft.Maui.IntegrationTests.csproj",
"src\\TestUtils\\src\\TestUtils\\TestUtils.csproj",
"src\\TestUtils\\src\\UITest.Core\\UITest.Core.csproj",
"src\\TestUtils\\src\\UITest.Appium\\UITest.Appium.csproj",
"src\\TestUtils\\src\\UITest.Core\\UITest.Core.csproj",
"src\\TestUtils\\src\\UITest.NUnit\\UITest.NUnit.csproj",
"src\\TestUtils\\src\\Microsoft.Maui.IntegrationTests\\Microsoft.Maui.IntegrationTests.csproj",
"src\\TestUtils\\src\\VisualTestUtils.MagickNet\\VisualTestUtils.MagickNet.csproj",
"src\\TestUtils\\src\\VisualTestUtils\\VisualTestUtils.csproj",
"src\\Workload\\Microsoft.Maui.Sdk\\Microsoft.Maui.Sdk.csproj",
"src\\Workload\\Microsoft.NET.Sdk.Maui.Manifest\\Microsoft.NET.Sdk.Maui.Manifest.csproj"
]
Expand Down
14 changes: 14 additions & 0 deletions Microsoft.Maui-vscode.sln
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITest.Analyzers", "src\Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maui.Controls.Sample.Embedding", "src\Controls\samples\Controls.Sample.Embedding\Maui.Controls.Sample.Embedding.csproj", "{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils", "src\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj", "{53D82EA7-4A62-46E5-8501-821F40CFB845}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils.MagickNet", "src\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj", "{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -539,6 +543,14 @@ Global
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9}.Release|Any CPU.Build.0 = Release|Any CPU
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9}.Release|Any CPU.Deploy.0 = Release|Any CPU
{53D82EA7-4A62-46E5-8501-821F40CFB845}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53D82EA7-4A62-46E5-8501-821F40CFB845}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53D82EA7-4A62-46E5-8501-821F40CFB845}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53D82EA7-4A62-46E5-8501-821F40CFB845}.Release|Any CPU.Build.0 = Release|Any CPU
{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -636,6 +648,8 @@ Global
{0048EA9A-D751-4576-A2BB-2A37BFB385A5} = {25D0D27A-C5FE-443D-8B65-D6C987F4A80E}
{DA001142-4777-4EDE-97D5-B1AC08162F99} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9} = {E1082E26-D700-4127-9329-66D673FD2D55}
{53D82EA7-4A62-46E5-8501-821F40CFB845} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{BE3E8F76-403C-4FDF-AA97-19E105E9E4F0} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
14 changes: 14 additions & 0 deletions Microsoft.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maui.Controls.Sample.Embedd
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls.ManualTests", "src\Controls\tests\ManualTests\Controls.ManualTests.csproj", "{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils", "src\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj", "{2B2488AE-CCD7-4D28-9526-9C2D722C23F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualTestUtils.MagickNet", "src\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj", "{D3A3C971-EFBF-441F-AA5D-C59673861B88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -642,6 +646,14 @@ Global
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C}.Release|Any CPU.Build.0 = Release|Any CPU
{2B2488AE-CCD7-4D28-9526-9C2D722C23F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B2488AE-CCD7-4D28-9526-9C2D722C23F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B2488AE-CCD7-4D28-9526-9C2D722C23F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B2488AE-CCD7-4D28-9526-9C2D722C23F0}.Release|Any CPU.Build.0 = Release|Any CPU
{D3A3C971-EFBF-441F-AA5D-C59673861B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3A3C971-EFBF-441F-AA5D-C59673861B88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3A3C971-EFBF-441F-AA5D-C59673861B88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3A3C971-EFBF-441F-AA5D-C59673861B88}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -757,6 +769,8 @@ Global
{F1BC506B-3A9E-4779-994E-339AFB21C9B9} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{4ADCBA87-30DB-44F5-85E9-94A4F4132FD9} = {E1082E26-D700-4127-9329-66D673FD2D55}
{E2BFD1F1-07A8-8DBE-3661-894D0FE37D9C} = {25D0D27A-C5FE-443D-8B65-D6C987F4A80E}
{2B2488AE-CCD7-4D28-9526-9C2D722C23F0} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
{D3A3C971-EFBF-441F-AA5D-C59673861B88} = {7AC28763-9C68-4BF9-A1BA-25CBFFD2D15C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) == ''">
<PackageReference Include="VisualTestUtils.MagickNet" Version="0.9.46-beta" />
<PackageReference Include="VisualTestUtils" Version="0.9.46-beta" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj" />
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) != ''">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) == ''">
<PackageReference Include="VisualTestUtils.MagickNet" Version="0.9.46-beta" />
<PackageReference Include="VisualTestUtils" Version="0.9.46-beta" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj" />
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) != ''">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) == ''">
<PackageReference Include="VisualTestUtils.MagickNet" Version="0.9.46-beta" />
<PackageReference Include="VisualTestUtils" Version="0.9.46-beta" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj" />
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) != ''">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) == ''">
<PackageReference Include="VisualTestUtils.MagickNet" Version="0.9.46-beta" />
<PackageReference Include="VisualTestUtils" Version="0.9.46-beta" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils.MagickNet\VisualTestUtils.MagickNet.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\VisualTestUtils\VisualTestUtils.csproj" />
</ItemGroup>

<ItemGroup Condition="$(UseLocalVisualTestUtils) != ''">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using ImageMagick;

namespace VisualTestUtils.MagickNet
{
public class MagickNetImageEditor : IImageEditor
{
MagickImage _magickImage;

public MagickNetImageEditor(ImageSnapshot imageSnapshot)
{
_magickImage = new MagickImage(imageSnapshot.Data);
}

public void Crop(int x, int y, int width, int height)
{
_magickImage.Crop(new MagickGeometry(x, y, width, height));
_magickImage.RePage();
}

public (int width, int height) GetSize() =>
(_magickImage.Width, _magickImage.Height);

public ImageSnapshot GetUpdatedImage()
{
ImageSnapshotFormat format = _magickImage.Format switch
{
MagickFormat.Png => ImageSnapshotFormat.PNG,
MagickFormat.Jpeg => ImageSnapshotFormat.JPEG,
_ => throw new NotSupportedException($"Unexpected image format: {_magickImage.Format}")
};

return new ImageSnapshot(_magickImage.ToByteArray(), format);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace VisualTestUtils.MagickNet
{
public class MagickNetImageEditorFactory : IImageEditorFactory
{
public IImageEditor CreateImageEditor(ImageSnapshot imageSnapshot) =>
new MagickNetImageEditor(imageSnapshot);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using ImageMagick;

namespace VisualTestUtils.MagickNet
{
/// <summary>
/// Verify images using ImageMagick.
/// </summary>
public class MagickNetVisualComparer : IVisualComparer
{
private ErrorMetric _errorMetric;
private double _differenceThreshold;

/// <summary>
/// Initializes a new instance of the <see cref="MagickNetVisualComparer"/> class.
/// </summary>
/// <param name="errorMetric">Error metric.</param>
/// <param name="differenceThreshold">The maximum percent difference that is allowed between the baseline and actual snapshot images. Default value is .005, meaning the images must be at least 99.5% the same.).</param>
public MagickNetVisualComparer(ErrorMetric errorMetric = ErrorMetric.Fuzz, double differenceThreshold = 0.005)
{
_errorMetric = errorMetric;
_differenceThreshold = differenceThreshold;
}

/// <inheritdoc/>
public ImageDifference Compare(ImageSnapshot baselineImage, ImageSnapshot actualImage)
{
var magickBaselineImage = new MagickImage(baselineImage.Data);
var magickActualImage = new MagickImage(actualImage.Data);

ImageSizeDifference imageSizeDifference = ImageSizeDifference.Compare(magickBaselineImage.Width, magickBaselineImage.Height, magickActualImage.Width, magickActualImage.Height);
if (imageSizeDifference != null)
return imageSizeDifference;

double distortionDifference = magickBaselineImage.Compare(magickActualImage, _errorMetric, Channels.Red);
if (distortionDifference > this._differenceThreshold)
return new ImagePercentageDifference(distortionDifference);

return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using ImageMagick;

namespace VisualTestUtils.MagickNet
{
/// <summary>
/// Verify images using ImageMagick.
/// </summary>
public class MagickNetVisualDiffGenerator : IVisualDiffGenerator
{
private ErrorMetric _errorMetric;

public MagickNetVisualDiffGenerator(ErrorMetric error = ErrorMetric.Fuzz)
{
_errorMetric = error;
}

public ImageSnapshot GenerateDiff(ImageSnapshot baselineImage, ImageSnapshot actualImage)
{
var magickBaselineImage = new MagickImage(baselineImage.Data);
var magickActualImage = new MagickImage(actualImage.Data);

MagickImage magickDiffImage = new MagickImage();
magickDiffImage.Format = MagickFormat.Png;

double percentageDifference = magickBaselineImage.Compare(magickActualImage, _errorMetric, magickDiffImage, Channels.Red);

return new ImageSnapshot(magickDiffImage.ToByteArray(), ImageSnapshotFormat.PNG);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageReadmeFile>package-readme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.5.0" />
</ItemGroup>

<ItemGroup>
<None Include="package-readme.md" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VisualTestUtils\VisualTestUtils.csproj" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/TestUtils/src/VisualTestUtils.MagickNet/package-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This package extends VisualTestUtils, providing support for perceptual diffs
based on [Magick.NET](https://github.com/dlemstra/Magick.NET).

Support includes creating a visual representation of the image diffs.
31 changes: 31 additions & 0 deletions src/TestUtils/src/VisualTestUtils/IImageEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace VisualTestUtils
{
/// <summary>
/// IImageEditor allows changing images. It's useful, for instance, for cropping
/// off the portion of an image that shouldn't be used as part of a visual test.
/// </summary>
public interface IImageEditor
{
/// <summary>
/// Get the size of the image, in pixels
/// </summary>
/// <returns>image width and height</returns>
(int width, int height) GetSize();

/// <summary>
/// Crop the image, updating it to be the subset in the specified rectangle.
/// </summary>
/// <param name="x">crop rectangle left</param>
/// <param name="y">crop rectangle top</param>
/// <param name="width">crop rectangle width</param>
/// <param name="height">crop rectangle height </param>
void Crop(int x, int y, int width, int height);

/// <summary>
/// Create an image snapshot for the updated image, returning it. The snapshot
/// has the same format (PNG, JPEG, etc.) as the original image.
/// </summary>
/// <returns></returns>
ImageSnapshot GetUpdatedImage();
}
}
15 changes: 15 additions & 0 deletions src/TestUtils/src/VisualTestUtils/IImageEditorFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace VisualTestUtils
{
public interface IImageEditorFactory
{
/// <summary>
/// Create an image editor, to update the specified image snapshot.
/// The original image snapshot is unchanged. After making edits,
/// call IImageEditor.GetImageSnapshot to get a new image snapshot
/// width the updates.
/// </summary>
/// <param name="imageSnapshot">image snapshot to manipulate</param>
/// <returns>image editor, that can be used to make image updates</returns>
IImageEditor CreateImageEditor(ImageSnapshot imageSnapshot);
}
}
Loading