Skip to content

Conversation

@nathansobo
Copy link
Contributor

@nathansobo nathansobo commented Dec 14, 2025

Summary

TestApp provides a simpler alternative to TestAppContext with:

  • Automatic effect flushing after updates
  • Clean window creation returning typed TestAppWindow<V>
  • Scene inspection via SceneSnapshot
  • Input simulation helpers

Changes

File Changes
app.rs Exports test_app module
app/test_app.rs TestApp and TestAppWindow for cleaner testing
color.rs Background::as_solid() helper
scene.rs SceneSnapshot for inspecting rendered quads/glyphs

Relationship to TestAppContext

This is an alternative API, not a replacement. Both can coexist:

Aspect TestAppContext TestApp
Creation Via #[gpui::test] macro Manual: TestApp::new()
Window type Type-erased VisualTestContext Generic TestAppWindow<V>
Effect flushing Manual Automatic
Scene inspection Not available window.scene_snapshot()

Use TestApp when: You need scene inspection, typed window access, or prefer explicit APIs.

Use TestAppContext when: You need multi-client simulation with shared dispatcher, or are extending existing tests.

Future work

Could add TestApp::new_app() to create a second app sharing the same dispatcher (like TestAppContext::new_app()) for multi-client testing.

Release Notes:

  • N/A

Adds zed/crates/gpui/src/app/test_app.rs with:

- TestApp: test context that auto-runs until parked after updates
- TestAppWindow<V>: window wrapper with input simulation helpers

Minor improvement over TestAppContext/VisualTestContext - mainly
convenience (auto-parking, owned window handle, cleaner signatures).

Does NOT solve the deeper issues:
- Scene is still pub(crate), can't inspect rendered output
- Editor still needs FocusHandle which needs real GPUI context
- TestEditor duplication in ex still exists

3 tests included demonstrating basic usage.
TestApp provides a simpler alternative to TestAppContext with:
- Automatic effect flushing after updates
- Clean window creation returning typed TestAppWindow<V>
- Scene inspection via SceneSnapshot
- Input simulation helpers

Also adds:
- Background::as_solid() helper in color.rs
- SceneSnapshot for inspecting rendered quads/glyphs in scene.rs
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 14, 2025
…rmWindow

- Public API: TestWindow<V> - the new typed test window wrapper
- Internal: TestPlatformWindow - the platform-level mock window (pub(crate))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants