mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
Add egui_kittest::HarnessBuilder::with_os and set the default to Nix (#7493)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ pub struct HarnessBuilder<State = ()> {
|
||||
pub(crate) screen_rect: Rect,
|
||||
pub(crate) pixels_per_point: f32,
|
||||
pub(crate) theme: egui::Theme,
|
||||
pub(crate) os: egui::os::OperatingSystem,
|
||||
pub(crate) max_steps: u64,
|
||||
pub(crate) step_dt: f32,
|
||||
pub(crate) state: PhantomData<State>,
|
||||
@@ -26,6 +27,7 @@ impl<State> Default for HarnessBuilder<State> {
|
||||
max_steps: 4,
|
||||
step_dt: 1.0 / 4.0,
|
||||
wait_for_pending_images: true,
|
||||
os: egui::os::OperatingSystem::Nix,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +56,21 @@ impl<State> HarnessBuilder<State> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Override the [`egui::os::OperatingSystem`] reported to egui.
|
||||
///
|
||||
/// This affects e.g. the way shortcuts are displayed. So for snapshot tests,
|
||||
/// it makes sense to set this to a specific OS, so snapshots don't change when running
|
||||
/// the same tests on different OSes.
|
||||
///
|
||||
/// Default is [`egui::os::OperatingSystem::Nix`].
|
||||
/// Use [`egui::os::OperatingSystem::from_target_os()`] to use the current OS (this restores
|
||||
/// eguis default behavior).
|
||||
#[inline]
|
||||
pub fn with_os(mut self, os: egui::os::OperatingSystem) -> Self {
|
||||
self.os = os;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the maximum number of steps to run when calling [`Harness::run`].
|
||||
///
|
||||
/// Default is 4.
|
||||
|
||||
@@ -93,6 +93,7 @@ impl<'a, State> Harness<'a, State> {
|
||||
screen_rect,
|
||||
pixels_per_point,
|
||||
theme,
|
||||
os,
|
||||
max_steps,
|
||||
step_dt,
|
||||
state: _,
|
||||
@@ -101,6 +102,7 @@ impl<'a, State> Harness<'a, State> {
|
||||
} = builder;
|
||||
let ctx = ctx.unwrap_or_default();
|
||||
ctx.set_theme(theme);
|
||||
ctx.set_os(os);
|
||||
ctx.enable_accesskit();
|
||||
ctx.all_styles_mut(|style| {
|
||||
// Disable cursor blinking so it doesn't interfere with snapshots
|
||||
|
||||
Reference in New Issue
Block a user