diff --git a/crates/ui-contract/src/testing/fixture.rs b/crates/ui-contract/src/testing/fixture.rs index 47c093e02..4b407b127 100644 --- a/crates/ui-contract/src/testing/fixture.rs +++ b/crates/ui-contract/src/testing/fixture.rs @@ -525,7 +525,9 @@ impl Fixture { self.frames.record_paint(); self.frame(Vec::new()); let mut out = Vec::new(); - let Some(paint) = self.frames.take_paint() else { return out }; + let Some(mut paint) = self.frames.take_paint() else { return out }; + // Only the shapes are asked for: the texture changes since the first recorded frame go unrendered. + paint.textures_delta.clear(); for clipped in paint.shapes { let mut shapes = Vec::new(); fixture::flatten(clipped.shape, &mut shapes); diff --git a/crates/ui-panels/tests/it/main.rs b/crates/ui-panels/tests/it/main.rs index 83aaa7240..1c11662b4 100644 --- a/crates/ui-panels/tests/it/main.rs +++ b/crates/ui-panels/tests/it/main.rs @@ -18,6 +18,7 @@ pub(crate) mod popup_surface; pub(crate) mod rails; pub(crate) mod sections; +pub(crate) mod story_shapes; craft_ui::registry!(); diff --git a/crates/ui-panels/tests/it/story_shapes.rs b/crates/ui-panels/tests/it/story_shapes.rs new file mode 100644 index 000000000..ef8f94c74 --- /dev/null +++ b/crates/ui-panels/tests/it/story_shapes.rs @@ -0,0 +1,17 @@ +//! A fixture returns the clipped shapes of a frame that uploads textures. + +use craft_ui::testing::{Fixture, Registry, trial}; + +/// Menu, rail and tile stories; the first frame of each uploads textures, the font atlas among them. +const STORIES: [&str; 6] = + ["tool_rail_marked_in_a_closed_group", "edit_menu", "menu", "menu_taller_than_the_window", "menu_with_companion", "tile_actions"]; + +#[trial] +fn the_first_frame_of_a_story_returns_its_clipped_shapes() { + let registry = Registry::of(&[craft_ui::testing::register, craft_ui_widgets::testing::register]); + for name in STORIES { + let entry = registry.stories().iter().find(|entry| entry.story.name == name).unwrap_or_else(|| panic!("story {name}")); + let shapes = Fixture::story(&entry.story).frame_clipped_shapes(); + assert!(!shapes.is_empty(), "{name}: the frame paints the story"); + } +}