Skip to content

Add fetch_pixel(s) method to window for unit testing. #2473

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

Open
DragonMoffon opened this issue Dec 17, 2024 · 2 comments
Open

Add fetch_pixel(s) method to window for unit testing. #2473

DragonMoffon opened this issue Dec 17, 2024 · 2 comments
Assignees
Labels
tests Everything related to testing
Milestone

Comments

@DragonMoffon
Copy link
Collaborator

We currently don't have a concrete way to do pixel testing for unit tests. get_image doesn't play nice with the spoof window. It would hopefully be performant, but it doesn't need to be as aggressively optimized as an official screenshot interface.

@DragonMoffon DragonMoffon added the tests Everything related to testing label Dec 17, 2024
@DragonMoffon DragonMoffon added this to the Future milestone Dec 17, 2024
@einarf
Copy link
Member

einarf commented Dec 19, 2024

I started on this a while ago ..

@pushfoo
Copy link
Member

pushfoo commented Mar 1, 2025

I have the following questions:

  • What does "spoof window" mean here? @DragonMoffon
  • Are our windows always assumed to be RGBA buffers?
  • Will all render targets be assumed to be RGBA buffers as well?
  • @einarf When you said "I started on this", did you mean the files below?

The arcade.screenshot functions

This file has commits from einarf in June and August of 2024, and two functions:

def get_pixel(x: int, y: int, components: int = 3) -> tuple[int, ...]:

def get_image(

Offscreen in the top-level conftest.py

This class:

  • is exposed as a top-level test fixture available in all tests via offscreen
  • was created in August of 2024 by einarf before further work by Eruvanos

It has the following methods of interest

def get_image(self) -> PIL.Image.Image:

def read_pixel(self, x, y, components=3) -> tuple[int, int, int, int] | tuple[int, int, int]:

def read_region(self, rect: Rect) -> list[tuple[int, int, int, int]]:

def read_region_bytes(self, rect: Rect, components=3) -> bytes:

def read_region_image(self, rect: Rect, components=3) -> PIL.Image.Image:

@einarf einarf self-assigned this Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Everything related to testing
Projects
None yet
Development

No branches or pull requests

3 participants