-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathtest_graphical_osupdate.py
More file actions
160 lines (125 loc) · 5.88 KB
/
test_graphical_osupdate.py
File metadata and controls
160 lines (125 loc) · 5.88 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import unittest
import lvgl as lv
import mpos
from mpos import (
wait_for_text,
find_label_with_text,
verify_text_present,
print_screen_labels,
BuildInfo,
AppManager
)
class TestOSUpdateGraphicalUI(unittest.TestCase):
"""Graphical tests for OSUpdate app UI state."""
def tearDown(self):
mpos.ui.back_screen()
def test_app_launches_successfully(self):
"""Test that OSUpdate app launches without errors."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result, "Failed to start OSUpdate app")
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not show version label within timeout"
)
screen = lv.screen_active()
self.assertIsNotNone(screen, "No active screen after launch")
def test_ui_elements_exist(self):
"""Test that all required UI elements are created."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
current_version_label = find_label_with_text(screen, "Installed OS version")
self.assertIsNotNone(current_version_label, "Current version label not found")
update_button_found = verify_text_present(screen, "Update") or verify_text_present(screen, "update") or \
verify_text_present(screen, "Reinstall") or verify_text_present(screen, "Install")
self.assertTrue(update_button_found, "Update button text not found")
def test_install_button_text_exists(self):
"""Test that install button with update text exists on screen."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
button_text_found = verify_text_present(screen, "Update OS") or \
verify_text_present(screen, "Reinstall") or \
verify_text_present(screen, "Install")
self.assertTrue(button_text_found, "Install button text should be present on screen")
def test_current_version_displayed(self):
"""Test that current OS version is displayed correctly."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version:", timeout=10),
"Version label did not appear within timeout"
)
screen = lv.screen_active()
version_label = find_label_with_text(screen, "Installed OS version:")
self.assertIsNotNone(version_label, "Version label not found")
label_text = version_label.get_text()
current_version = BuildInfo.version.release
self.assertIn(current_version, label_text,
f"Current version {current_version} not in label text: {label_text}")
def test_initial_status_message_without_wifi(self):
"""Test status message when wifi is not connected."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
checking_found = verify_text_present(screen, "Checking") or \
verify_text_present(screen, "version") or \
verify_text_present(screen, "WiFi")
self.assertTrue(checking_found, "Should show some status message")
def test_initial_state_labels(self):
"""Print initial app labels for debugging."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
print("\n=== OSUpdate Initial State Labels ===")
print_screen_labels(screen)
class TestOSUpdateGraphicalStatusMessages(unittest.TestCase):
"""Graphical tests for OSUpdate status messages."""
def tearDown(self):
mpos.ui.back_screen()
def test_status_label_exists(self):
"""Test that status label is created and visible."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
has_status = (
verify_text_present(screen, "Checking") or
verify_text_present(screen, "version") or
verify_text_present(screen, "WiFi") or
verify_text_present(screen, "Error") or
verify_text_present(screen, "Update")
)
self.assertTrue(has_status, "Status label should be present with some message")
def test_all_labels_readable(self):
"""Test that all labels are readable (no truncation issues)."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
self.assertTrue(
wait_for_text("Installed OS version", timeout=10),
"OSUpdate app did not load within timeout"
)
screen = lv.screen_active()
print("\n=== All OSUpdate Labels ===")
print_screen_labels(screen)
version_found = verify_text_present(screen, "Installed OS version")
self.assertTrue(version_found, "Version label should be present and readable")