Skip to content

Add ImageLoader::has_pending and wait_for_pending_images#7030

Merged
lucasmerlin merged 4 commits intomainfrom
lucas/harness-wait-for-loading-images
May 8, 2025
Merged

Add ImageLoader::has_pending and wait_for_pending_images#7030
lucasmerlin merged 4 commits intomainfrom
lucas/harness-wait-for-loading-images

Conversation

@lucasmerlin
Copy link
Collaborator

@lucasmerlin lucasmerlin commented May 7, 2025

With kittest it was difficult to wait for images to be loaded before taking a snapshot test.
This PR adds Harness::with_wait_for_pending_images (true by default) which will cause Harness::run to sleep until all images are loaded (or HarnessBuilder::with_max_steps is exceeded).

It also adds a new ImageLoader::has_pending and BytesLoader::has_pending, which should be implemented if things are loaded / decoded asynchronously.

It reverts #6901 which was my previous attempt to fix this (but this didn't work since only the tested crate is compiled with cfg(test) and not it's dependencies)

@github-actions
Copy link

github-actions bot commented May 7, 2025

Preview available at https://egui-pr-preview.github.io/pr/7030-lucasharness-wait-for-loading-images
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin lucasmerlin force-pushed the lucas/harness-wait-for-loading-images branch from f889705 to f855a9f Compare May 7, 2025 08:26
@lucasmerlin lucasmerlin added feature New feature or request egui_kittest labels May 7, 2025
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@lucasmerlin lucasmerlin merged commit 120d736 into main May 8, 2025
46 of 47 checks passed
@lucasmerlin lucasmerlin deleted the lucas/harness-wait-for-loading-images branch May 8, 2025 07:27
@SunilKukreja1004
Copy link

How do we call the Egui Update function for exiting native egui app in egui_Kittest Struct as we need to pass e frame object ?

darkwater pushed a commit to darkwater/egui that referenced this pull request Aug 24, 2025
)

With kittest it was difficult to wait for images to be loaded before
taking a snapshot test.
This PR adds `Harness::with_wait_for_pending_images` (true by default)
which will cause `Harness::run` to sleep until all images are loaded (or
`HarnessBuilder::with_max_steps` is exceeded).

It also adds a new ImageLoader::has_pending and
BytesLoader::has_pending, which should be implemented if things are
loaded / decoded asynchronously.

It reverts emilk#6901 which was my previous
attempt to fix this (but this didn't work since only the tested crate is
compiled with cfg(test) and not it's dependencies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui_kittest feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants