@@ -18,6 +18,8 @@ hardware_init: |
1818 dev = WS_OLED_128X128_SPI(spi, dc, res, cs)
1919
2020tests :
21+ # ----- Mock: Smoke tests -----
22+
2123 - name : " Fill black does not crash"
2224 action : call
2325 method : fill
@@ -36,28 +38,131 @@ tests:
3638 args : ["Test", 0, 0, 15]
3739 mode : [mock]
3840
39- - name : " Power off does not crash"
41+ - name : " Show does not crash"
42+ action : call
43+ method : show
44+ mode : [mock]
45+
46+ # ----- Mock: Verify power_off sends correct commands -----
47+
48+ - name : " Power off sends FN_SELECT_A disable and DISP off"
4049 action : script
4150 script : |
51+ i2c.clear_write_log()
4252 dev.power_off()
43- result = True
53+ log = i2c.get_write_log()
54+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
55+ # Expect: SET_FN_SELECT_A (0xAB), 0x00 (disable VDD), SET_DISP (0xAE)
56+ result = cmds == [0xAB, 0x00, 0xAE]
4457 expect_true : true
4558 mode : [mock]
4659
47- - name : " Power on does not crash"
60+ # ----- Mock: Verify power_on sends correct commands -----
61+
62+ - name : " Power on sends FN_SELECT_A enable and DISP on"
4863 action : script
4964 script : |
50- dev.power_off ()
65+ i2c.clear_write_log ()
5166 dev.power_on()
52- result = True
67+ log = i2c.get_write_log()
68+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
69+ # Expect: SET_FN_SELECT_A (0xAB), 0x01 (enable VDD), SET_DISP|0x01 (0xAF)
70+ result = cmds == [0xAB, 0x01, 0xAF]
5371 expect_true : true
5472 mode : [mock]
5573
56- - name : " Show does not crash"
57- action : call
58- method : show
74+ # ----- Mock: Verify contrast command -----
75+
76+ - name : " Contrast sends SET_CONTRAST with value"
77+ action : script
78+ script : |
79+ i2c.clear_write_log()
80+ dev.contrast(200)
81+ log = i2c.get_write_log()
82+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
83+ result = cmds == [0x81, 200]
84+ expect_true : true
85+ mode : [mock]
86+
87+ # ----- Mock: Verify invert commands -----
88+
89+ - name : " Invert on sends SET_DISP_MODE inverted"
90+ action : script
91+ script : |
92+ i2c.clear_write_log()
93+ dev.invert(True)
94+ log = i2c.get_write_log()
95+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
96+ # SET_DISP_MODE (0xA4) | 0x03 = 0xA7 (inverted)
97+ result = cmds == [0xA7]
98+ expect_true : true
5999 mode : [mock]
60100
101+ - name : " Invert off sends SET_DISP_MODE normal"
102+ action : script
103+ script : |
104+ i2c.clear_write_log()
105+ dev.invert(False)
106+ log = i2c.get_write_log()
107+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
108+ # SET_DISP_MODE (0xA4) = normal
109+ result = cmds == [0xA4]
110+ expect_true : true
111+ mode : [mock]
112+
113+ # ----- Mock: Verify rotate commands -----
114+
115+ - name : " Rotate sends offset and remap commands"
116+ action : script
117+ script : |
118+ i2c.clear_write_log()
119+ dev.rotate(True)
120+ log = i2c.get_write_log()
121+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
122+ # power_off (3 cmds) + SET_DISP_OFFSET, 128, SET_SEG_REMAP, 0x42 + power_on (3 cmds)
123+ result = 0xA2 in cmds and 0x42 in cmds and 128 in cmds
124+ expect_true : true
125+ mode : [mock]
126+
127+ # ----- Mock: Verify show sends column/row addr + data -----
128+
129+ - name : " Show sends column and row address then data"
130+ action : script
131+ script : |
132+ i2c.clear_write_log()
133+ dev.show()
134+ log = i2c.get_write_log()
135+ cmds = [data[1] for reg, data in log if reg is None and len(data) == 2 and data[0] == 0x80]
136+ # SET_COL_ADDR (0x15), start, end, SET_ROW_ADDR (0x75), start, end
137+ has_col = 0x15 in cmds
138+ has_row = 0x75 in cmds
139+ # Check data was sent (writevto with 0x40 prefix)
140+ has_data = any(reg is None and len(data) > 2 and data[0] == 0x40 for reg, data in log)
141+ result = has_col and has_row and has_data
142+ expect_true : true
143+ mode : [mock]
144+
145+ # ----- Mock: Verify pixel buffer -----
146+
147+ - name : " Pixel modifies framebuffer"
148+ action : script
149+ script : |
150+ dev.fill(0)
151+ dev.pixel(10, 20, 15)
152+ result = dev.framebuf.pixel(10, 20) == 15
153+ expect_true : true
154+ mode : [mock]
155+
156+ - name : " Fill sets all pixels"
157+ action : script
158+ script : |
159+ dev.fill(7)
160+ result = dev.framebuf.pixel(0, 0) == 7 and dev.framebuf.pixel(63, 63) == 7
161+ expect_true : true
162+ mode : [mock]
163+
164+ # ----- Hardware -----
165+
61166 - name : " Display white screen"
62167 action : hardware_script
63168 script : |
0 commit comments