Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client gametest screenshot comparison API #4381

Open
wants to merge 3 commits into
base: 1.21.4
Choose a base branch
from

Conversation

Earthcomputer
Copy link
Contributor

Adds APIs to assert that a screenshot matches or contains a template image.

Comment on lines +39 to +43
* <p>Template images loaded from a path are expected to be in the {@code templates} directory inside the resources
* directory of the mod which registered the gametest. If the template image is not found, and the
* {@code fabric.client.gametest.testModResourcesPath} system property is set to the resources folder of the mod which
* registered the gametest, then the screenshot will be saved to the {@code templates} folder so that it can be used
* next time the gametest is run.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if loom could set this system property by default?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can assume the default path and allow the user to override it in the DSL, can you open an loom issue so its not forgotten about?

@Earthcomputer Earthcomputer changed the title Screenshot comparison Client gametest screenshot comparison API Jan 14, 2025
Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

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

This is really good, the default algorithms look good, im glad we arent pulling in natives to do it :D

Comment on lines +39 to +43
* <p>Template images loaded from a path are expected to be in the {@code templates} directory inside the resources
* directory of the mod which registered the gametest. If the template image is not found, and the
* {@code fabric.client.gametest.testModResourcesPath} system property is set to the resources folder of the mod which
* registered the gametest, then the screenshot will be saved to the {@code templates} folder so that it can be used
* next time the gametest is run.
Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can assume the default path and allow the user to override it in the DSL, can you open an loom issue so its not forgotten about?

@modmuss50 modmuss50 added last call If you care, make yourself heard right away! test enhancement New feature or request labels Jan 16, 2025
* @param <DATA> The type of the image data array
*/
@ApiStatus.NonExtendable
interface RawImage<DATA> {
Copy link
Member

Choose a reason for hiding this comment

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

This is a non-extendable interface, but are there any public APIs that create instances of it (ie can it even be used with API code)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no public APIs to create instances of RawImage, but it can be used by custom implementations of TestScreenshotComparisonAlgorithm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request last call If you care, make yourself heard right away! test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants