Skip to content

Commit ee9ccbc

Browse files
committed
bevy_text tests work
1 parent 36f4d4d commit ee9ccbc

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crates/bevy_text/src/text2d.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ mod tests {
381381
use bevy_app::{App, Update};
382382
use bevy_asset::{load_internal_binary_asset, Handle};
383383
use bevy_ecs::{event::Events, schedule::IntoSystemConfigs};
384-
use bevy_utils::default;
384+
385+
use crate::{detect_text_needs_rerender, TextSpansScratch};
385386

386387
use super::*;
387388

@@ -398,12 +399,15 @@ mod tests {
398399
.init_resource::<TextPipeline>()
399400
.init_resource::<CosmicFontSystem>()
400401
.init_resource::<SwashCache>()
402+
.init_resource::<TextSpansScratch>()
401403
.add_systems(
402404
Update,
403405
(
406+
detect_text_needs_rerender::<Text2d, TextSpan2d>,
404407
update_text2d_layout,
405-
calculate_bounds_text2d.after(update_text2d_layout),
406-
),
408+
calculate_bounds_text2d,
409+
)
410+
.chain(),
407411
);
408412

409413
// A font is needed to ensure the text is laid out with an actual size.
@@ -414,13 +418,7 @@ mod tests {
414418
|bytes: &[u8], _path: String| { Font::try_from_bytes(bytes.to_vec()).unwrap() }
415419
);
416420

417-
let entity = app
418-
.world_mut()
419-
.spawn((Text2dBundle {
420-
text: Text::from_section(FIRST_TEXT, default()),
421-
..default()
422-
},))
423-
.id();
421+
let entity = app.world_mut().spawn(Text2d::new(FIRST_TEXT)).id();
424422

425423
(app, entity)
426424
}
@@ -472,8 +470,8 @@ mod tests {
472470
.get_entity_mut(entity)
473471
.expect("Could not find entity");
474472
*entity_ref
475-
.get_mut::<Text>()
476-
.expect("Missing Text on entity") = Text::from_section(SECOND_TEXT, default());
473+
.get_mut::<Text2d>()
474+
.expect("Missing Text2d on entity") = Text2d::new(SECOND_TEXT);
477475

478476
// Recomputes the AABB.
479477
app.update();

0 commit comments

Comments
 (0)