forked from MicroPythonOS/MicroPythonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_graphical_start_app.py
More file actions
67 lines (47 loc) · 2.18 KB
/
test_graphical_start_app.py
File metadata and controls
67 lines (47 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
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
from mpos import ui, wait_for_render, AppManager
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 = AppManager.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 = AppManager.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 = AppManager.restart_launcher()
wait_for_render(10) # Wait for launcher to load
self.assertTrue(result, "restart_launcher() should succeed")
print("Launcher restart successful")