From 02a897dd06bfdafe95c6057007c83235b36eceb1 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Wed, 25 Mar 2026 15:24:34 +0100 Subject: [PATCH] Rename test --- ...enshot.py => test_graphical_screenshot.py} | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) rename tests/{test_screenshot.py => test_graphical_screenshot.py} (72%) diff --git a/tests/test_screenshot.py b/tests/test_graphical_screenshot.py similarity index 72% rename from tests/test_screenshot.py rename to tests/test_graphical_screenshot.py index bcff9538..b96565a4 100644 --- a/tests/test_screenshot.py +++ b/tests/test_graphical_screenshot.py @@ -12,7 +12,7 @@ import os import sys import unittest import mpos.ui -from mpos import AppManager, DeviceInfo, capture_screenshot, wait_for_render +from mpos import AppManager, DeviceInfo, DisplayMetrics, capture_screenshot, wait_for_render class TestScreenshotCapture(unittest.TestCase): @@ -21,7 +21,7 @@ class TestScreenshotCapture(unittest.TestCase): def setUp(self): """Set up test fixtures before each test method.""" if sys.platform == "esp32": - self.screenshot_dir = "tests/screenshots" + self.screenshot_dir = "screenshots" else: self.screenshot_dir = "../tests/screenshots" @@ -54,7 +54,9 @@ class TestScreenshotCapture(unittest.TestCase): print(f"\nCapturing screenshot to: {screenshot_path}") try: - buffer = capture_screenshot(screenshot_path, width=320, height=240) + width = DisplayMetrics.width() + height = DisplayMetrics.height() + buffer = capture_screenshot(screenshot_path, width=width, height=height) print(f"Screenshot captured: {len(buffer)} bytes") stat = os.stat(screenshot_path) @@ -62,8 +64,20 @@ class TestScreenshotCapture(unittest.TestCase): stat[6] > 0, "Screenshot file is empty", ) + expected_size = width * height * 2 + self.assertEqual( + stat[6], + expected_size, + f"Screenshot file size {stat[6]} does not match expected {expected_size}", + ) print(f"Screenshot file size: {stat[6]} bytes") except Exception as exc: self.fail(f"Failed to capture screenshot: {exc}") + finally: + try: + print(f"Removing screenshot {screenshot_path}") + os.remove(screenshot_path) + except OSError: + pass print("\n=== About app screenshot test completed successfully ===")