From ec29caabef306021294f8628fc754c3ca7c67238 Mon Sep 17 00:00:00 2001 From: Brett Striker Date: Tue, 2 Apr 2024 22:48:06 -0400 Subject: [PATCH] [bevy_ui/layout] Update tests to get GlobalTransform properly (#12802) This is 2 of 5 iterative PR's that affect bevy_ui/layout - [x] Blocked by https://github.com/bevyengine/bevy/pull/12801 [Diff to parent PR](https://github.com/StrikeForceZero/bevy/compare/dev/bevy_ui/breakup_layout_mod..dev/bevy_ui/update_layout_tests) --- # Objective - Update a test in bevy_ui/layout to use the proper way to get an up to date `GlobalTransform` ## Solution - Adds `sync_simple_transforms`, and `propagate_transforms` to the test schedule in bevy_ui/layout --- --- crates/bevy_ui/src/layout/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 62d60f50cbb18..ccff47ae38067 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -343,7 +343,8 @@ mod tests { use bevy_render::camera::OrthographicProjection; use bevy_render::prelude::Camera; use bevy_render::texture::Image; - use bevy_transform::prelude::{GlobalTransform, Transform}; + use bevy_transform::prelude::GlobalTransform; + use bevy_transform::systems::{propagate_transforms, sync_simple_transforms}; use bevy_utils::prelude::default; use bevy_utils::HashMap; use bevy_window::PrimaryWindow; @@ -399,6 +400,8 @@ mod tests { update_target_camera_system, apply_deferred, ui_layout_system, + sync_simple_transforms, + propagate_transforms, ) .chain(), ); @@ -697,15 +700,11 @@ mod tests { ui_schedule.run(&mut world); let overlap_check = world - .query_filtered::<(Entity, &Node, &mut GlobalTransform, &Transform), Without>() - .iter_mut(&mut world) + .query_filtered::<(Entity, &Node, &GlobalTransform), Without>() + .iter(&world) .fold( Option::<(Rect, bool)>::None, - |option_rect, (entity, node, mut global_transform, transform)| { - // fix global transform - for some reason the global transform isn't populated yet. - // might be related to how these specific tests are working directly with World instead of App - *global_transform = GlobalTransform::from(transform.compute_affine()); - let global_transform = &*global_transform; + |option_rect, (entity, node, global_transform)| { let current_rect = node.logical_rect(global_transform); assert!( current_rect.height().abs() + current_rect.width().abs() > 0.,