Skip to content

Commit

Permalink
Simplify GlobalTransform update in bevy_ui/layout tests
Browse files Browse the repository at this point in the history
Remove the need to manually update GlobalTransform
in bevy_ui/layout tests
  • Loading branch information
StrikeForceZero committed Mar 29, 2024
1 parent fd718d3 commit d03ba9f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/bevy_ui/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -399,6 +400,8 @@ mod tests {
update_target_camera_system,
apply_deferred,
ui_layout_system,
sync_simple_transforms,
propagate_transforms,
)
.chain(),
);
Expand Down Expand Up @@ -697,15 +700,11 @@ mod tests {
ui_schedule.run(&mut world);

let overlap_check = world
.query_filtered::<(Entity, &Node, &mut GlobalTransform, &Transform), Without<Parent>>()
.iter_mut(&mut world)
.query_filtered::<(Entity, &Node, &GlobalTransform), Without<Parent>>()
.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.,
Expand Down

0 comments on commit d03ba9f

Please sign in to comment.