Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump PuppeteerSharp from 20.0.2 to 20.0.3 #124

Merged
merged 3 commits into from
Oct 30, 2024
Merged
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
10 changes: 4 additions & 6 deletions Codeuctivity.HtmlRenderer/Codeuctivity.HtmlRenderer.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
Expand All @@ -15,11 +15,10 @@
<PackageReleaseNotes>$(LAST_COMMIT_MESSAGE)</PackageReleaseNotes>
<PackageIcon>NugetIcon.png</PackageIcon>
<PackageProjectUrl>https://github.com/Codeuctivity/PuppeteerSharp.Renderer</PackageProjectUrl>
<Description>Renders HTML to PNG or PDF, supports windows and linux</Description>
<Description>Renders HTML to PNG or PDF, supports windows, linux and macos</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<SignAssembly>True</SignAssembly>
<Optimize Condition="'$(GITHUB_ACTIONS)' == 'true'">true</Optimize>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand All @@ -38,9 +37,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="PuppeteerSharp" Version="20.0.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422">
<PackageReference Include="PuppeteerSharp" Version="20.0.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 5 additions & 1 deletion Codeuctivity.HtmlRenderer/Renderer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using PuppeteerSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -95,6 +96,9 @@
BrowserFetcher = browserFetcher;
var revisionInfo = await BrowserFetcher.DownloadAsync(PuppeteerSharp.BrowserData.Chrome.DefaultBuildId).ConfigureAwait(false);
LaunchOptions.ExecutablePath = revisionInfo.GetExecutablePath();

// Temporary work around https://github.com/hardkoded/puppeteer-sharp/issues/2782 https://stackoverflow.com/questions/78996364/chrome-129-headless-shows-blank-window
LaunchOptions.Args = new List<string>(LaunchOptions.Args ?? Array.Empty<string>()) { "--headless=old" }.ToArray();
Browser = await Puppeteer.LaunchAsync(LaunchOptions).ConfigureAwait(false);

return this;
Expand Down Expand Up @@ -160,7 +164,7 @@
}

var absolutePath = Path.GetFullPath(sourceHtmlFilePath);
await using var page = await GetPage().ConfigureAwait(false);

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 167 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.GoToAsync($"file://{absolutePath}").ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text rendered in PDF.
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
Expand All @@ -171,7 +175,7 @@
{
if (Browser == null)
{
throw new RendererException("Call CreateAsync first");
throw new RendererException($"Call {nameof(CreateAsync)} first");
}

return await Browser.NewPageAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -201,7 +205,7 @@
}

var absolutePath = Path.GetFullPath(sourceHtmlFilePath);
await using var page = await GetPage().ConfigureAwait(false);

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 208 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.GoToAsync($"file://{absolutePath}").ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text the screenshot.
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
Expand All @@ -224,7 +228,7 @@
/// <param name="screenshotOptions"></param>
public async Task<byte[]> ConvertHtmlStringToPngData(string sourceHtmlData, ScreenshotOptions screenshotOptions)
{
await using var page = await GetPage().ConfigureAwait(false);

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)

Check warning on line 231 in Codeuctivity.HtmlRenderer/Renderer.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Consider calling ConfigureAwait on the awaited task (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2007)
await page.SetContentAsync(sourceHtmlData).ConfigureAwait(false);
// Wait for fonts to be loaded. Omitting this might result in no text the screenshot.
await page.EvaluateExpressionHandleAsync("document.fonts.ready").ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 4 additions & 0 deletions Codeuctivity.HtmlRendererTests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = none
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<ItemGroup>
<Compile Remove="SourceTestFiles\**" />
<EmbeddedResource Remove="SourceTestFiles\**" />
<None Remove="SourceTestFiles\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="SourceTestFiles\**" />
<EmbeddedResource Remove="SourceTestFiles\**" />
<None Remove="SourceTestFiles\**" />

<SupportedPlatform Include="Linux" />
<SupportedPlatform Include="macOS" />
<SupportedPlatform Include="Windows" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="4.0.258" />
<PackageReference Include="PDFtoImage" Version="4.0.2" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="4.0.273" />
<PackageReference Include="PDFtoImage" Version="4.1.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Codeuctivity.HtmlRenderer\Codeuctivity.HtmlRenderer.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Codeuctivity.HtmlRenderer\Codeuctivity.HtmlRenderer.csproj" />
</ItemGroup>

<ItemGroup>
<EditorConfigFiles Remove="C:\Users\Stefan\Documents\source\repo\PuppeteerSharp.Renderer\Codeuctivity.HtmlRendererTests\.editorconfig" />
</ItemGroup>

<ItemGroup>
<None Include="C:\Users\Stefan\Documents\source\repo\PuppeteerSharp.Renderer\Codeuctivity.HtmlRendererTests\.editorconfig" />
</ItemGroup>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class DocumentAsserter
{
private const string TestOutputFirectory = "../../../../TestResult";

internal static void AssertImageIsEqual(string actualImagePath, string expectImageFilePath, int allowedPixelErrorCount)
internal static void AssertImageIsEqual(string actualImagePath, string expectImageFilePath, int allowedPixelErrorCount, int pixelColorShiftTolerance = 0)
{
var actualFullPath = Path.GetFullPath(actualImagePath);
var expectFullPath = Path.GetFullPath(expectImageFilePath);
Expand All @@ -29,26 +29,28 @@ internal static void AssertImageIsEqual(string actualImagePath, string expectIma
osSpecificDiffFileSuffix = "osx";
}

var allowedDiffImage = $"{expectFullPath}.diff.{osSpecificDiffFileSuffix}.png";
var osSpecificAllowedDiffImage = $"{expectFullPath}.diff.{osSpecificDiffFileSuffix}.png";
var newDiffImage = $"{actualFullPath}.diff.png";
using (var fileStreamDifferenceMask = File.Create(newDiffImage))
using (var maskImage = ImageSharpCompare.ImageSharpCompare.CalcDiffMaskImage(actualFullPath, expectFullPath))
{
SixLabors.ImageSharp.ImageExtensions.SaveAsPng(maskImage, fileStreamDifferenceMask);
}

if (File.Exists(allowedDiffImage))
if (File.Exists(osSpecificAllowedDiffImage))
{
var resultWithAllowedDiff = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath, allowedDiffImage);
var resultWithOsSpecificAllowedDiff = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath, osSpecificAllowedDiffImage);

if (allowedPixelErrorCount < resultWithAllowedDiff.PixelErrorCount)
if (allowedPixelErrorCount < resultWithOsSpecificAllowedDiff.PixelErrorCount)
{
CopyToTestOutput(actualImagePath);
CopyToTestOutput(expectImageFilePath);
CopyToTestOutput(newDiffImage);
}

Assert.True(resultWithAllowedDiff.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {resultWithAllowedDiff.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}");
// File.Copy(newDiffImage, osSpecificAllowedDiffImage, true);

Assert.True(resultWithOsSpecificAllowedDiff.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {resultWithOsSpecificAllowedDiff.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}");
return;
}

Expand All @@ -58,7 +60,7 @@ internal static void AssertImageIsEqual(string actualImagePath, string expectIma
SixLabors.ImageSharp.ImageExtensions.SaveAsPng(maskImage, fileStreamDifferenceMask);
}

var result = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath);
var result = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath, pixelColorShiftTolerance: pixelColorShiftTolerance);

if (allowedPixelErrorCount < result.PixelErrorCount)
{
Expand All @@ -67,7 +69,7 @@ internal static void AssertImageIsEqual(string actualImagePath, string expectIma
CopyToTestOutput(actualImagePath);
}

Assert.True(result.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {result.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}\nReplace {actualFullPath} with the new value or store the diff as {allowedDiffImage}.");
Assert.True(result.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {result.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}\nReplace {actualFullPath} with the new value or store the diff as {osSpecificAllowedDiffImage}.");
}

private static void CopyToTestOutput(string testOutputFile)
Expand Down
8 changes: 4 additions & 4 deletions Codeuctivity.HtmlRendererTests/RendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public async Task ShouldConvertHtmlToPdf(string testFileName)

if (!IsRunningOnAzureOrMacos())
{
PDFtoImage.Conversion.SavePng(actualImagePathDirectory, await File.ReadAllBytesAsync(actualFilePath));
DocumentAsserter.AssertImageIsEqual(actualImagePathDirectory, expectReferenceFilePath, 8080);
PDFtoImage.Conversion.SavePng(actualImagePathDirectory, await File.ReadAllBytesAsync(actualFilePath), 0);
DocumentAsserter.AssertImageIsEqual(actualImagePathDirectory, expectReferenceFilePath, 8080, 400);
}
File.Delete(actualFilePath);
}
Expand Down Expand Up @@ -66,8 +66,8 @@ public async Task ShouldConvertHtmlToPdfWithOptions(string testFileName, bool pr

if (!IsRunningOnAzureOrMacos())
{
PDFtoImage.Conversion.SavePng(actualImagePathDirectory, await File.ReadAllBytesAsync(actualFilePath));
DocumentAsserter.AssertImageIsEqual(actualImagePathDirectory, expectReferenceFilePath, allowedPixelDiff);
PDFtoImage.Conversion.SavePng(actualImagePathDirectory, await File.ReadAllBytesAsync(actualFilePath), 0);
DocumentAsserter.AssertImageIsEqual(actualImagePathDirectory, expectReferenceFilePath, allowedPixelDiff, 400);
}
File.Delete(actualFilePath);
}
Expand Down
Loading