diff --git a/src/Graphics/tests/Graphics.Tests/.gitignore b/src/Graphics/tests/Graphics.Tests/.gitignore new file mode 100644 index 000000000000..6f0deff111e3 --- /dev/null +++ b/src/Graphics/tests/Graphics.Tests/.gitignore @@ -0,0 +1 @@ +Errors/ diff --git a/src/Graphics/tests/Graphics.Tests/Graphics.Tests.csproj b/src/Graphics/tests/Graphics.Tests/Graphics.Tests.csproj index 9c5b4bb7657c..9352b2a0635e 100644 --- a/src/Graphics/tests/Graphics.Tests/Graphics.Tests.csproj +++ b/src/Graphics/tests/Graphics.Tests/Graphics.Tests.csproj @@ -1,4 +1,4 @@ - + $(_MauiDotNetTfm) @@ -10,15 +10,35 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all + + + + + + + + + + + + + + + + + + + + diff --git a/src/Graphics/tests/Graphics.Tests/ImageAssert.cs b/src/Graphics/tests/Graphics.Tests/ImageAssert.cs new file mode 100644 index 000000000000..af1f46418150 --- /dev/null +++ b/src/Graphics/tests/Graphics.Tests/ImageAssert.cs @@ -0,0 +1,59 @@ +using System.IO; +using SkiaSharp; +using SkiaSharp.Extended; +using Xunit; + +namespace Microsoft.Maui; + +public static class ImageAssert +{ + private const double ImageErrorThreshold = 0.0027; + + public static void Equivalent(Stream actualData, string expectedFilename, string diffDirectory, double threshold = ImageErrorThreshold) + { + using var actual = SKImage.FromEncodedData(actualData); + Equivalent(actual, expectedFilename, diffDirectory, threshold); + } + + public static void Equivalent(string actualFilename, string expectedFilename, string diffDirectory, double threshold = ImageErrorThreshold) + { + using var actual = SKImage.FromEncodedData(actualFilename); + Equivalent(actual, expectedFilename, diffDirectory, threshold); + } + + public static void Equivalent(SKImage actual, string expectedFilename, string diffDirectory, double threshold = ImageErrorThreshold) + { + var expected = SKImage.FromEncodedData(expectedFilename); + var similarity = SKPixelComparer.Compare(actual, expected); + + var isSimilar = similarity.ErrorPixelPercentage <= threshold; + + if (isSimilar) + { + return; + } + + var outputFilename = Path.Combine(diffDirectory, expectedFilename); + + var diffFilename = Path.ChangeExtension(outputFilename, ".diff.png"); + + Directory.CreateDirectory(Path.GetDirectoryName(diffFilename)); + + using (var diff = SKPixelComparer.GenerateDifferenceMask(actual, expected)) + using (var diffData = diff.Encode(SKEncodedImageFormat.Png, 100)) + using (var diffFile = File.Create(diffFilename)) + { + diffData.SaveTo(diffFile); + } + + using (var actualData = actual.Encode(SKEncodedImageFormat.Png, 100)) + using (var actualFile = File.Create(Path.ChangeExtension(outputFilename, ".png"))) + { + actualData.SaveTo(actualFile); + } + + File.Copy(expectedFilename, Path.ChangeExtension(outputFilename, ".expected.png"), true); + + Assert.Fail($"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels). See {diffFilename}"); + } +} diff --git a/src/Graphics/tests/Graphics.Tests/SkiaSharpScenarioTests.cs b/src/Graphics/tests/Graphics.Tests/SkiaSharpScenarioTests.cs new file mode 100644 index 000000000000..ab4a90ddce10 --- /dev/null +++ b/src/Graphics/tests/Graphics.Tests/SkiaSharpScenarioTests.cs @@ -0,0 +1,97 @@ +using System; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using GraphicsTester.Scenarios; +using Microsoft.Maui.Graphics.Skia; +using Xunit; + +namespace Microsoft.Maui.Graphics.Tests; + +public class SkiaSharpScenarioTests +{ + public static TheoryData Scenarios => + new(ScenarioList.Scenarios.Select(s => s.ToString())); + + [Theory] + [MemberData(nameof(Scenarios))] + public void Scenario(string scenarioName) + { + // find scenario + var scenario = ScenarioList.Scenarios.Single(s => s.ToString() == scenarioName); + + // render scenario + using var bmp = new SkiaBitmapExportContext((int)scenario.Width, (int)scenario.Height, 1f); + bmp.Canvas.FillColor = Colors.Transparent; + bmp.Canvas.FillRectangle(0, 0, scenario.Width, scenario.Height); + scenario.Draw(bmp.Canvas); + + var expectedImagePath = GetExpectedImageaPath(scenario); + + // save image if it did not exist, then fail the test + if (!File.Exists(expectedImagePath)) + { + var newImageFilename = Path.Combine(ProjectRoot, expectedImagePath); + Directory.CreateDirectory(Path.GetDirectoryName(newImageFilename)); + + bmp.WriteToFile(newImageFilename); + + Assert.Fail($"Image file did not exist, created: {newImageFilename}"); + } + + // file existed, compare + ImageAssert.Equivalent(bmp.SKImage, expectedImagePath, GetErrorsImageDirectory(), 0); + } + + private static string ProjectRoot => + Path.GetFullPath("../../../../../src/Graphics/tests/Graphics.Tests"); + + private static string GetExpectedImageaPath(AbstractScenario scenario) + { + var fileName = GetSafeFilename(scenario.ToString()) + ".png"; + var os = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? "Windows" + : RuntimeInformation.IsOSPlatform(OSPlatform.OSX) + ? "Mac" + : "Linux"; + var filePath = Path.Combine("TestImages", os, fileName); + + return filePath; + } + + private static string GetErrorsImageDirectory() + { + var outputFolder = Path.GetFullPath(Path.Combine(ProjectRoot, "Errors")); + + if (Environment.GetEnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY") is { } asd && !string.IsNullOrWhiteSpace(asd)) + { + outputFolder = Path.GetFullPath(Path.Combine( + asd, typeof(SkiaSharpScenarioTests).FullName, "Errors")); + } + + Directory.CreateDirectory(outputFolder); + + return outputFolder; + } + + private static string GetSafeFilename(string text) + { + char[] chars = text.ToCharArray(); + + char[] allowedSpecialChars = ['_', '-']; + for (int i = 0; i < chars.Length; i++) + { + chars[i] = char.IsLetterOrDigit(chars[i]) || allowedSpecialChars.Contains(chars[i]) + ? char.ToLowerInvariant(chars[i]) + : '-'; + } + + var safe = new string(chars); + while (safe.Contains("--", StringComparison.OrdinalIgnoreCase)) + { + safe = safe.Replace("--", "-", StringComparison.OrdinalIgnoreCase); + } + + return safe.Trim('-'); + } +} diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection-including-background-ellipses.png new file mode 100644 index 000000000000..2b10516acf92 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection.png new file mode 100644 index 000000000000..0e24d5291438 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcdirection.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario1.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario1.png new file mode 100644 index 000000000000..8e66c625db91 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario1.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario2.png new file mode 100644 index 000000000000..abceb712eec3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/arcscenario2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/cliprect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/cliprect.png new file mode 100644 index 000000000000..a2c6424f1f9d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/cliprect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/dimensiontest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/dimensiontest.png new file mode 100644 index 000000000000..94db2728b55d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/dimensiontest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs-including-background-ellipses.png new file mode 100644 index 000000000000..9b02481c003c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs.png new file mode 100644 index 000000000000..6a02062c047f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawarcs.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawellipses.png new file mode 100644 index 000000000000..c2c0ded05897 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawflattenedpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawflattenedpaths.png new file mode 100644 index 000000000000..56abd93235d3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawflattenedpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawhorizontallycenteredtextwithsimpleapi.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawhorizontallycenteredtextwithsimpleapi.png new file mode 100644 index 000000000000..54088e384d2c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawhorizontallycenteredtextwithsimpleapi.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawimages.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawimages.png new file mode 100644 index 000000000000..901db063321f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawimages.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlines.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlines.png new file mode 100644 index 000000000000..02e34ef171b3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlines.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlinesscaled.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlinesscaled.png new file mode 100644 index 000000000000..3536f9197416 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlinesscaled.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrect.png new file mode 100644 index 000000000000..d4e62f8a96f9 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoutoverflow.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoutoverflow.png new file mode 100644 index 000000000000..99f201de3746 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoutoverflow.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoverflow.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoverflow.png new file mode 100644 index 000000000000..664c2d49ccfa Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawlongtextinrectwithoverflow.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawmarkdigattributedtext.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawmarkdigattributedtext.png new file mode 100644 index 000000000000..9a9901b85c89 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawmarkdigattributedtext.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpaths.png new file mode 100644 index 000000000000..4b5770d38e36 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpathsscaled.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpathsscaled.png new file mode 100644 index 000000000000..60bd237937db Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawpathsscaled.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawrectangles.png new file mode 100644 index 000000000000..8e508afe4e5b Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawroundedrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawroundedrectangles.png new file mode 100644 index 000000000000..fd959f590411 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawroundedrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect.png new file mode 100644 index 000000000000..f8c19f41bf7a Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect2.png new file mode 100644 index 000000000000..7763c6f0eaee Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawshorttextinrect2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextatpoint.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextatpoint.png new file mode 100644 index 000000000000..aecaad65e996 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextatpoint.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextrotatedatpoint.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextrotatedatpoint.png new file mode 100644 index 000000000000..089a72cb1898 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawtextrotatedatpoint.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext.png new file mode 100644 index 000000000000..43681fc91151 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext2.png new file mode 100644 index 000000000000..46c59f1fd69b Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/drawverticallycenteredtext2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs-including-background-ellipses.png new file mode 100644 index 000000000000..9e9c3ea1436d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs.png new file mode 100644 index 000000000000..0eb01fdccf69 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillarcs.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/filledarcdirection.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/filledarcdirection.png new file mode 100644 index 000000000000..627829d24c1b Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/filledarcdirection.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillellipses.png new file mode 100644 index 000000000000..3763e146d198 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillpaths.png new file mode 100644 index 000000000000..747bd58afe68 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillrectangles.png new file mode 100644 index 000000000000..5cef76955420 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillroundedrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillroundedrectangles.png new file mode 100644 index 000000000000..72eac239aca4 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/fillroundedrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/imagefills.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/imagefills.png new file mode 100644 index 000000000000..8666c0da855d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/imagefills.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/linejoins.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/linejoins.png new file mode 100644 index 000000000000..e8ab4add8087 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/linejoins.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/multipleshadowtest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/multipleshadowtest.png new file mode 100644 index 000000000000..abc47a728f5e Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/multipleshadowtest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/patternfills.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/patternfills.png new file mode 100644 index 000000000000..82bfd3be7a42 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/patternfills.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/radialgradientincircle.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/radialgradientincircle.png new file mode 100644 index 000000000000..47724264faf8 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/radialgradientincircle.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/rectanglewithzerostroke.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/rectanglewithzerostroke.png new file mode 100644 index 000000000000..dc78a8342993 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/rectanglewithzerostroke.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/scalecanvas.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/scalecanvas.png new file mode 100644 index 000000000000..679b0d07930f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/scalecanvas.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/simpleshadowtest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/simpleshadowtest.png new file mode 100644 index 000000000000..0d4123fd8f6f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/simpleshadowtest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/strokelocations.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/strokelocations.png new file mode 100644 index 000000000000..630e2005641d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/strokelocations.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/subtractfromclip.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/subtractfromclip.png new file mode 100644 index 000000000000..21b24f63a047 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/subtractfromclip.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern1.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern1.png new file mode 100644 index 000000000000..c3960e6541b4 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern1.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern2.png new file mode 100644 index 000000000000..acd25824ec2b Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/testpattern2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Mac/transformrotatefromorigin.png b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/transformrotatefromorigin.png new file mode 100644 index 000000000000..b2a96d8cddc9 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Mac/transformrotatefromorigin.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection-including-background-ellipses.png new file mode 100644 index 000000000000..87eaba04e604 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection.png new file mode 100644 index 000000000000..0e24d5291438 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcdirection.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario1.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario1.png new file mode 100644 index 000000000000..f4c309d83e22 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario1.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario2.png new file mode 100644 index 000000000000..abceb712eec3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/arcscenario2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/cliprect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/cliprect.png new file mode 100644 index 000000000000..a2c6424f1f9d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/cliprect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/dimensiontest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/dimensiontest.png new file mode 100644 index 000000000000..c93584eeaa6c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/dimensiontest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs-including-background-ellipses.png new file mode 100644 index 000000000000..aa6c43f98211 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs.png new file mode 100644 index 000000000000..bcb3ecbb32c0 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawarcs.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawellipses.png new file mode 100644 index 000000000000..ac7cc73e591f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawflattenedpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawflattenedpaths.png new file mode 100644 index 000000000000..08e5dd91d551 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawflattenedpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawhorizontallycenteredtextwithsimpleapi.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawhorizontallycenteredtextwithsimpleapi.png new file mode 100644 index 000000000000..57bc6b80bbc5 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawhorizontallycenteredtextwithsimpleapi.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawimages.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawimages.png new file mode 100644 index 000000000000..901db063321f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawimages.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlines.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlines.png new file mode 100644 index 000000000000..02e34ef171b3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlines.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlinesscaled.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlinesscaled.png new file mode 100644 index 000000000000..3536f9197416 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlinesscaled.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrect.png new file mode 100644 index 000000000000..ecc7ac90ad06 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoutoverflow.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoutoverflow.png new file mode 100644 index 000000000000..c1423d7b3bca Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoutoverflow.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoverflow.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoverflow.png new file mode 100644 index 000000000000..8c6272aa0846 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawlongtextinrectwithoverflow.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawmarkdigattributedtext.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawmarkdigattributedtext.png new file mode 100644 index 000000000000..9497087acfc5 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawmarkdigattributedtext.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpaths.png new file mode 100644 index 000000000000..a5ce8a920627 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpathsscaled.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpathsscaled.png new file mode 100644 index 000000000000..5f95589f114c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawpathsscaled.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawrectangles.png new file mode 100644 index 000000000000..a8a3e2c819ff Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawroundedrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawroundedrectangles.png new file mode 100644 index 000000000000..637c0f3c465d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawroundedrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect.png new file mode 100644 index 000000000000..9f86d7dd897a Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect2.png new file mode 100644 index 000000000000..c2f8a209d790 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawshorttextinrect2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextatpoint.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextatpoint.png new file mode 100644 index 000000000000..9ef04110d02f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextatpoint.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextrotatedatpoint.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextrotatedatpoint.png new file mode 100644 index 000000000000..a2fa6daa09cf Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawtextrotatedatpoint.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext.png new file mode 100644 index 000000000000..a0cca6ecfb5f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext2.png new file mode 100644 index 000000000000..07166c9b5baf Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/drawverticallycenteredtext2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs-including-background-ellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs-including-background-ellipses.png new file mode 100644 index 000000000000..d8cb1aded1dd Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs-including-background-ellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs.png new file mode 100644 index 000000000000..465f178009b3 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillarcs.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/filledarcdirection.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/filledarcdirection.png new file mode 100644 index 000000000000..627829d24c1b Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/filledarcdirection.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillellipses.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillellipses.png new file mode 100644 index 000000000000..30337a7b7094 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillellipses.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillpaths.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillpaths.png new file mode 100644 index 000000000000..6c624fe1ef03 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillpaths.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillrectangles.png new file mode 100644 index 000000000000..99930c7a8d5c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillroundedrectangles.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillroundedrectangles.png new file mode 100644 index 000000000000..db0d3262d050 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/fillroundedrectangles.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/imagefills.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/imagefills.png new file mode 100644 index 000000000000..8666c0da855d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/imagefills.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/linejoins.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/linejoins.png new file mode 100644 index 000000000000..e8ab4add8087 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/linejoins.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/multipleshadowtest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/multipleshadowtest.png new file mode 100644 index 000000000000..abc47a728f5e Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/multipleshadowtest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/patternfills.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/patternfills.png new file mode 100644 index 000000000000..82bfd3be7a42 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/patternfills.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/radialgradientincircle.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/radialgradientincircle.png new file mode 100644 index 000000000000..47724264faf8 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/radialgradientincircle.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/rectanglewithzerostroke.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/rectanglewithzerostroke.png new file mode 100644 index 000000000000..dc78a8342993 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/rectanglewithzerostroke.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/scalecanvas.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/scalecanvas.png new file mode 100644 index 000000000000..51e52927887c Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/scalecanvas.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/simpleshadowtest.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/simpleshadowtest.png new file mode 100644 index 000000000000..0d4123fd8f6f Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/simpleshadowtest.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/strokelocations.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/strokelocations.png new file mode 100644 index 000000000000..630e2005641d Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/strokelocations.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/subtractfromclip.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/subtractfromclip.png new file mode 100644 index 000000000000..21b24f63a047 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/subtractfromclip.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern1.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern1.png new file mode 100644 index 000000000000..9652fe3670b6 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern1.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern2.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern2.png new file mode 100644 index 000000000000..605ab31b13ba Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/testpattern2.png differ diff --git a/src/Graphics/tests/Graphics.Tests/TestImages/Windows/transformrotatefromorigin.png b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/transformrotatefromorigin.png new file mode 100644 index 000000000000..147bed9aa091 Binary files /dev/null and b/src/Graphics/tests/Graphics.Tests/TestImages/Windows/transformrotatefromorigin.png differ diff --git a/src/SingleProject/Resizetizer/test/UnitTests/.gitignore b/src/SingleProject/Resizetizer/test/UnitTests/.gitignore new file mode 100644 index 000000000000..0dc09ad1c8c9 --- /dev/null +++ b/src/SingleProject/Resizetizer/test/UnitTests/.gitignore @@ -0,0 +1 @@ +errors/ diff --git a/src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs b/src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs index 97820035e626..439c60abbe89 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/BaseTest.cs @@ -6,6 +6,7 @@ using SkiaSharp; using SkiaSharp.Extended; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { @@ -18,28 +19,28 @@ public class BaseTest : IDisposable private readonly string DeleteDirectory; protected readonly string DestinationDirectory; - public BaseTest(string testContextDirectory = null) + public BaseTest(ITestOutputHelper output) { - if (!string.IsNullOrEmpty(testContextDirectory)) - { - DestinationDirectory = testContextDirectory; - DeleteDirectory = testContextDirectory; - } - else - { - var name = GetType().FullName; - if (name.StartsWith(TestFolderName + ".", StringComparison.OrdinalIgnoreCase)) - name = name.Substring(TestFolderName.Length + 1); + Output = output; - var dir = Path.Combine(Path.GetTempPath(), TestFolderName, name, Path.GetRandomFileName()); + var name = GetType().FullName; + if (name.StartsWith(TestFolderName + ".", StringComparison.OrdinalIgnoreCase)) + name = name.Substring(TestFolderName.Length + 1); - DestinationDirectory = dir; - DeleteDirectory = dir; - } + var dir = Path.Combine(Path.GetTempPath(), TestFolderName, name, Path.GetRandomFileName()); + + DestinationDirectory = dir; + DeleteDirectory = dir; + + Output.WriteLine($"Using DestinationDirectory={DestinationDirectory}"); } + public ITestOutputHelper Output { get; } + public virtual void Dispose() { + Output.WriteLine($"Cleaning up directories={DeleteDirectory}"); + if (Directory.Exists(DeleteDirectory)) Directory.Delete(DeleteDirectory, true); } @@ -137,33 +138,12 @@ void AssertFileMatchesReal(string actualFilename, object[] args = null, [CallerM } else { - using var actual = SKImage.FromEncodedData(actualFilename); - using var expected = SKImage.FromEncodedData(expectedFilename); - - var similarity = SKPixelComparer.Compare(actual, expected); - - var isSimilar = similarity.ErrorPixelPercentage <= ImageErrorThreshold; - - if (!isSimilar) - { - var root = GetTestProjectRoot(); - - var maskFilename = Path.Combine(root, "errors", expectedFilename); - maskFilename = Path.ChangeExtension(maskFilename, ".mask.png"); - - Directory.CreateDirectory(Path.GetDirectoryName(maskFilename)); + var root = GetTestProjectRoot(); + var diffDir = Path.Combine(root, "errors"); - using (var mask = SKPixelComparer.GenerateDifferenceMask(actual, expected)) - using (var data = mask.Encode(SKEncodedImageFormat.Png, 100)) - using (var maskFile = File.Create(maskFilename)) - { - data.SaveTo(maskFile); - } + Output.WriteLine($"Validating image similarity with diff dir:{diffDir}"); - Assert.True( - isSimilar, - $"Image was not equal. Error was {similarity.ErrorPixelPercentage}% ({similarity.AbsoluteError} pixels). See {maskFilename}"); - } + ImageAssert.Equivalent(actualFilename, expectedFilename, diffDir); } } diff --git a/src/SingleProject/Resizetizer/test/UnitTests/DetectInvalidResourceOutputFilenamesTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/DetectInvalidResourceOutputFilenamesTests.cs index 1f662a716ca2..5f9e00b048d4 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/DetectInvalidResourceOutputFilenamesTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/DetectInvalidResourceOutputFilenamesTests.cs @@ -7,6 +7,7 @@ using Microsoft.Build.Utilities; using SkiaSharp; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { @@ -14,6 +15,11 @@ public class DetectInvalidResourceOutputFilenamesTests { public class ExecuteForApp : MSBuildTaskTestFixture { + public ExecuteForApp(ITestOutputHelper output) + : base(output) + { + } + protected DetectInvalidResourceOutputFilenamesTask GetNewTask(params ITaskItem[] items) => new DetectInvalidResourceOutputFilenamesTask { diff --git a/src/SingleProject/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index 8b8a1ad52267..fce50e27bcb6 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -5,11 +5,17 @@ using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { public class GeneratePackageAppxManifestTests : MSBuildTaskTestFixture { + public GeneratePackageAppxManifestTests(ITestOutputHelper output) + : base(output) + { + } + protected GeneratePackageAppxManifest GetNewTask( string manifest, string? generatedFilename = null, diff --git a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAndroidResourcesTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAndroidResourcesTests.cs index d2290b5a912d..5e80c0ca802b 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAndroidResourcesTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAndroidResourcesTests.cs @@ -6,6 +6,7 @@ using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { @@ -17,7 +18,8 @@ public class GenerateSplashAndroidResourcesTests : MSBuildTaskTestFixture ResizeMetadata = new() { ["Resize"] = "true" }; - public GenerateSplashAndroidResourcesTests() + public GenerateSplashAndroidResourcesTests(ITestOutputHelper outputHelper) + : base(outputHelper) { _colors = Path.Combine(DestinationDirectory, "values", "maui_colors.xml"); _drawable = Path.Combine(DestinationDirectory, "drawable", "maui_splash_image.xml"); diff --git a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAssetsTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAssetsTests.cs index b2b16aad10c1..7e8eccad3054 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAssetsTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashAssetsTests.cs @@ -5,11 +5,17 @@ using Microsoft.Build.Utilities; using SkiaSharp; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { public class GenerateSplashAssetsTests : MSBuildTaskTestFixture { + public GenerateSplashAssetsTests(ITestOutputHelper output) + : base(output) + { + } + protected GenerateSplashAssets GetNewTask(ITaskItem splash) => new() { diff --git a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashStoryboardTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashStoryboardTests.cs index eb64f9744337..bd823e753dc0 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashStoryboardTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/GenerateSplashStoryboardTests.cs @@ -6,6 +6,7 @@ using Microsoft.Build.Utilities; using SkiaSharp; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { @@ -15,7 +16,8 @@ public class GenerateSplashStoryboardTests : MSBuildTaskTestFixture const string LibraryProjectDirectory = ProjectDirectory + @"/ClassLibrary1"; #endif + public GetMauiAssetsPathTests(ITestOutputHelper output) + : base(output) + { + } + protected GetMauiAssetPath GetNewTask(string folderName, params ITaskItem[] input) => new() { ProjectDirectory = ProjectDirectory, diff --git a/src/SingleProject/Resizetizer/test/UnitTests/MSBuildTaskFixture.cs b/src/SingleProject/Resizetizer/test/UnitTests/MSBuildTaskFixture.cs index 35060cafa5bb..0e9fcded9a75 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/MSBuildTaskFixture.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/MSBuildTaskFixture.cs @@ -17,18 +17,11 @@ public abstract class MSBuildTaskTestFixture : BaseTest, IBuildEngine protected List LogCustomEvents = new List(); protected List LogWarningEvents = new List(); - protected MSBuildTaskTestFixture() - : this(null) + protected MSBuildTaskTestFixture(ITestOutputHelper output) + : base(output) { } - protected MSBuildTaskTestFixture(ITestOutputHelper? output) - { - Output = output; - } - - public ITestOutputHelper? Output { get; } - // IBuildEngine bool IBuildEngine.ContinueOnError => false; diff --git a/src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj b/src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj index cf167be636d4..a6950880709b 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj +++ b/src/SingleProject/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj @@ -13,7 +13,7 @@ - + @@ -28,4 +28,8 @@ + + + + diff --git a/src/SingleProject/Resizetizer/test/UnitTests/SkiaSharpAppIconToolsTests.cs b/src/SingleProject/Resizetizer/test/UnitTests/SkiaSharpAppIconToolsTests.cs index 6e638d522fc7..335d6308bd59 100644 --- a/src/SingleProject/Resizetizer/test/UnitTests/SkiaSharpAppIconToolsTests.cs +++ b/src/SingleProject/Resizetizer/test/UnitTests/SkiaSharpAppIconToolsTests.cs @@ -1,6 +1,7 @@ using System.IO; using SkiaSharp; using Xunit; +using Xunit.Abstractions; namespace Microsoft.Maui.Resizetizer.Tests { @@ -11,7 +12,8 @@ public class Resize : BaseTest readonly string DestinationFilename; readonly TestLogger Logger; - public Resize() + public Resize(ITestOutputHelper outputHelper) + : base(outputHelper) { DestinationFilename = Path.Combine(DestinationDirectory, Path.GetRandomFileName() + ".png"); Logger = new TestLogger();