use smix_sdk::animation_settings_verified;
#[test]
fn every_setting_at_zero_passes() {
assert!(
animation_settings_verified(&[
("window_animation_scale", "0.0"),
("transition_animation_scale", "0"),
("animator_duration_scale", "0.0"),
])
.is_ok()
);
}
#[test]
fn a_setting_that_did_not_take_is_named() {
let err = animation_settings_verified(&[
("window_animation_scale", "0.0"),
("transition_animation_scale", "1.0"),
("animator_duration_scale", "0.0"),
])
.expect_err("a scale of 1.0 is not off");
assert_eq!(err.len(), 1);
assert!(
err[0].contains("transition_animation_scale") && err[0].contains("1.0"),
"the failure must name the setting and what came back: {err:?}"
);
}
#[test]
fn an_absent_setting_is_not_success() {
for absent in ["", "null"] {
let err = animation_settings_verified(&[("window_animation_scale", absent)])
.expect_err("an absent setting is not off");
assert!(
err[0].contains("window_animation_scale"),
"{absent:?} was accepted as off"
);
}
}
#[test]
fn reduce_motion_reads_back_as_one() {
assert!(animation_settings_verified(&[("UIAccessibilityReduceMotionEnabled", "1")]).is_ok());
let err = animation_settings_verified(&[("UIAccessibilityReduceMotionEnabled", "0")])
.expect_err("0 means Reduce Motion is off");
assert!(err[0].contains("UIAccessibilityReduceMotionEnabled"));
}
#[test]
fn a_fresh_device_is_not_quiet() {
let err = animation_settings_verified(&[
("window_animation_scale", "1.0"),
("transition_animation_scale", "1.0"),
("animator_duration_scale", "null"),
])
.expect_err("a fresh emulator animates");
assert_eq!(
err.len(),
3,
"every one of the three has to be named: {err:?}"
);
}