From 0252fc09614f3ed7db1652203a500f7c1b29f857 Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Wed, 21 Aug 2024 17:30:23 -0400 Subject: [PATCH] don't anticipate double-buffering in tests --- tests/input_playback.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/input_playback.rs b/tests/input_playback.rs index f8fd857..e591249 100644 --- a/tests/input_playback.rs +++ b/tests/input_playback.rs @@ -1,5 +1,6 @@ // BLOCKED: add time strategy tests: https://github.com/bevyengine/bevy/issues/6146 +use bevy::ecs::event::EventRegistry; use bevy::input::keyboard::Key; use bevy::input::keyboard::KeyboardInput; use bevy::input::ButtonState; @@ -40,6 +41,9 @@ fn playback_app(strategy: PlaybackStrategy) -> App { InputPlugin, InputPlaybackPlugin, )); + + let mut registry = app.world_mut().resource_mut::(); + registry.should_update = ShouldUpdateEvents::Always; *app.world_mut().resource_mut::() = strategy; app @@ -67,14 +71,13 @@ fn complex_timestamped_input() -> TimestampedInputs { #[test] fn minimal_playback() { let mut app = playback_app(PlaybackStrategy::FrameCount); + let input_events = app.world().resource::>(); assert_eq!(input_events.len(), 0); - *app.world_mut().resource_mut::() = simple_timestamped_input(); app.update(); - // By default, only events up to the current frame are played back let input_events = app.world().resource::>(); assert_eq!(input_events.len(), 1); let input = app.world().resource::>(); @@ -82,8 +85,7 @@ fn minimal_playback() { app.update(); let input_events = app.world().resource::>(); - // Events are double-buffered - assert_eq!(input_events.len(), 2); + assert_eq!(input_events.len(), 1); let input = app.world().resource::>(); assert!(!input.pressed(KeyCode::KeyF)); } @@ -168,6 +170,7 @@ fn playback_strategy_paused() { #[test] fn playback_strategy_frame() { let mut app = playback_app(PlaybackStrategy::FrameCount); + *app.world_mut().resource_mut::() = complex_timestamped_input(); let timestamped_input = app.world().resource::(); @@ -208,13 +211,13 @@ fn playback_strategy_frame_range_once() { // Frame 3 (events are double buffered) app.update(); let input_events = app.world().resource::>(); - assert_eq!(input_events.len(), 3); + assert_eq!(input_events.len(), 1); // Frame 4 (events are double buffered) app.update(); let input_events = app.world().resource::>(); assert_eq!(*app.world().resource::(), strategy); - assert_eq!(input_events.len(), 1); + assert_eq!(input_events.len(), 0); // Paused app.update(); @@ -246,13 +249,13 @@ fn playback_strategy_frame_range_loop() { // Frame 3 (events are double buffered) app.update(); let input_events = app.world().resource::>(); - assert_eq!(input_events.len(), 3); + assert_eq!(input_events.len(), 1); // Frame 4 (events are double buffered) app.update(); let input_events = app.world().resource::>(); assert_eq!(*app.world().resource::(), strategy); - assert_eq!(input_events.len(), 1); + assert_eq!(input_events.len(), 0); // Spacing frame app.update();