Skip to content

Commit

Permalink
Simplify kittest readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmerlin committed Dec 16, 2024
1 parent 0fb340f commit b136c11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions crates/egui_kittest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ use std::cell::RefCell;

fn main() {
let mut checked = false;
let app = |ctx: &Context| {
CentralPanel::default().show(ctx, |ui| {
ui.checkbox(&mut checked, "Check me!");
});
let app = |ui: &mut egui::Ui| {
ui.checkbox(&mut checked, "Check me!");
};

let mut harness = Harness::builder().with_size(egui::Vec2::new(200.0, 100.0)).build(app);
let mut harness = Harness::new_ui(app);

let checkbox = harness.get_by_label("Check me!");
assert_eq!(checkbox.toggled(), Some(Toggled::False));
Expand All @@ -28,6 +26,9 @@ fn main() {

let checkbox = harness.get_by_label("Check me!");
assert_eq!(checkbox.toggled(), Some(Toggled::True));

// Shrink the window size to the smallest size possible
harness.fit_contents();

// You can even render the ui and do image snapshot tests
#[cfg(all(feature = "wgpu", feature = "snapshot"))]
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_kittest/tests/snapshots/readme_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b136c11

Please sign in to comment.