-
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 (124 loc) · 6.06 KB
/
test_graphical_osupdate.py
File metadata and controls
160 lines (124 loc) · 6.06 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
import unittest
import lvgl as lv
import mpos
# Import graphical test helper
from mpos import (
wait_for_render,
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):
"""Clean up after each test method."""
# Navigate back to launcher
mpos.ui.back_screen()
wait_for_render(60)
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")
wait_for_render(60)
# Get active screen
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)
wait_for_render(60)
screen = lv.screen_active()
# Find UI elements by searching for labels/text
current_version_label = find_label_with_text(screen, "Installed OS version")
self.assertIsNotNone(current_version_label, "Current version label not found")
# Check for update button text (case insensitive)
# Button text will be "Update OS", "Reinstall\nsame version", or "Install\nolder version"
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)
wait_for_render(60)
screen = lv.screen_active()
# Verify the button text is present - it will be "Update OS" initially
# (or "Reinstall\nsame version" or "Install\nolder version" depending on version comparison)
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)
wait_for_render(60)
screen = lv.screen_active()
# Find version label
version_label = find_label_with_text(screen, "Installed OS version:")
self.assertIsNotNone(version_label, "Version label not found")
# Check that it contains the current version
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."""
# This test assumes desktop mode where wifi check returns True
# On actual hardware without wifi, it would show error
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
wait_for_render(60)
screen = lv.screen_active()
# Should show either "Checking for OS updates..." or update info
# or wifi error depending on network state
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)
wait_for_render(60)
screen = lv.screen_active()
# Print labels for debugging
print("\n=== OSUpdate Initial State Labels ===")
print_screen_labels(screen)
class TestOSUpdateGraphicalStatusMessages(unittest.TestCase):
"""Graphical tests for OSUpdate status messages."""
def tearDown(self):
"""Clean up after test."""
mpos.ui.back_screen()
wait_for_render(60)
def test_status_label_exists(self):
"""Test that status label is created and visible."""
result = AppManager.start_app("com.micropythonos.osupdate")
self.assertTrue(result)
wait_for_render(60)
screen = lv.screen_active()
# Status label should exist and show some text
# Look for common status messages
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)
wait_for_render(60)
screen = lv.screen_active()
# Print all labels to verify they're readable
print("\n=== All OSUpdate Labels ===")
print_screen_labels(screen)
# At minimum, should have version label
version_found = verify_text_present(screen, "Installed OS version")
self.assertTrue(version_found, "Version label should be present and readable")