mirror of
https://github.com/zed-industries/zed.git
synced 2026-07-09 16:00:35 +00:00
## Screenshot testing Adds visual testing infrastructure for GPUI that captures screenshots by rendering directly to Metal textures. The The screenshots end up in `target/visual_tests/` and look like this: <img width="2560" height="1600" alt="workspace_with_editor2" src="https://github.com/user-attachments/assets/54112343-4af1-4347-9bab-f099de97dd29" /> <img width="2560" height="1600" alt="project_panel2" src="https://github.com/user-attachments/assets/0cd54b61-dace-4398-a28e-0b4d7c2968f6" /> ### Key Features - **Direct texture capture**: Screenshots are captured by rendering the scene to a Metal texture and reading pixels directly from GPU memory, rather than using ScreenCaptureKit - **No visibility requirements**: Windows don't need to be visible on screen since we read directly from the render pipeline - **Deterministic output**: Captures exactly what GPUI renders, not what the OS compositor displays - **No permissions needed**: Doesn't require Screen Recording permission like ScreenCaptureKit would ### Running the Visual Tests ```bash # Run visual tests (compares against baselines) cargo run -p zed --bin visual_test_runner --features visual-tests # Update baseline images (when UI intentionally changes) UPDATE_BASELINE=1 cargo run -p zed --bin visual_test_runner --features visual-tests # View the captured screenshots open target/visual_tests/ ``` ### Implementation - `Window::render_to_image()` - Renders the current scene to a texture and returns an `RgbaImage` - `MetalRenderer::render_to_image()` - Core implementation that renders to a non-framebuffer-only texture - `VisualTestAppContext` - Test context that uses real macOS platform rendering - `VisualTestAppContext::capture_screenshot()` - Synchronous screenshot capture using direct texture rendering ### Usage ```rust let mut cx = VisualTestAppContext::new(); let window = cx.open_window(...)?; let screenshot: RgbaImage = cx.capture_screenshot(window.into())?; ``` Release Notes: - N/A --------- Co-authored-by: Amp <amp@ampcode.com>
51 lines
998 B
Text
51 lines
998 B
Text
**/*.db
|
|
**/cargo-target
|
|
**/target
|
|
**/venv
|
|
**/.direnv
|
|
*.wasm
|
|
*.xcodeproj
|
|
.DS_Store
|
|
.blob_store
|
|
.build
|
|
.claude/settings.local.json
|
|
.envrc
|
|
.flatpak-builder
|
|
.idea
|
|
.netrc
|
|
*.pyc
|
|
.pytest_cache
|
|
.swiftpm
|
|
.swiftpm/config/registries.json
|
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
|
.venv
|
|
.vscode
|
|
.wrangler
|
|
.perf-runs
|
|
/assets/*licenses.*
|
|
/crates/collab/seed.json
|
|
/crates/theme/schemas/theme.json
|
|
/crates/zed/resources/flatpak/flatpak-cargo-sources.json
|
|
/crates/project_panel/benches/linux_repo_snapshot.txt
|
|
/dev.zed.Zed*.json
|
|
/node_modules/
|
|
/plugins/bin
|
|
/script/node_modules
|
|
/snap
|
|
/zed.xcworkspace
|
|
DerivedData/
|
|
Packages
|
|
xcuserdata/
|
|
crates/docs_preprocessor/actions.json
|
|
|
|
# Don't commit any secrets to the repo.
|
|
.env
|
|
.env.secret.toml
|
|
|
|
# `nix build` output
|
|
/result
|
|
|
|
# Visual test baseline images (these will be stored outside
|
|
# the repo in the future, but we don't haven't decided exactly
|
|
# where yet, so for now they get generated into a gitignored dir.)
|
|
/crates/zed/test_fixtures/visual_tests/
|