Skip to content

Add HtmlRenderer.Test project, port applicable tests from PeachPDF - #262

Open
jhaygood86 wants to merge 3 commits into
ArthurHub:masterfrom
jhaygood86:port-peachpdf-tests
Open

Add HtmlRenderer.Test project, port applicable tests from PeachPDF#262
jhaygood86 wants to merge 3 commits into
ArthurHub:masterfrom
jhaygood86:port-peachpdf-tests

Conversation

@jhaygood86

@jhaygood86 jhaygood86 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a new HtmlRenderer.Test project (MSTest, matching this repo's existing HtmlRenderer.IntegrationTest/HtmlRenderer.PdfSharp.Test style) for pure unit tests against the core library, backed by a new lightweight mock RAdapter/RGraphics test harness with no dependency on any UI framework.
  • Ports the subset of PeachPDF's test suite (PeachPDF forked from HTML-Renderer and has since built out a much larger CSS engine, SVG support, and PDF pipeline) that HTML-Renderer's current feature set can actually exercise, converted from xUnit to MSTest, and routed to the appropriate project:
    • HtmlRenderer.Test — CSS parsing/property and Core Dom/Utils unit tests
    • HtmlRenderer.IntegrationTest — end-to-end layout/paint behavior tests, using a similar harness backed by the real WinForms adapter
    • HtmlRenderer.PdfSharp.Test — PDF-generation and PdfSharp-adapter tests
  • Of the ~483 candidate test files in PeachPDF.Tests, the large majority test PeachPDF-only features HTML-Renderer doesn't have at all (its own CSS engine/CSSOM, SVG, flexbox/grid, box-shadow/gradients, WOFF fonts, bidi text shaping, cascade layers, etc.) and were left out.
  • Where a ported test exercises a feature that does exist in HTML-Renderer but whose current implementation isn't spec compliant (e.g. margin: 0 auto never centers, vertical-align keywords beyond sub/super are no-ops, mixed-sign margin collapsing is wrong), the test is still ported with its full original assertions intact — so it documents the real target behavior — but marked [Ignore("not yet spec compliant")] rather than dropped or forced to pass.
  • Adds InternalsVisibleTo grants from HtmlRenderer/HtmlRenderer.WinForms/HtmlRenderer.PdfSharp to their respective new/existing test projects, matching the same grants PeachPDF's own .csproj already declares for PeachPDF.Tests.
  • No behavioral changes to HTML-Renderer itself.

More tests will be ported incrementally from PeachPDF as HTML-Renderer backports more of its standard/spec support — this PR is a starting point, not a one-time snapshot.

Test plan

  • dotnet build Source/HtmlRenderer.sln (Debug and Release) — clean, 0 errors
  • dotnet test per project:
    • HtmlRenderer.Test: 220 passed, 0 failed, 41 skipped (ignored, spec-compliance gaps)
    • HtmlRenderer.IntegrationTest (new tests): 111 passed, 0 failed, 85 skipped
    • HtmlRenderer.PdfSharp.Test: 15 passed, 0 failed
  • Confirmed the new HtmlRenderer.Test project is already picked up by the existing CI matrix in build.yml without changes — it targets plain net8.0 (no UI framework dependency), and its filename already matches the non-Windows job's Source/Test/**/*.Test.csproj glob, while the Windows job runs dotnet test against the whole .sln.
  • All 9 CI matrix jobs (Windows/Ubuntu/macOS × .NET 8/9/10) pass.

PeachPDF forked from HTML-Renderer and has since built out a much
larger CSS engine, SVG support, and PDF pipeline, with a large xUnit
test suite covering it. This adds a new HtmlRenderer.Test project
(MSTest, matching this repo's existing test style) and ports the
subset of PeachPDF.Tests that HTML-Renderer's current feature set can
actually exercise, routing tests to the appropriate project:

- HtmlRenderer.Test: CSS parsing/property and Core Dom/Utils unit
  tests, using a new lightweight mock RAdapter/RGraphics test harness
  (no dependency on any UI framework).
- HtmlRenderer.IntegrationTest: end-to-end layout/paint behavior
  tests, using a similar harness backed by the real WinForms adapter.
- HtmlRenderer.PdfSharp.Test: PDF-generation and PdfSharp-adapter
  tests.

Of the ~483 candidate test files, the large majority test PeachPDF
features HTML-Renderer doesn't have at all (its own CSS engine, SVG,
flexbox/grid, shadows/gradients, WOFF fonts, bidi text shaping, etc.)
and were left out. Where a ported test exercises a feature that does
exist in HTML-Renderer but whose current implementation isn't spec
compliant, the test is still ported (full assertions intact, so it
documents the real target behavior) but marked
[Ignore("not yet spec compliant")] rather than dropped or forced to
pass.

InternalsVisibleTo grants were added to HtmlRenderer/HtmlRenderer.WinForms/
HtmlRenderer.PdfSharp for their respective test projects, matching the
same grants PeachPDF's own csproj already declares for PeachPDF.Tests.

More tests will be ported incrementally from PeachPDF as HTML-Renderer
backports more of its standard/spec support.
dotnet test's underlying MSBuild VSTest target only accepts a single
project (MSB1008: Only one project can be specified), unlike dotnet
build. The non-Windows test step passed the *.Test.csproj glob
straight to dotnet test, which happened to work when only one project
matched it, but now that HtmlRenderer.Test.csproj also matches, dotnet
expands the glob to two paths and the step fails outright. Iterate and
test each matching project individually instead.
@eXpl0it3r
eXpl0it3r force-pushed the port-peachpdf-tests branch from 0571cb4 to 69f5ef0 Compare August 21, 2026 19:31
@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Rebased onto master and removed Claude co-author attribution

Between opening this PR and now, HTML-Renderer's old hand-rolled CSS
parser/CssData was replaced by a real ExCSS-derived engine, and
RAdapter/RGraphicsPath/PdfGenerator gained new signatures (multi-stop
gradients, @font-face loading, elliptical ArcTo radii, async PDF
generation). Rebasing this branch onto that work left several ported
test files referencing now-removed APIs (CssParser.ParseCssBlock,
CssData.GetCssBlock/ContainsCssBlock, CssParser.ParseBorder, the
proprietary corner-radius/ActualCornerNw mechanism).

- MockAdapter/RecordingGraphics (both HtmlRenderer.Test and
  HtmlRenderer.IntegrationTest): implement the new
  CreateLinearGradientBrush(RPoint, RPoint, stops[]) and
  LoadFontFaceFontInt overloads, and the 5-arg ArcTo signature.
- PdfGeneratorTests: await the now-async PdfGenerator.GeneratePdf.
- The 7 CSS unit tests that parsed raw property strings directly now
  go through CssParser.ParseInlineStyle/IStyleRule for
  declaration-level checks, or the full LayoutHarness pipeline for
  cascade-level checks, matching how the rest of this port already
  verifies behavior.
- BorderRadiusIntegrationTests: rewritten against the new engine's
  real, spec-compliant border-radius properties
  (ActualBorderTopLeftRadiusX/Y etc.), replacing the now-removed
  proprietary corner-radius workaround this test previously had to use.

Since the real engine fixes several of the compliance gaps the
original port had to mark [Ignore("not yet spec compliant")] for,
those tests are un-ignored here (cascade specificity, media-query
not/only/comma-lists, several illegal-value rejections, all of
border-radius). One new regression the port surfaced (a NullReferenceException
in the new CSS-Nesting parser on malformed split <style> content) is
newly marked [Ignore] with the verified root cause, rather than fixed
here or silently dropped.
@jhaygood86
jhaygood86 force-pushed the port-peachpdf-tests branch from 24d0280 to bf2de64 Compare August 22, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants