Skip to content

test(avalonia): headless tests for rendering, change events, overlays and theme - #33

Merged
Shewart merged 1 commit into
mainfrom
test/avalonia-headless
Oct 16, 2026
Merged

Shewart merged 1 commit into
mainfrom
test/avalonia-headless

Conversation

@Shewart

@Shewart Shewart commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

Avalonia headless tests, and a theme fix they found.

  • New tests/ShellUI.Native.Avalonia.Tests (xunit v3, Avalonia.Headless.XUnit 12.1.3, Skia). It compiles the Avalonia demo's component files, so it tests the code the CLI ships.
    • Every component renders in light and dark.
    • Change events: values set from code raise nothing; a click or key raises the event once (Switch, Checkbox, Toggle, Slider, Tabs, Pagination, Accordion, Collapsible, RadioGroup, Select).
    • Overlays: Dialog keeps Tab inside and returns focus on Escape; Dropdown closes on a click outside without clicking through, and on an item or Escape; HoverCard stays open while hovered and closes when the pointer leaves.
    • Theme: token brushes follow SetTheme; ThemeChanged fires.
  • Added to ShellUI.Native.slnx; the build-avalonia CI job (ubuntu, windows, macOS) runs it.
  • Fix: ShellTheme.EnsureInitialized used a static bool, so a second Application never got the theme palettes and every token lookup failed. It now remembers which application it set up. Template synced.

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • CI/CD changes

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added comments where necessary
  • My changes generate no new warnings

Testing Done

  • Headless suite: 155 tests pass, run twice in a row, and in Release.
  • Main suite: 1462 tests pass. Solution builds with 0 warnings; format clean.
  • Breaking each of these on purpose makes a test fail: the old static theme flag, HoverCard light dismiss, Dropdown click-through, Select's user-input flag.

… and theme

- Every component renders in light and dark (Skia, no display)
- Change events: code-set values stay silent, clicks and keys raise once
- Dialog traps Tab and returns focus on Escape; Dropdown closes on a
  click outside without clicking through; HoverCard stays open while
  hovered and closes on leave
- Token brushes follow SetTheme
- CI runs them on ubuntu, windows and macOS

fix(avalonia): ShellTheme publishes its palettes to a new Application

The initialized flag was a static bool, so a second Application (one per
headless test) never got the palettes and every token lookup failed.
@Shewart
Shewart marked this pull request as ready for review October 16, 2026 17:32
@Shewart
Shewart merged commit ab5f373 into main Oct 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant