implements PLN-0142
This commit is contained in:
@@ -32,6 +32,7 @@ impl VirtualMachineRuntime {
|
||||
gfx2d_commands: Vec::new(),
|
||||
gfxui_commands: Vec::new(),
|
||||
logs_written_this_frame: HashMap::new(),
|
||||
game_lifecycle_events_delivered: Vec::new(),
|
||||
atomic_telemetry,
|
||||
last_crash_report: None,
|
||||
certifier: Certifier::new(cap_config.unwrap_or_default()),
|
||||
@@ -135,6 +136,7 @@ impl VirtualMachineRuntime {
|
||||
self.gfx2d_commands.clear();
|
||||
self.gfxui_commands.clear();
|
||||
self.logs_written_this_frame.clear();
|
||||
self.game_lifecycle_events_delivered.clear();
|
||||
|
||||
self.last_crash_report = None;
|
||||
|
||||
@@ -191,6 +193,21 @@ impl VirtualMachineRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deliver_game_lifecycle_events<I>(&mut self, events: I)
|
||||
where
|
||||
I: IntoIterator<Item = GameLifecycleEvent>,
|
||||
{
|
||||
self.game_lifecycle_events_delivered.extend(events);
|
||||
}
|
||||
|
||||
pub fn delivered_game_lifecycle_events(&self) -> &[GameLifecycleEvent] {
|
||||
&self.game_lifecycle_events_delivered
|
||||
}
|
||||
|
||||
pub fn take_delivered_game_lifecycle_events(&mut self) -> Vec<GameLifecycleEvent> {
|
||||
std::mem::take(&mut self.game_lifecycle_events_delivered)
|
||||
}
|
||||
|
||||
pub fn initialize_vm(
|
||||
&mut self,
|
||||
log_service: &mut LogService,
|
||||
@@ -224,3 +241,26 @@ impl VirtualMachineRuntime {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::os::{GameLifecycleEvent, GameLifecycleEventKind};
|
||||
use crate::task::TaskId;
|
||||
|
||||
#[test]
|
||||
fn vm_runtime_records_and_drains_delivered_game_lifecycle_events() {
|
||||
let mut runtime = VirtualMachineRuntime::new(None);
|
||||
let pause = GameLifecycleEvent { task_id: TaskId(7), kind: GameLifecycleEventKind::Pause };
|
||||
let resume = GameLifecycleEvent {
|
||||
task_id: TaskId(7),
|
||||
kind: GameLifecycleEventKind::ResumeForeground,
|
||||
};
|
||||
|
||||
runtime.deliver_game_lifecycle_events([pause, resume]);
|
||||
|
||||
assert_eq!(runtime.delivered_game_lifecycle_events(), &[pause, resume]);
|
||||
assert_eq!(runtime.take_delivered_game_lifecycle_events(), vec![pause, resume]);
|
||||
assert!(runtime.delivered_game_lifecycle_events().is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ mod tests;
|
||||
mod tick;
|
||||
|
||||
use crate::CrashReport;
|
||||
use crate::os::GameLifecycleEvent;
|
||||
pub use frame_scheduler::FrameScheduler;
|
||||
use prometeu_bytecode::string_materialization_count;
|
||||
use prometeu_hal::app_mode::AppMode;
|
||||
@@ -49,6 +50,7 @@ pub struct VirtualMachineRuntime {
|
||||
pub gfx2d_commands: Vec<Gfx2dCommand>,
|
||||
pub gfxui_commands: Vec<GfxUiCommand>,
|
||||
pub logs_written_this_frame: HashMap<u32, u32>,
|
||||
pub game_lifecycle_events_delivered: Vec<GameLifecycleEvent>,
|
||||
pub atomic_telemetry: Arc<AtomicTelemetry>,
|
||||
pub last_crash_report: Option<CrashReport>,
|
||||
pub certifier: Certifier,
|
||||
|
||||
Reference in New Issue
Block a user