2025-11-14 14:32:59 +01:00
|
|
|
"""
|
|
|
|
|
Graphical test for the About app.
|
|
|
|
|
|
|
|
|
|
This test verifies that the About app displays correct information,
|
|
|
|
|
specifically that the Hardware ID shown matches the actual hardware ID.
|
|
|
|
|
|
|
|
|
|
This is a proof of concept for graphical testing that:
|
|
|
|
|
1. Starts an app programmatically
|
|
|
|
|
2. Verifies UI content via direct widget inspection
|
2026-03-25 14:49:47 +01:00
|
|
|
3. Works on both desktop and device
|
2025-11-14 14:32:59 +01:00
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
Desktop: ./tests/unittest.sh tests/test_graphical_about_app.py
|
2025-11-16 00:29:22 +01:00
|
|
|
Device: ./tests/unittest.sh tests/test_graphical_about_app.py --ondevice
|
2025-11-14 14:32:59 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
import lvgl as lv
|
|
|
|
|
import mpos.ui
|
2026-01-13 00:38:17 +01:00
|
|
|
from mpos import (
|
2025-11-14 14:32:59 +01:00
|
|
|
wait_for_render,
|
|
|
|
|
find_label_with_text,
|
|
|
|
|
verify_text_present,
|
2026-01-24 23:32:10 +01:00
|
|
|
print_screen_labels,
|
|
|
|
|
DeviceInfo,
|
2026-01-25 00:08:01 +01:00
|
|
|
BuildInfo,
|
2026-03-25 14:49:47 +01:00
|
|
|
AppManager,
|
2025-11-14 14:32:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestGraphicalAboutApp(unittest.TestCase):
|
|
|
|
|
"""Test suite for About app graphical verification."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
"""Set up test fixtures before each test method."""
|
|
|
|
|
# Store hardware ID for verification
|
2026-01-24 23:32:10 +01:00
|
|
|
self.hardware_id = DeviceInfo.hardware_id
|
2025-11-14 14:32:59 +01:00
|
|
|
print(f"Testing with hardware ID: {self.hardware_id}")
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
"""Clean up after each test method."""
|
|
|
|
|
# Navigate back to launcher (closes the About app)
|
|
|
|
|
try:
|
|
|
|
|
mpos.ui.back_screen()
|
|
|
|
|
wait_for_render(5) # Allow navigation to complete
|
|
|
|
|
except:
|
|
|
|
|
pass # Already on launcher or error
|
|
|
|
|
|
|
|
|
|
def test_about_app_shows_correct_hardware_id(self):
|
|
|
|
|
"""
|
|
|
|
|
Test that About app displays the correct Hardware ID.
|
|
|
|
|
|
|
|
|
|
Verification approach:
|
|
|
|
|
1. Start the About app
|
|
|
|
|
2. Wait for UI to render
|
|
|
|
|
3. Find the "Hardware ID:" label
|
|
|
|
|
4. Verify it contains the actual hardware ID
|
|
|
|
|
"""
|
|
|
|
|
print("\n=== Starting About app test ===")
|
|
|
|
|
|
|
|
|
|
# Start the About app
|
2026-01-25 00:19:38 +01:00
|
|
|
result = AppManager.start_app("com.micropythonos.about")
|
2025-11-14 14:32:59 +01:00
|
|
|
self.assertTrue(result, "Failed to start About app")
|
|
|
|
|
|
|
|
|
|
# Wait for UI to fully render
|
|
|
|
|
wait_for_render(iterations=15)
|
|
|
|
|
|
|
|
|
|
# Get current screen
|
|
|
|
|
screen = lv.screen_active()
|
|
|
|
|
|
|
|
|
|
# Debug: Print all labels found (helpful for development)
|
|
|
|
|
print("\nLabels found on screen:")
|
|
|
|
|
print_screen_labels(screen)
|
|
|
|
|
|
|
|
|
|
# Verify that Hardware ID text is present
|
|
|
|
|
hardware_id_label = find_label_with_text(screen, "Hardware ID:")
|
|
|
|
|
self.assertIsNotNone(
|
|
|
|
|
hardware_id_label,
|
|
|
|
|
"Could not find 'Hardware ID:' label on screen"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Get the full text from the Hardware ID label
|
|
|
|
|
hardware_id_text = hardware_id_label.get_text()
|
|
|
|
|
print(f"\nHardware ID label text: {hardware_id_text}")
|
|
|
|
|
|
|
|
|
|
# Verify the hardware ID matches
|
|
|
|
|
expected_text = f"Hardware ID: {self.hardware_id}"
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
hardware_id_text,
|
|
|
|
|
expected_text,
|
|
|
|
|
f"Hardware ID mismatch. Expected '{expected_text}', got '{hardware_id_text}'"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Also verify using the helper function
|
|
|
|
|
self.assertTrue(
|
|
|
|
|
verify_text_present(screen, self.hardware_id),
|
|
|
|
|
f"Hardware ID '{self.hardware_id}' not found on screen"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
print("\n=== About app test completed successfully ===")
|
|
|
|
|
|
|
|
|
|
def test_about_app_shows_os_version(self):
|
|
|
|
|
"""
|
|
|
|
|
Test that About app displays the OS version.
|
|
|
|
|
|
|
|
|
|
This is a simpler test that just verifies version info is present.
|
|
|
|
|
"""
|
|
|
|
|
print("\n=== Starting About app OS version test ===")
|
|
|
|
|
|
|
|
|
|
# Start the About app
|
2026-01-25 00:19:38 +01:00
|
|
|
result = AppManager.start_app("com.micropythonos.about")
|
2025-11-14 14:32:59 +01:00
|
|
|
self.assertTrue(result, "Failed to start About app")
|
|
|
|
|
|
|
|
|
|
# Wait for UI to render
|
2026-03-24 21:28:53 +01:00
|
|
|
wait_for_render(iterations=150)
|
2025-11-14 14:32:59 +01:00
|
|
|
|
|
|
|
|
# Get current screen
|
|
|
|
|
screen = lv.screen_active()
|
|
|
|
|
|
|
|
|
|
# Verify that MicroPythonOS version text is present
|
|
|
|
|
self.assertTrue(
|
2026-01-26 11:11:35 +01:00
|
|
|
verify_text_present(screen, "Release version:"),
|
|
|
|
|
"Could not find 'Release version:' on screen"
|
2025-11-14 14:32:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Verify the actual version string is present
|
2026-01-24 23:32:10 +01:00
|
|
|
os_version = BuildInfo.version.release
|
2025-11-14 14:32:59 +01:00
|
|
|
self.assertTrue(
|
|
|
|
|
verify_text_present(screen, os_version),
|
|
|
|
|
f"OS version '{os_version}' not found on screen"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
print(f"Found OS version: {os_version}")
|
|
|
|
|
print("=== OS version test completed successfully ===")
|
|
|
|
|
|
|
|
|
|
|