#[cfg(feature = "bevy_ci_testing")] use bevy::{ dev_tools::ci_testing::{CiTestingConfig, CiTestingEvent, CiTestingEventOnFrame}, diagnostic::FrameCount, platform_support::collections::HashSet, prelude::*, render::view::screenshot::Captured, state::state::FreelyMutableState, }; #[cfg(feature = "bevy_ci_testing")] pub fn switch_scene_in_ci( mut ci_config: ResMut, scene: Res>, mut next_scene: ResMut>, mut scenes_visited: Local>, frame_count: Res, captured: RemovedComponents, ) { if scene.is_changed() { // Changed scene! trigger a screenshot in 100 frames ci_config.events.push(CiTestingEventOnFrame( frame_count.0 + 100, CiTestingEvent::NamedScreenshot(format!("{:?}", scene.get())), )); if scenes_visited.contains(scene.get()) { // Exit once all scenes have been screenshotted ci_config.events.push(CiTestingEventOnFrame( frame_count.0 + 1, CiTestingEvent::AppExit, )); } return; } if !captured.is_empty() { // Screenshot taken! Switch to the next scene scenes_visited.insert(scene.get().clone()); next_scene.set(scene.get().next()); } } pub trait Next { fn next(&self) -> Self; }