Add `ScreenshotRenderer` check to catch missing screenshots
What changed, and why it matters
This commit adds a quality-check to the project's internal screenshot-generation test tool. It counts how many screenshots are produced and raises an error if a test view fails to render one. There is no change to the actual SeedSigner wallet application or its security.
No security action needed. Treat as a normal test/CI enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies tests/screenshot_generator/generator.py and tests/screenshot_generator/utils.py. It introduces a render_count counter on the ScreenshotRenderer, increments it each time a screenshot is saved, and after each target View.run() checks whether the count increased. If not, it raises an exception. It also adds a final print of total screenshots rendered. This is purely a test/CI improvement for the screenshot generator.
Changed components
tests/screenshot_generator/generator.pytests/screenshot_generator/utils.pyInspect captured patch +19 / −0
diff --git a/tests/screenshot_generator/generator.py b/tests/screenshot_generator/generator.py
index 0cc8bfa..d983762 100644
--- a/tests/screenshot_generator/generator.py
+++ b/tests/screenshot_generator/generator.py
@@ -413,8 +413,16 @@ def generate_screenshots(locale):
try:
print(f"Running {screenshot_config.screenshot_name}")
try:
+ cur_count = screenshot_renderer.render_count
+
+ # Set up and run the target View
screenshot_config.run_callback_before()
screenshot_config.View_cls(**screenshot_config.view_kwargs).run()
+
+ if screenshot_renderer.render_count == cur_count:
+ # The View didn't actually render anything
+ raise Exception(f"{screenshot_config.screenshot_name} did not render a screenshot. Verify that its `run_screen()` is reachable by the screenshot generator.")
+
except ScreenshotComplete:
# The target View has run and its Screen has rendered what it needs to
if toast_thread is not None:
@@ -507,3 +515,5 @@ def generate_screenshots(locale):
with open(os.path.join(screenshot_root, "README.md"), 'w') as readme_file:
readme_file.write(main_readme)
+
+ print(f"Screenshots rendered: {screenshot_renderer.render_count}")
diff --git a/tests/screenshot_generator/utils.py b/tests/screenshot_generator/utils.py
index d767bdf..d161831 100644
--- a/tests/screenshot_generator/utils.py
+++ b/tests/screenshot_generator/utils.py
@@ -10,6 +10,10 @@ from seedsigner.views.view import View
class ScreenshotComplete(Exception):
+ """
+ Slightly hacky way for the ScreenshotRenderer to intentionally break out of the
+ normal Controller flow in order to return control to the screenshot generator.
+ """
pass
@@ -30,6 +34,8 @@ class ScreenshotRenderer(Renderer):
renderer.canvas = Image.new('RGB', (renderer.canvas_width, renderer.canvas_height))
renderer.draw = ImageDraw.Draw(renderer.canvas)
+
+ renderer.render_count = 0
def set_screenshot_filename(self, filename:str):
@@ -56,6 +62,9 @@ class ScreenshotRenderer(Renderer):
self.canvas.paste(image)
self.canvas.save(os.path.join(self.screenshot_path, self.screenshot_filename))
+ self.render_count += 1
+
+ # Break out of the normal Controller flow and return to the screenshot generator
raise ScreenshotComplete()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.