Skip to content

Visual Studio Code, rebuilt in Rust

Rust

test(gpui): read every debug bound, the scene and hitboxes of a frame

rokartur164137c3ba79
diff --git a/native/vendor/gpui-fast/crates/gpui/src/app/test_context.rs b/native/vendor/gpui-fast/crates/gpui/src/app/test_context.rs
index 0564f1c4e9c..83a96f8405c 100644
--- a/native/vendor/gpui-fast/crates/gpui/src/app/test_context.rs
+++ b/native/vendor/gpui-fast/crates/gpui/src/app/test_context.rs
@@ -1046,6 +1046,16 @@ impl VisualTestContext {
self.update(|window, _| window.rendered_frame.debug_bounds.get(selector).copied())
}
+ /// The bounds of every element drawn with a debug selector in the last frame.
+ pub fn all_debug_bounds(&mut self) -> Vec<(String, Bounds<Pixels>)> {
+ self.update(|window, _| window.rendered_frame.debug_bounds.iter().map(|(selector, bounds)| (selector.clone(), *bounds)).collect())
+ }
+
+ /// Reads the scene and the hitboxes of the last frame.
+ pub fn read_rendered_frame<R>(&mut self, read: impl FnOnce(&crate::Scene, &[crate::Hitbox]) -> R) -> R {
+ self.update(|window, _| read(&window.rendered_frame.scene, &window.rendered_frame.hitboxes))
+ }
+
/// Draw an element to the window. Useful for simulating events or actions
pub fn draw<E>(
&mut self,