Repository navigation
Let TestAppContext render with a real text system, renderer and scale - #11
Open
francois-unity wants to merge 1 commit into
Open
francois-unity wants to merge 1 commit into
francois-unity wants to merge 1 commit into
Conversation
francois-unity
marked this pull request as ready for review
October 8, 2026 14:19
chris-addison
force-pushed
the
unity/a11y-automation
branch
from
October 12, 2026 16:37
33d34a1 to
e916cd1
Compare
TestAppContext::build hardcodes its platform: the stub TestTextSystem, which paints no glyphs, no headless renderer, an empty asset registry, and windows whose scale factor is the constant 2. A test can open a window and read its scene, but not render it to pixels the way an app draws it. HeadlessAppContext can, but it isn’t a TestAppContext, so code written against TestAppContext and VisualTestContext can’t use it. TestAppContext::with_platform takes a text system, an asset source, a headless renderer factory and a scale factor. TestPlatform keeps the scale factor and hands it to each TestWindow, which reports it from scale_factor(), so Window::render_to_image returns an image of the window’s size times that factor. build, and with it #[gpui::test], keeps the stub text system, no renderer, no assets and a scale of 2. gpui_platform::current_headless_renderer now returns WGPU’s headless renderer on Linux, FreeBSD and Windows under test-support, through an optional gpui_wgpu dependency that Linux already builds for its windows. Under bench-support alone it still returns None there. Unit tests drive the new constructor with a recording renderer. A rendering test in gpui_platform renders IBM Plex through Parley with the platform’s headless renderer at two scales, and CI runs it on all three platforms.
chris-addison
force-pushed
the
unity/HUB-8114-configurable-test-platform
branch
from
October 12, 2026 16:41
a40b259 to
9daafb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
TestAppContext::with_platform, which takes a text system, an asset source, a headless renderer factory and a scale factor, so aTestAppContextwindow renders to pixels throughWindow::render_to_imagethe way the app draws it.build, and with it#[gpui::test], keeps the stub text system, no renderer, no assets and a scale of 2.Why: the native Unity Hub’s visual regression suite renders seeded scenes from its headless harness, which is built on
TestAppContextandVisualTestContext(HUB-8114, for HUB-8065).buildhardcodesTestPlatform::new: the stubTestTextSystempaints no glyphs, there is no renderer, and the emptyAssetRegistrydropssvg()icons.TestWindow::scale_factoris the constant 2.HeadlessAppContexthas that configuration but isn’t aTestAppContext; it stays as it is.TestPlatformkeeps a scale factor (2 by default) and hands it to eachTestWindow, whosescale_factor()reads it, resizes included.gpui_platform::current_headless_renderer()returns WGPU’s headless renderer on Linux, FreeBSD and Windows undertest-support, through an optionalgpui_wgpudependency that Linux already builds for its windows. Like Metal’s without a device, it panics without a GPU adapter; lavapipe or WARP is enough. Underbench-supportalone it still returnsNonethere.How to test
cargo +1.98.1 test -p gpui-ce --lib -- app::test_context: three new tests. With a recording renderer, awith_platformwindow at scale 1.5 reports that scale, renders and reads back 300×150 for 200×100, keeps the scale through a resize, and loads its assets.buildstill gives scale 2, no glyph sprites and no assets, andrender_to_imagerefuses. A zero scale panics.GPUI_RUN_RENDERING_TESTS=1 cargo +1.98.1 test -p gpui_ce_platform --features test-support --test test_app_context_render: IBM Plex through Parley withcurrent_headless_renderer()at scales 1 and 1.5, checking glyph sprites, the image size, the background colour and the ink. Green with Metal on macOS; CI runs it with WGPU on Linux and Windows.cargo +1.98.1 test -p gpui-ce --features test-support,-p gpui_ce_elements -p gpui_ce_parley -p gpui_ce_macos -p gpui_ce_platform,parley_renderand workspace clippy with-D warningsare green on macOS. A Linux-targetcargo clippy -p gpui-ce -p gpui_ce_platform --all-targets -- -D warnings, with and withouttest-support, is clean.--features bench-supportalone stops on two errors already at the base (bench_context.rs:536,debug_overlay.rs:220), so itsNonebranch is checked by reading.bindgenbuild-script error (Declare gpui_media’s bindgen build dependency on every host #6 fixes it), and typos on the base’swdth(Let typos accept the renamed Noto Sans font file #10 fixes it).unity/HUB-8070-hub-pin-2(Read a Linux window’s frame back with render-to-image #9’s two commits overunity/HUB-8048-hub-pin-3), asunity/HUB-8114-hub-pin-2(d12157734f) in Unity-Technologies/unity-hub#16239. The cherry-pick is clean, and the same tests and clippy runs are green there, withrender-to-imageon as well.