implements PLN-0155
This commit is contained in:
@@ -9,7 +9,6 @@ use prometeu_hal::log::LogSource;
|
||||
use prometeu_hal::telemetry::CertificationConfig;
|
||||
use prometeu_hal::{InputSignals, RuntimePlatform};
|
||||
use prometeu_system::{PrometeuHub, ResidentGameState, SystemOS};
|
||||
use prometeu_vm::VirtualMachine;
|
||||
|
||||
/// PROMETEU Firmware.
|
||||
///
|
||||
@@ -27,8 +26,6 @@ use prometeu_vm::VirtualMachine;
|
||||
/// 2. Delegates the logic update to the current active state.
|
||||
/// 3. Handles state transitions (e.g., from Loading to Playing).
|
||||
pub struct Firmware {
|
||||
/// The execution engine (PVM) for user applications.
|
||||
pub vm: VirtualMachine,
|
||||
/// The underlying OS services (Syscalls, Filesystem, Telemetry).
|
||||
pub os: SystemOS,
|
||||
/// The internal state of the system launcher (Hub).
|
||||
@@ -46,7 +43,6 @@ impl Firmware {
|
||||
/// Initializes the firmware in the `Reset` state.
|
||||
pub fn new(cap_config: Option<CertificationConfig>) -> Self {
|
||||
Self {
|
||||
vm: VirtualMachine::default(),
|
||||
os: SystemOS::new(cap_config),
|
||||
hub: PrometeuHub::new(),
|
||||
state: FirmwareState::Reset(ResetStep),
|
||||
@@ -122,7 +118,6 @@ impl Firmware {
|
||||
/// Dispatches the `on_enter` event to the current state implementation.
|
||||
fn on_enter(&mut self, signals: &InputSignals, platform: &mut dyn RuntimePlatform) {
|
||||
let mut req = PrometeuContext {
|
||||
vm: &mut self.vm,
|
||||
os: &mut self.os,
|
||||
hub: &mut self.hub,
|
||||
boot_target: &self.boot_target,
|
||||
@@ -150,7 +145,6 @@ impl Firmware {
|
||||
platform: &mut dyn RuntimePlatform,
|
||||
) -> Option<FirmwareState> {
|
||||
let mut req = PrometeuContext {
|
||||
vm: &mut self.vm,
|
||||
os: &mut self.os,
|
||||
hub: &mut self.hub,
|
||||
boot_target: &self.boot_target,
|
||||
@@ -173,7 +167,6 @@ impl Firmware {
|
||||
/// Dispatches the `on_exit` event to the current state implementation.
|
||||
fn on_exit(&mut self, signals: &InputSignals, platform: &mut dyn RuntimePlatform) {
|
||||
let mut req = PrometeuContext {
|
||||
vm: &mut self.vm,
|
||||
os: &mut self.os,
|
||||
hub: &mut self.hub,
|
||||
boot_target: &self.boot_target,
|
||||
@@ -532,6 +525,24 @@ mod tests {
|
||||
assert!(matches!(firmware.state, FirmwareState::LaunchHub(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_clears_vm_sessions_and_runtime_identity() {
|
||||
let mut firmware = Firmware::new(None);
|
||||
let mut platform = TestPlatform::new();
|
||||
let signals = InputSignals::default();
|
||||
|
||||
firmware.load_cartridge(valid_cartridge(AppMode::Game));
|
||||
firmware.tick(&signals, &mut platform);
|
||||
|
||||
assert_eq!(firmware.os.sessions().vm_session_count(), 1);
|
||||
assert_eq!(firmware.os.vm().current_cartridge_title(), "Valid Cart");
|
||||
|
||||
firmware.change_state(FirmwareState::Reset(ResetStep), &signals, &mut platform);
|
||||
|
||||
assert_eq!(firmware.os.sessions().vm_session_count(), 0);
|
||||
assert_eq!(firmware.os.vm().current_cartridge_title(), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_cartridge_routes_system_apps_to_system_running() {
|
||||
let mut firmware = Firmware::new(None);
|
||||
|
||||
Reference in New Issue
Block a user