@@ -352,29 +352,21 @@ pub fn ui_layout_system(
352
352
353
353
#[ cfg( test) ]
354
354
mod tests {
355
+ use crate :: update:: update_cameras_test_system;
356
+ use crate :: {
357
+ layout:: ui_surface:: UiSurface , prelude:: * , ui_layout_system,
358
+ update:: propagate_ui_target_cameras, ContentSize , LayoutContext ,
359
+ } ;
355
360
use bevy_app:: { App , HierarchyPropagatePlugin , PostUpdate , PropagateSet } ;
356
- use taffy:: TraversePartialTree ;
357
-
358
- use bevy_asset:: { AssetEvent , Assets } ;
359
361
use bevy_camera:: { Camera , Camera2d } ;
360
362
use bevy_ecs:: { prelude:: * , system:: RunSystemOnce } ;
361
- use bevy_image:: Image ;
362
363
use bevy_math:: { Rect , UVec2 , Vec2 } ;
363
364
use bevy_platform:: collections:: HashMap ;
364
- use bevy_render:: texture:: ManualTextureViews ;
365
365
use bevy_transform:: systems:: mark_dirty_trees;
366
366
use bevy_transform:: systems:: { propagate_parent_transforms, sync_simple_transforms} ;
367
367
use bevy_utils:: prelude:: default;
368
- use bevy_window:: {
369
- PrimaryWindow , Window , WindowCreated , WindowResized , WindowResolution ,
370
- WindowScaleFactorChanged ,
371
- } ;
372
- //use uuid::timestamp::UUID_TICKS_BETWEEN_EPOCHS;
373
-
374
- use crate :: {
375
- layout:: ui_surface:: UiSurface , prelude:: * , ui_layout_system,
376
- update:: propagate_ui_target_cameras, ContentSize , LayoutContext ,
377
- } ;
368
+ use bevy_window:: { PrimaryWindow , Window , WindowResolution } ;
369
+ use taffy:: TraversePartialTree ;
378
370
379
371
// these window dimensions are easy to convert to and from percentage values
380
372
const WINDOW_WIDTH : f32 = 1000. ;
@@ -388,22 +380,14 @@ mod tests {
388
380
) ) ;
389
381
app. init_resource :: < UiScale > ( ) ;
390
382
app. init_resource :: < UiSurface > ( ) ;
391
- app. init_resource :: < Events < WindowScaleFactorChanged > > ( ) ;
392
- app. init_resource :: < Events < WindowResized > > ( ) ;
393
- // Required for the camera system
394
- app. init_resource :: < Events < WindowCreated > > ( ) ;
395
- app. init_resource :: < Events < AssetEvent < Image > > > ( ) ;
396
- app. init_resource :: < Assets < Image > > ( ) ;
397
- app. init_resource :: < ManualTextureViews > ( ) ;
398
383
app. init_resource :: < bevy_text:: TextPipeline > ( ) ;
399
384
app. init_resource :: < bevy_text:: CosmicFontSystem > ( ) ;
400
385
app. init_resource :: < bevy_text:: SwashCache > ( ) ;
401
386
402
387
app. add_systems (
403
388
PostUpdate ,
404
389
(
405
- // UI is driven by calculated camera target info, so we need to run the camera system first
406
- bevy_render:: camera:: camera_system,
390
+ update_cameras_test_system,
407
391
propagate_ui_target_cameras,
408
392
ApplyDeferred ,
409
393
ui_layout_system,
@@ -1064,14 +1048,7 @@ mod tests {
1064
1048
1065
1049
app. add_systems (
1066
1050
PostUpdate ,
1067
- (
1068
- // UI is driven by calculated camera target info, so we need to run the camera system first
1069
- bevy_render:: camera:: camera_system,
1070
- propagate_ui_target_cameras,
1071
- ApplyDeferred ,
1072
- ui_layout_system,
1073
- )
1074
- . chain ( ) ,
1051
+ ( propagate_ui_target_cameras, ApplyDeferred , ui_layout_system) . chain ( ) ,
1075
1052
) ;
1076
1053
1077
1054
app. add_plugins ( HierarchyPropagatePlugin :: < ComputedUiTargetCamera > :: new (
@@ -1088,29 +1065,13 @@ mod tests {
1088
1065
let world = app. world_mut ( ) ;
1089
1066
world. init_resource :: < UiScale > ( ) ;
1090
1067
world. init_resource :: < UiSurface > ( ) ;
1091
- world. init_resource :: < Events < WindowScaleFactorChanged > > ( ) ;
1092
- world. init_resource :: < Events < WindowResized > > ( ) ;
1093
- // Required for the camera system
1094
- world. init_resource :: < Events < WindowCreated > > ( ) ;
1095
- world. init_resource :: < Events < AssetEvent < Image > > > ( ) ;
1096
- world. init_resource :: < Assets < Image > > ( ) ;
1097
- world. init_resource :: < ManualTextureViews > ( ) ;
1098
1068
1099
1069
world. init_resource :: < bevy_text:: TextPipeline > ( ) ;
1100
1070
1101
1071
world. init_resource :: < bevy_text:: CosmicFontSystem > ( ) ;
1102
1072
1103
1073
world. init_resource :: < bevy_text:: SwashCache > ( ) ;
1104
1074
1105
- // spawn a dummy primary window and camera
1106
- world. spawn ( (
1107
- Window {
1108
- resolution : WindowResolution :: new ( WINDOW_WIDTH , WINDOW_HEIGHT ) ,
1109
- ..default ( )
1110
- } ,
1111
- PrimaryWindow ,
1112
- ) ) ;
1113
-
1114
1075
let ui_root = world
1115
1076
. spawn ( Node {
1116
1077
width : Val :: Percent ( 100. ) ,
0 commit comments