Skip to content

Commit

Permalink
[bevy_ui/layout] Update tests to get GlobalTransform properly (bevyen…
Browse files Browse the repository at this point in the history
…gine#12802)

This is 2 of 5 iterative PR's that affect bevy_ui/layout

- [x] Blocked by bevyengine#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

---
  • Loading branch information
StrikeForceZero authored and chompaa committed Apr 5, 2024
1 parent d3aaf55 commit ec29caa
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 ec29caa

Please sign in to comment.