Skip to content
New issue

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

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

Already on GitHub? # to your account

Client gametest screenshot comparison API #4381

Merged
merged 3 commits into from
Jan 21, 2025

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
@modmuss50 modmuss50 mentioned this pull request Jan 15, 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

@modmuss50 modmuss50 added the merge me please Pull requests that are ready to merge label Jan 21, 2025
@modmuss50 modmuss50 merged commit a069796 into FabricMC:1.21.4 Jan 21, 2025
4 checks passed
modmuss50 pushed a commit that referenced this pull request Jan 21, 2025
* Add screenshot comparison API

* Cleanup and docs

* Remove no-longer-needed changes to access widener

(cherry picked from commit a069796)
@Earthcomputer Earthcomputer deleted the screenshot-comparison branch January 21, 2025 19:13
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request last call If you care, make yourself heard right away! merge me please Pull requests that are ready to merge test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants