Menu
cosmic-mobile
publicLatest change d22956783f74f68f3d7eff1dd31f885aaf0fbe3e - Checkpoint BúiOS prototype and document clean-worktree workflow by AkurAI Build
#[path = "../src/navigation.rs"]
mod navigation;
#[test]
fn setting_defaults_off_and_round_trips() {
assert!(navigation::path().ends_with("cosmic-mobile/navigation"));
let dir = std::env::temp_dir().join(format!("cosmic-nav-test-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("navigation");
assert!(!navigation::enabled(&path));
navigation::save(&path, true).unwrap();
assert!(navigation::enabled(&path));
navigation::save(&path, false).unwrap();
assert!(!navigation::enabled(&path));
std::fs::write(&path, "invalid").unwrap();
assert!(!navigation::enabled(&path));
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn three_equal_touch_targets_reject_outside_coordinates() {
assert_eq!(navigation::button(10., 10., 450., 56.), Some(0));
assert_eq!(navigation::button(225., 28., 450., 56.), Some(1));
assert_eq!(navigation::button(449., 55., 450., 56.), Some(2));
for (x, y) in [(-1., 0.), (450., 10.), (10., 56.), (f64::NAN, 10.)] {
assert_eq!(navigation::button(x, y, 450., 56.), None);
}
}