refactor(windows): converge core/animation.rs and animation/prefix.rs to the shared version

core/animation.rs takes the KDE copy's module docs and its three serde unit tests (without KDE's QtCurve trait, which stays KDE-only); prefix.rs gets the module docs. No code change: the enum, the custom serde impls and the doc comments are as before, so schema.json is unchanged.

Verified: Windows clippy --workspace --locked --all-targets -D warnings clean. The new unit tests cannot run on Linux for this tree (the same tests run in KDE and, after the move, in the protocol crate).
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:53 -07:00
1 parent 163eff4216
commit 51d7454b10
2 files changed
+43

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
//! The kinds of animation that settings can be given for, by prefix (`movement`).
use clap::ValueEnum;
use serde::Deserialize;
+41
View File
@@ -1,3 +1,5 @@
//! The easing curves an animation can have (`komorebic animation-style`).
use clap::ValueEnum;
use serde::Deserialize;
@@ -152,3 +154,42 @@ impl Serialize for AnimationStyle {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_style_is_written_as_its_name_and_a_bezier_as_four_numbers() {
assert_eq!(
serde_json::to_string(&AnimationStyle::EaseInOutSine).unwrap(),
r#""EaseInOutSine""#
);
assert_eq!(
serde_json::to_string(&AnimationStyle::CubicBezier(0.32, 0.72, 0.0, 1.0)).unwrap(),
"[0.32,0.72,0.0,1.0]"
);
}
#[test]
fn a_style_is_read_back_from_what_it_is_written_as() {
for style in [
AnimationStyle::Linear,
AnimationStyle::EaseOutBounce,
AnimationStyle::CubicBezier(0.1, 0.2, 0.3, 0.4),
] {
let json = serde_json::to_string(&style).unwrap();
assert_eq!(
serde_json::from_str::<AnimationStyle>(&json).unwrap(),
style
);
}
}
#[test]
fn a_name_that_is_no_style_and_a_bezier_that_is_not_four_numbers_are_refused() {
assert!(serde_json::from_str::<AnimationStyle>(r#""EaseInPlace""#).is_err());
assert!(serde_json::from_str::<AnimationStyle>("[0.1, 0.2, 0.3]").is_err());
assert!(serde_json::from_str::<AnimationStyle>("[0.1, 0.2, 0.3, 0.4, 0.5]").is_err());
}
}