tests/extmod: Add test which subclasses framebuf.FrameBuffer.
This commit is contained in:
parent
fd0b0db873
commit
3c28df1658
20
tests/extmod/framebuf_subclass.py
Normal file
20
tests/extmod/framebuf_subclass.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# test subclassing framebuf.FrameBuffer
|
||||||
|
|
||||||
|
try:
|
||||||
|
import framebuf
|
||||||
|
except ImportError:
|
||||||
|
print('SKIP')
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
class FB(framebuf.FrameBuffer):
|
||||||
|
def __init__(self, n):
|
||||||
|
self.n = n
|
||||||
|
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
|
||||||
|
|
||||||
|
def foo(self):
|
||||||
|
self.hline(0, 2, self.n, 0x0304)
|
||||||
|
|
||||||
|
fb = FB(n=3)
|
||||||
|
fb.pixel(0, 0, 0x0102)
|
||||||
|
fb.foo()
|
||||||
|
print(bytes(fb))
|
1
tests/extmod/framebuf_subclass.py.exp
Normal file
1
tests/extmod/framebuf_subclass.py.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03'
|
Loading…
x
Reference in New Issue
Block a user