test: pin the rotation contract and the missing-field default

all eight wl_output variants against their degrees, and a snapshot
serialized without the field deserializing to 0, so an older probe
child never forces a lockstep upgrade.
This commit is contained in:
Mariano Abad
2026-08-17 21:49:50 -03:00
parent 3d18e61afa
commit a3e27b2742
+32
View File
@@ -545,6 +545,38 @@ pub fn get_home_dir_trusted() -> Option<PathBuf> {
mod tests { mod tests {
use super::*; use super::*;
#[test]
fn test_transform_degrees_maps_all_eight_variants() {
use sctk::reexports::client::protocol::wl_output::Transform;
// Flipped variants report their rotation: the frame still needs that turn to read
// upright, and the mirror half has no producer among desktop compositors to test.
for (t, deg) in [
(Transform::Normal, 0),
(Transform::_90, 90),
(Transform::_180, 180),
(Transform::_270, 270),
(Transform::Flipped, 0),
(Transform::Flipped90, 90),
(Transform::Flipped180, 180),
(Transform::Flipped270, 270),
] {
assert_eq!(transform_degrees(t), deg, "{t:?}");
}
}
#[test]
fn test_display_info_without_transform_defaults_to_zero() {
// A snapshot serialized by an older probe child carries no transform field; it must
// deserialize with 0 rather than fail, or a greeter-side child update becomes a
// lockstep upgrade.
let old = r#"{"name":"HDMI-1","x":0,"y":0,"width":1920,"height":1080,"logical_size":null,"refresh_rate":60}"#;
let info: WaylandDisplayInfo = serde_json::from_str(old).unwrap();
assert_eq!(info.transform, 0);
let roundtrip: WaylandDisplayInfo =
serde_json::from_str(&serde_json::to_string(&info).unwrap()).unwrap();
assert_eq!(roundtrip.transform, 0);
}
#[test] #[test]
fn test_run_cmds_trim_newline() { fn test_run_cmds_trim_newline() {
assert_eq!(run_cmds_trim_newline("echo -n 123").unwrap(), "123"); assert_eq!(run_cmds_trim_newline("echo -n 123").unwrap(), "123");