Skip to content

Commit f8e0eb5

Browse files
Fix failing unit tests
1 parent 354d2c5 commit f8e0eb5

5 files changed

+65
-65
lines changed

tests/test_graphical_animation_deleted_widget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ def test_keyboard_scenario(self):
130130
"""
131131
print("Testing keyboard deletion scenario...")
132132

133-
from mpos.ui.keyboard import CustomKeyboard
133+
from mpos.ui.keyboard import MposKeyboard
134134

135135
# Create textarea and keyboard (like QuasiNametag does)
136136
textarea = lv.textarea(self.screen)
137137
textarea.set_size(280, 40)
138138
textarea.align(lv.ALIGN.TOP_MID, 0, 10)
139139

140-
keyboard = CustomKeyboard(self.screen)
140+
keyboard = MposKeyboard(self.screen)
141141
keyboard.set_textarea(textarea)
142142
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
143143
keyboard.add_flag(lv.obj.FLAG.HIDDEN)

tests/test_graphical_custom_keyboard.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Graphical tests for CustomKeyboard.
2+
Graphical tests for MposKeyboard.
33
44
Tests keyboard visual appearance, text input via simulated button presses,
55
and mode switching. Captures screenshots for regression testing.
@@ -13,15 +13,15 @@
1313
import lvgl as lv
1414
import sys
1515
import os
16-
from mpos.ui.keyboard import CustomKeyboard, create_keyboard
16+
from mpos.ui.keyboard import MposKeyboard, create_keyboard
1717
from graphical_test_helper import (
1818
wait_for_render,
1919
capture_screenshot,
2020
)
2121

2222

23-
class TestGraphicalCustomKeyboard(unittest.TestCase):
24-
"""Test suite for CustomKeyboard graphical verification."""
23+
class TestGraphicalMposKeyboard(unittest.TestCase):
24+
"""Test suite for MposKeyboard graphical verification."""
2525

2626
def setUp(self):
2727
"""Set up test fixtures before each test method."""
@@ -65,7 +65,7 @@ def _create_test_keyboard_scene(self):
6565
textarea.set_one_line(True)
6666

6767
# Create custom keyboard
68-
keyboard = CustomKeyboard(screen)
68+
keyboard = MposKeyboard(screen)
6969
keyboard.set_textarea(textarea)
7070
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
7171

@@ -114,7 +114,7 @@ def test_keyboard_lowercase_appearance(self):
114114
screen, keyboard, textarea = self._create_test_keyboard_scene()
115115

116116
# Ensure lowercase mode
117-
keyboard.set_mode(CustomKeyboard.MODE_LOWERCASE)
117+
keyboard.set_mode(MposKeyboard.MODE_LOWERCASE)
118118
wait_for_render(10)
119119

120120
# Capture screenshot
@@ -136,7 +136,7 @@ def test_keyboard_uppercase_appearance(self):
136136
screen, keyboard, textarea = self._create_test_keyboard_scene()
137137

138138
# Switch to uppercase mode
139-
keyboard.set_mode(CustomKeyboard.MODE_UPPERCASE)
139+
keyboard.set_mode(MposKeyboard.MODE_UPPERCASE)
140140
wait_for_render(10)
141141

142142
# Capture screenshot
@@ -158,7 +158,7 @@ def test_keyboard_numbers_appearance(self):
158158
screen, keyboard, textarea = self._create_test_keyboard_scene()
159159

160160
# Switch to numbers mode
161-
keyboard.set_mode(CustomKeyboard.MODE_NUMBERS)
161+
keyboard.set_mode(MposKeyboard.MODE_NUMBERS)
162162
wait_for_render(10)
163163

164164
# Capture screenshot
@@ -180,7 +180,7 @@ def test_keyboard_specials_appearance(self):
180180
screen, keyboard, textarea = self._create_test_keyboard_scene()
181181

182182
# Switch to specials mode
183-
keyboard.set_mode(CustomKeyboard.MODE_SPECIALS)
183+
keyboard.set_mode(MposKeyboard.MODE_SPECIALS)
184184
wait_for_render(10)
185185

186186
# Capture screenshot
@@ -248,7 +248,7 @@ def test_keyboard_visibility_light_mode(self):
248248

249249
self.assertFalse(
250250
is_white,
251-
f"Custom keyboard buttons are pure white in light mode (invisible)!"
251+
f"Mpos keyboard buttons are pure white in light mode (invisible)!"
252252
)
253253

254254
print("=== Visibility test PASSED ===")

tests/test_graphical_custom_keyboard_basic.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Functional tests for CustomKeyboard.
2+
Functional tests for MposKeyboard.
33
44
Tests keyboard creation, mode switching, text input, and API compatibility.
55
@@ -10,11 +10,11 @@
1010

1111
import unittest
1212
import lvgl as lv
13-
from mpos.ui.keyboard import CustomKeyboard, create_keyboard
13+
from mpos.ui.keyboard import MposKeyboard, create_keyboard
1414

1515

16-
class TestCustomKeyboard(unittest.TestCase):
17-
"""Test suite for CustomKeyboard functionality."""
16+
class TestMposKeyboard(unittest.TestCase):
17+
"""Test suite for MposKeyboard functionality."""
1818

1919
def setUp(self):
2020
"""Set up test fixtures before each test method."""
@@ -37,10 +37,10 @@ def tearDown(self):
3737
print("=== Test Cleanup Complete ===\n")
3838

3939
def test_keyboard_creation(self):
40-
"""Test that CustomKeyboard can be created."""
40+
"""Test that MposKeyboard can be created."""
4141
print("Testing keyboard creation...")
4242

43-
keyboard = CustomKeyboard(self.screen)
43+
keyboard = MposKeyboard(self.screen)
4444

4545
# Verify keyboard exists
4646
self.assertIsNotNone(keyboard)
@@ -54,20 +54,20 @@ def test_keyboard_factory_custom(self):
5454

5555
keyboard = create_keyboard(self.screen, custom=True)
5656

57-
# Verify it's a CustomKeyboard instance
58-
self.assertIsInstance(keyboard, CustomKeyboard)
57+
# Verify it's a MposKeyboard instance
58+
self.assertIsInstance(keyboard, MposKeyboard)
5959

60-
print("Factory created CustomKeyboard successfully")
60+
print("Factory created MposKeyboard successfully")
6161

6262
def test_keyboard_factory_standard(self):
6363
"""Test factory function creates standard keyboard."""
6464
print("Testing factory function with custom=False...")
6565

6666
keyboard = create_keyboard(self.screen, custom=False)
6767

68-
# Verify it's an LVGL keyboard (not CustomKeyboard)
69-
self.assertFalse(isinstance(keyboard, CustomKeyboard),
70-
"Factory with custom=False should not create CustomKeyboard")
68+
# Verify it's an LVGL keyboard (not MposKeyboard)
69+
self.assertFalse(isinstance(keyboard, MposKeyboard),
70+
"Factory with custom=False should not create MposKeyboard")
7171
# It should be an lv.keyboard instance
7272
self.assertEqual(type(keyboard).__name__, 'keyboard')
7373

@@ -77,7 +77,7 @@ def test_set_textarea(self):
7777
"""Test setting textarea association."""
7878
print("Testing set_textarea...")
7979

80-
keyboard = CustomKeyboard(self.screen)
80+
keyboard = MposKeyboard(self.screen)
8181
keyboard.set_textarea(self.textarea)
8282

8383
# Verify textarea is associated
@@ -90,21 +90,21 @@ def test_mode_switching(self):
9090
"""Test keyboard mode switching."""
9191
print("Testing mode switching...")
9292

93-
keyboard = CustomKeyboard(self.screen)
93+
keyboard = MposKeyboard(self.screen)
9494

9595
# Test setting different modes
96-
keyboard.set_mode(CustomKeyboard.MODE_LOWERCASE)
97-
keyboard.set_mode(CustomKeyboard.MODE_UPPERCASE)
98-
keyboard.set_mode(CustomKeyboard.MODE_NUMBERS)
99-
keyboard.set_mode(CustomKeyboard.MODE_SPECIALS)
96+
keyboard.set_mode(MposKeyboard.MODE_LOWERCASE)
97+
keyboard.set_mode(MposKeyboard.MODE_UPPERCASE)
98+
keyboard.set_mode(MposKeyboard.MODE_NUMBERS)
99+
keyboard.set_mode(MposKeyboard.MODE_SPECIALS)
100100

101101
print("Mode switching successful")
102102

103103
def test_alignment(self):
104104
"""Test keyboard alignment."""
105105
print("Testing alignment...")
106106

107-
keyboard = CustomKeyboard(self.screen)
107+
keyboard = MposKeyboard(self.screen)
108108
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
109109

110110
print("Alignment successful")
@@ -113,7 +113,7 @@ def test_height_settings(self):
113113
"""Test height configuration."""
114114
print("Testing height settings...")
115115

116-
keyboard = CustomKeyboard(self.screen)
116+
keyboard = MposKeyboard(self.screen)
117117
keyboard.set_style_min_height(160, 0)
118118
keyboard.set_style_height(160, 0)
119119

@@ -123,7 +123,7 @@ def test_flags(self):
123123
"""Test object flags (show/hide)."""
124124
print("Testing flags...")
125125

126-
keyboard = CustomKeyboard(self.screen)
126+
keyboard = MposKeyboard(self.screen)
127127

128128
# Test hiding
129129
keyboard.add_flag(lv.obj.FLAG.HIDDEN)
@@ -139,7 +139,7 @@ def test_event_callback(self):
139139
"""Test adding event callbacks."""
140140
print("Testing event callbacks...")
141141

142-
keyboard = CustomKeyboard(self.screen)
142+
keyboard = MposKeyboard(self.screen)
143143
callback_called = [False]
144144

145145
def test_callback(event):
@@ -157,10 +157,10 @@ def test_callback(event):
157157
print("Event callback successful")
158158

159159
def test_api_compatibility(self):
160-
"""Test that CustomKeyboard has same API as lv.keyboard."""
160+
"""Test that MposKeyboard has same API as lv.keyboard."""
161161
print("Testing API compatibility...")
162162

163-
keyboard = CustomKeyboard(self.screen)
163+
keyboard = MposKeyboard(self.screen)
164164

165165
# Check that all essential methods exist
166166
essential_methods = [
@@ -178,11 +178,11 @@ def test_api_compatibility(self):
178178
for method_name in essential_methods:
179179
self.assertTrue(
180180
hasattr(keyboard, method_name),
181-
f"CustomKeyboard missing method: {method_name}"
181+
f"MposKeyboard missing method: {method_name}"
182182
)
183183
self.assertTrue(
184184
callable(getattr(keyboard, method_name)),
185-
f"CustomKeyboard.{method_name} is not callable"
185+
f"MposKeyboard.{method_name} is not callable"
186186
)
187187

188188
print("API compatibility verified")

tests/test_graphical_keyboard_animation.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
Test CustomKeyboard animation support (show/hide with mpos.ui.anim).
2+
Test MposKeyboard animation support (show/hide with mpos.ui.anim).
33
4-
This test reproduces the bug where CustomKeyboard is missing methods
4+
This test reproduces the bug where MposKeyboard is missing methods
55
required by mpos.ui.anim.smooth_show() and smooth_hide().
66
77
Usage:
@@ -12,11 +12,11 @@
1212
import unittest
1313
import lvgl as lv
1414
import mpos.ui.anim
15-
from mpos.ui.keyboard import CustomKeyboard
15+
from mpos.ui.keyboard import MposKeyboard
1616

1717

1818
class TestKeyboardAnimation(unittest.TestCase):
19-
"""Test CustomKeyboard compatibility with animation system."""
19+
"""Test MposKeyboard compatibility with animation system."""
2020

2121
def setUp(self):
2222
"""Set up test fixtures."""
@@ -40,25 +40,25 @@ def tearDown(self):
4040

4141
def test_keyboard_has_set_style_opa(self):
4242
"""
43-
Test that CustomKeyboard has set_style_opa method.
43+
Test that MposKeyboard has set_style_opa method.
4444
4545
This method is required by mpos.ui.anim for fade animations.
4646
"""
47-
print("Testing that CustomKeyboard has set_style_opa...")
47+
print("Testing that MposKeyboard has set_style_opa...")
4848

49-
keyboard = CustomKeyboard(self.screen)
49+
keyboard = MposKeyboard(self.screen)
5050
keyboard.set_textarea(self.textarea)
5151
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
5252
keyboard.add_flag(lv.obj.FLAG.HIDDEN)
5353

5454
# Verify method exists
5555
self.assertTrue(
5656
hasattr(keyboard, 'set_style_opa'),
57-
"CustomKeyboard missing set_style_opa method"
57+
"MposKeyboard missing set_style_opa method"
5858
)
5959
self.assertTrue(
6060
callable(getattr(keyboard, 'set_style_opa')),
61-
"CustomKeyboard.set_style_opa is not callable"
61+
"MposKeyboard.set_style_opa is not callable"
6262
)
6363

6464
# Try calling it (should not raise AttributeError)
@@ -72,13 +72,13 @@ def test_keyboard_has_set_style_opa(self):
7272

7373
def test_keyboard_smooth_show(self):
7474
"""
75-
Test that CustomKeyboard can be shown with smooth_show animation.
75+
Test that MposKeyboard can be shown with smooth_show animation.
7676
7777
This reproduces the actual user interaction in QuasiNametag.
7878
"""
7979
print("Testing smooth_show animation...")
8080

81-
keyboard = CustomKeyboard(self.screen)
81+
keyboard = MposKeyboard(self.screen)
8282
keyboard.set_textarea(self.textarea)
8383
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
8484
keyboard.add_flag(lv.obj.FLAG.HIDDEN)
@@ -89,7 +89,7 @@ def test_keyboard_smooth_show(self):
8989
print("smooth_show called successfully")
9090
except AttributeError as e:
9191
self.fail(f"smooth_show raised AttributeError: {e}\n"
92-
"This is the bug - CustomKeyboard missing animation methods")
92+
"This is the bug - MposKeyboard missing animation methods")
9393

9494
# Verify keyboard is no longer hidden
9595
self.assertFalse(
@@ -101,13 +101,13 @@ def test_keyboard_smooth_show(self):
101101

102102
def test_keyboard_smooth_hide(self):
103103
"""
104-
Test that CustomKeyboard can be hidden with smooth_hide animation.
104+
Test that MposKeyboard can be hidden with smooth_hide animation.
105105
106106
This reproduces the hide behavior in QuasiNametag.
107107
"""
108108
print("Testing smooth_hide animation...")
109109

110-
keyboard = CustomKeyboard(self.screen)
110+
keyboard = MposKeyboard(self.screen)
111111
keyboard.set_textarea(self.textarea)
112112
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
113113
# Start visible
@@ -119,7 +119,7 @@ def test_keyboard_smooth_hide(self):
119119
print("smooth_hide called successfully")
120120
except AttributeError as e:
121121
self.fail(f"smooth_hide raised AttributeError: {e}\n"
122-
"This is the bug - CustomKeyboard missing animation methods")
122+
"This is the bug - MposKeyboard missing animation methods")
123123

124124
print("=== smooth_hide test PASSED ===")
125125

@@ -133,7 +133,7 @@ def test_keyboard_show_hide_cycle(self):
133133
"""
134134
print("Testing full show/hide cycle...")
135135

136-
keyboard = CustomKeyboard(self.screen)
136+
keyboard = MposKeyboard(self.screen)
137137
keyboard.set_textarea(self.textarea)
138138
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
139139
keyboard.add_flag(lv.obj.FLAG.HIDDEN)
@@ -160,13 +160,13 @@ def test_keyboard_show_hide_cycle(self):
160160

161161
def test_keyboard_has_get_y_and_set_y(self):
162162
"""
163-
Test that CustomKeyboard has get_y and set_y methods.
163+
Test that MposKeyboard has get_y and set_y methods.
164164
165165
These are required for slide animations (though not currently used).
166166
"""
167167
print("Testing get_y and set_y methods...")
168168

169-
keyboard = CustomKeyboard(self.screen)
169+
keyboard = MposKeyboard(self.screen)
170170
keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
171171

172172
# Verify methods exist

0 commit comments

Comments
 (0)