use super::super::{GROUND, ROW, install, type_scale};
use crate::settings::{HELP_DELAY, Settings};
#[test]
fn install_sets_the_type_scale() {
let ctx = egui::Context::default();
install(&ctx, &Settings::default());
let style = ctx.style();
let size = |ts: egui::TextStyle| style.text_styles.get(&ts).map(|f| f.size);
assert_eq!(size(egui::TextStyle::Body), Some(type_scale::BODY));
assert_eq!(size(egui::TextStyle::Heading), Some(type_scale::HEADING));
assert_eq!(size(egui::TextStyle::Small), Some(type_scale::SMALL));
assert_eq!(size(egui::TextStyle::Monospace), Some(type_scale::MONO));
assert!(
style.spacing.interact_size.y <= ROW,
"a control stands under a row"
);
assert_eq!(style.visuals.panel_fill, GROUND);
}
#[test]
fn install_installs_the_wheel_the_delay_and_the_scale() {
let ctx = egui::Context::default();
let settings = Settings {
wheel: 180.0,
help_delay: 1.5,
scale: 1.5,
..Settings::default()
};
for _ in 0..2 {
let _ = ctx.run(egui::RawInput::default(), |ctx| {
install(ctx, &settings);
});
}
assert!((ctx.options(|o| o.line_scroll_speed) - 180.0).abs() < f32::EPSILON);
assert!(!ctx.options(|o| o.zoom_with_keyboard));
assert!((ctx.style().interaction.tooltip_delay - 1.5).abs() < f32::EPSILON);
assert!((ctx.zoom_factor() - 1.5).abs() < f32::EPSILON);
let off = Settings {
on: std::collections::BTreeSet::new(),
..Settings::default()
};
install(&ctx, &off);
assert!(ctx.style().interaction.tooltip_delay.is_infinite());
assert!(ctx.style().interaction.tooltip_grace_time.abs() < f32::EPSILON);
install(&ctx, &Settings::default());
assert!((ctx.style().interaction.tooltip_delay - HELP_DELAY).abs() < f32::EPSILON);
}