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.
76 lines
2.6 KiB
Rust
76 lines
2.6 KiB
Rust
//! Palette --selftest under Xvfb on display :93 (kept clear of the
|
|
//! demo :98, layout :92 and runner :91 tests).
|
|
use std::path::PathBuf;
|
|
use std::process::{Child, Command, Stdio};
|
|
use std::time::{Duration, Instant};
|
|
|
|
fn palette_bin() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_BIN_EXE_xframe-palette"))
|
|
}
|
|
|
|
fn start_xvfb(display: &str) -> Option<Child> {
|
|
// A SIGKILLed Xvfb leaves its socket behind; a stale socket makes
|
|
// the wait below return at once and the X client then fails to
|
|
// connect. Remove it when no server for this display is alive.
|
|
let sock_path = format!("/tmp/.X11-unix/X{}", display.trim_start_matches(':'));
|
|
let server_running = Command::new("pgrep")
|
|
.args(["-f", &format!("Xvfb {}", display)])
|
|
.output()
|
|
.map(|o| o.status.success())
|
|
.unwrap_or(false);
|
|
if !server_running && PathBuf::from(&sock_path).exists() {
|
|
let _ = std::fs::remove_file(&sock_path);
|
|
}
|
|
let child = Command::new("Xvfb")
|
|
.args([display, "-screen", "0", "1280x1024x24"])
|
|
.stdout(Stdio::null())
|
|
.stderr(Stdio::null())
|
|
.spawn()
|
|
.ok()?;
|
|
let sock = format!("/tmp/.X11-unix/X{}", display.trim_start_matches(':'));
|
|
let t0 = Instant::now();
|
|
while !PathBuf::from(&sock).exists() {
|
|
if t0.elapsed() > Duration::from_secs(10) {
|
|
return None;
|
|
}
|
|
std::thread::sleep(Duration::from_millis(100));
|
|
}
|
|
Some(child)
|
|
}
|
|
|
|
#[test]
|
|
fn palette_selftest_selects_all_562() {
|
|
let mut xvfb = match start_xvfb(":93") {
|
|
Some(c) => c,
|
|
None => {
|
|
eprintln!("Xvfb unavailable; skipping X test");
|
|
return;
|
|
}
|
|
};
|
|
let sel = std::env::temp_dir().join("xframe-palette-selftest-selection.txt");
|
|
let _ = std::fs::remove_file(&sel);
|
|
let out = Command::new(palette_bin())
|
|
.arg("--selftest")
|
|
.env("DISPLAY", ":93")
|
|
.env("LIGHTGUI_SELECTION", &sel)
|
|
.output()
|
|
.expect("run palette --selftest");
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
let _ = xvfb.kill();
|
|
let _ = xvfb.wait();
|
|
assert!(
|
|
out.status.success(),
|
|
"palette selftest failed: {}",
|
|
stdout.lines().rev().take(5).collect::<Vec<_>>().join("\n")
|
|
);
|
|
assert!(
|
|
stdout.contains("SELFTEST 562/562 selections OK"),
|
|
"last lines: {}",
|
|
stdout.lines().rev().take(3).collect::<Vec<_>>().join("\n")
|
|
);
|
|
// The selection file must hold the last widget (index 561).
|
|
let sel_text = std::fs::read_to_string(&sel).expect("selection file");
|
|
assert!(sel_text.contains("561"), "selection file: {}", sel_text);
|
|
let _ = std::fs::remove_file(&sel);
|
|
}
|