Skip to main content

Module fake

Module fake 

Source
Expand description

An in-memory DesktopBackend implementation for unit and integration tests.

The backend is Clone-able (all internal state lives behind Arc<Mutex<_>>), so a test can hold one clone for observation while handing another clone to the DesktopController.

use rdi_core::fake::FakeDesktop;
use rdi_core::{IconId, IconSnapshot, Point};

let desktop = FakeDesktop::new();
desktop.add_icon(IconSnapshot::new(
    IconId::from("a"), "A", None, false, Point::new(0, 0),
));

// Handing a clone to the controller (M2 wiring covered elsewhere).
let backend = desktop.clone();

// The test can still inspect state:
assert_eq!(desktop.icon_count(), 1);

Structsยง

FakeDesktop
Observable, cloneable fake desktop backed by a HashMap.
FakeDesktopInner