New Archetype::Monitor (MonitorWidget, kind-dispatched draw) for XHistoryGraph, XCoreGrid, XNetGraph, XTempHistory, XUsageBar, XStackBar, XVerticalBar, XTachometer, XArcGauge, XDonutGauge, XProcessList, XLoadBadge, XMonitorButton, XMonitorGrid, XSysBox. - data/registry.json + data/palette.json: 15 entries, registry kept in sorted order (the C extractor requires it); palette Misc/X group re-sorted, other sections untouched, registry_index refreshed (XGraph 545->548, XSpreadsheet 546->555). - crates/xframe-widgets/src/monitor.rs: stdlib-only live checks (/proc scan, systemctl is-active, TcpStream::connect_timeout), poll()/update() with a 2s staleness guard, deterministic demo seeding; unit tests incl. headless Canvas draw for all kinds. - Placeholder 16x16 icons (assets/PROVENANCE.md notes they are placeholders pending the C port) + 15 demo examples + README monitor-family section (547 -> 562). - xframe-common ico test tolerates the 15 monitor icons as pending until the C icons land (matched by name, not index). cargo build --workspace: clean, warning-free. xframe-common lib 8/8, xframe-widgets lib 28/28, widget_tests 24/24, demo smoke 3/3, designer palette/seam 4/4 + 4/4 pass.
74 lines
2.4 KiB
Rust
74 lines
2.4 KiB
Rust
//! Palette data tests — no display needed. The live 562/562 drive
|
|
//! through the real buttons runs under Xvfb via the binary itself
|
|
//! (`LIGHTGUI_PALETTE_SELFTEST=<log>`); see README.md.
|
|
|
|
use lightgui_designer::palette::{
|
|
palette_counts, palette_sections, registry_families, registry_names, xframe_entries,
|
|
};
|
|
use lightgui_designer::seam::mapping_len;
|
|
|
|
#[test]
|
|
fn palette_counts_are_xframe_only() {
|
|
let (lg, xf, total) = palette_counts();
|
|
assert_eq!((lg, xf, total), (0, 562, 562));
|
|
}
|
|
|
|
#[test]
|
|
fn palette_sections_sum_to_562() {
|
|
let sections = palette_sections();
|
|
assert_eq!(sections.len(), 11);
|
|
assert_eq!(
|
|
sections.iter().map(|s| s.count).sum::<usize>(),
|
|
562,
|
|
"section counts sum to 562"
|
|
);
|
|
let entries = xframe_entries();
|
|
assert_eq!(entries.len(), 562);
|
|
for s in §ions {
|
|
assert_eq!(
|
|
entries.iter().filter(|e| e.section == s.name).count(),
|
|
s.count,
|
|
"section {} has its entries",
|
|
s.name
|
|
);
|
|
}
|
|
// Palette order is section order, not registry order — but every
|
|
// entry registry_index must point at its own name in the
|
|
// registry, and the two lists must hold the same set of names.
|
|
let names = registry_names();
|
|
for e in &entries {
|
|
assert_eq!(
|
|
names[e.registry_index as usize], e.name,
|
|
"registry_index of {} points at its name",
|
|
e.name
|
|
);
|
|
}
|
|
let mut from_palette: Vec<&str> = entries.iter().map(|e| e.name.as_str()).collect();
|
|
let mut from_registry: Vec<&str> = names.iter().map(String::as_str).collect();
|
|
from_palette.sort_unstable();
|
|
from_registry.sort_unstable();
|
|
assert_eq!(
|
|
from_palette, from_registry,
|
|
"palette and registry hold the same 562 names"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn registry_families_match_brief() {
|
|
let fams: std::collections::HashMap<String, usize> = registry_families().into_iter().collect();
|
|
assert_eq!(fams["Gtk"], 102);
|
|
assert_eq!(fams["T"], 90);
|
|
assert_eq!(fams["Ind"], 250);
|
|
assert_eq!(fams["Stock"], 37);
|
|
assert_eq!(fams["Inst"], 66);
|
|
assert_eq!(fams["X"], 17);
|
|
}
|
|
|
|
#[test]
|
|
fn seam_mapping_covers_the_whole_registry() {
|
|
// Identity mapping: every registry name maps to itself.
|
|
assert_eq!(mapping_len(), 562);
|
|
let names: std::collections::HashSet<String> = registry_names().into_iter().collect();
|
|
assert_eq!(names.len(), 562);
|
|
}
|