You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
"""
|
|
Test for app launching functionality.
|
|
|
|
This test verifies that the app starting system works correctly,
|
|
including launching existing apps and handling non-existent apps.
|
|
|
|
Works on both desktop and ESP32 by using the standard boot/main
|
|
initialization pattern.
|
|
|
|
Usage:
|
|
Desktop: ./tests/unittest.sh tests/test_graphical_start_app.py
|
|
Device: ./tests/unittest.sh tests/test_graphical_start_app.py --ondevice
|
|
"""
|
|
|
|
import unittest
|
|
import mpos.apps
|
|
import mpos.ui
|
|
from mpos.ui.testing import wait_for_render
|
|
|
|
|
|
class TestStartApp(unittest.TestCase):
|
|
"""Test suite for app launching functionality."""
|
|
|
|
def setUp(self):
|
|
"""Set up test fixtures before each test method."""
|
|
print("\n=== Test Setup ===")
|
|
# No custom initialization needed - boot.py/main.py already ran
|
|
|
|
def tearDown(self):
|
|
"""Clean up after each test method."""
|
|
# Navigate back to launcher to close any opened apps
|
|
try:
|
|
mpos.ui.back_screen()
|
|
wait_for_render(5) # Allow navigation to complete
|
|
except:
|
|
pass # Already on launcher or error
|
|
|
|
print("=== Test Cleanup Complete ===\n")
|
|
|
|
def test_normal(self):
|
|
"""Test that launching an existing app succeeds."""
|
|
print("Testing normal app launch...")
|
|
|
|
result = mpos.apps.start_app("com.micropythonos.launcher")
|
|
wait_for_render(10) # Wait for app to load
|
|
|
|
self.assertTrue(result, "com.micropythonos.launcher should start")
|
|
print("Normal app launch successful")
|
|
|
|
def test_nonexistent(self):
|
|
"""Test that launching a non-existent app fails gracefully."""
|
|
print("Testing non-existent app launch...")
|
|
|
|
result = mpos.apps.start_app("com.micropythonos.nonexistent")
|
|
|
|
self.assertFalse(result, "com.micropythonos.nonexistent should not start")
|
|
print("Non-existent app handled correctly")
|
|
|
|
def test_restart_launcher(self):
|
|
"""Test that restarting the launcher succeeds."""
|
|
print("Testing launcher restart...")
|
|
|
|
result = mpos.apps.restart_launcher()
|
|
wait_for_render(10) # Wait for launcher to load
|
|
|
|
self.assertTrue(result, "restart_launcher() should succeed")
|
|
print("Launcher restart successful")
|
|
|
|
|