77This is a proof of concept for graphical testing that:
881. Starts an app programmatically
992. Verifies UI content via direct widget inspection
10- 3. Captures screenshots for visual regression testing
11- 4. Works on both desktop and device
10+ 3. Works on both desktop and device
1211
1312Usage:
1413 Desktop: ./tests/unittest.sh tests/test_graphical_about_app.py
1817import unittest
1918import lvgl as lv
2019import mpos .ui
21- import os
2220from mpos import (
2321 wait_for_render ,
24- capture_screenshot ,
2522 find_label_with_text ,
2623 verify_text_present ,
2724 print_screen_labels ,
2825 DeviceInfo ,
2926 BuildInfo ,
30- AppManager
27+ AppManager ,
3128)
3229
3330
@@ -36,21 +33,6 @@ class TestGraphicalAboutApp(unittest.TestCase):
3633
3734 def setUp (self ):
3835 """Set up test fixtures before each test method."""
39- # Get absolute path to screenshots directory
40- # When running tests, we're in internal_filesystem/, so go up one level
41- import sys
42- if sys .platform == "esp32" :
43- self .screenshot_dir = "tests/screenshots"
44- else :
45- # On desktop, tests directory is in parent
46- self .screenshot_dir = "../tests/screenshots"
47-
48- # Ensure screenshots directory exists
49- try :
50- os .mkdir (self .screenshot_dir )
51- except OSError :
52- pass # Directory already exists
53-
5436 # Store hardware ID for verification
5537 self .hardware_id = DeviceInfo .hardware_id
5638 print (f"Testing with hardware ID: { self .hardware_id } " )
@@ -73,7 +55,6 @@ def test_about_app_shows_correct_hardware_id(self):
7355 2. Wait for UI to render
7456 3. Find the "Hardware ID:" label
7557 4. Verify it contains the actual hardware ID
76- 5. Capture screenshot for visual verification
7758 """
7859 print ("\n === Starting About app test ===" )
7960
@@ -116,25 +97,6 @@ def test_about_app_shows_correct_hardware_id(self):
11697 f"Hardware ID '{ self .hardware_id } ' not found on screen"
11798 )
11899
119- # Capture screenshot for visual regression testing
120- screenshot_path = f"{ self .screenshot_dir } /about_app_{ self .hardware_id } .raw"
121- print (f"\n Capturing screenshot to: { screenshot_path } " )
122-
123- try :
124- buffer = capture_screenshot (screenshot_path , width = 320 , height = 240 )
125- print (f"Screenshot captured: { len (buffer )} bytes" )
126-
127- # Verify screenshot file was created
128- stat = os .stat (screenshot_path )
129- self .assertTrue (
130- stat [6 ] > 0 , # stat[6] is file size
131- "Screenshot file is empty"
132- )
133- print (f"Screenshot file size: { stat [6 ]} bytes" )
134-
135- except Exception as e :
136- self .fail (f"Failed to capture screenshot: { e } " )
137-
138100 print ("\n === About app test completed successfully ===" )
139101
140102 def test_about_app_shows_os_version (self ):
0 commit comments