summaryrefslogtreecommitdiffstatshomepage
path: root/tests/extmod/framebuf_subclass.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-02-19 22:45:32 +1100
committerDamien George <damien.p.george@gmail.com>2020-02-21 13:32:48 +1100
commitf8449dd092cb3ab7c74686db972500dc194613f7 (patch)
tree9d82a35bf73a94eedad3dd7e8e77eea7882b237b /tests/extmod/framebuf_subclass.py
parentf6d99bc7952d5854fc5822d9cf54b792794f6da7 (diff)
downloadmicropython-f8449dd092cb3ab7c74686db972500dc194613f7.tar.gz
micropython-f8449dd092cb3ab7c74686db972500dc194613f7.zip
extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer.
Diffstat (limited to 'tests/extmod/framebuf_subclass.py')
-rw-r--r--tests/extmod/framebuf_subclass.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/extmod/framebuf_subclass.py b/tests/extmod/framebuf_subclass.py
index 6363c224fb..f44a306a35 100644
--- a/tests/extmod/framebuf_subclass.py
+++ b/tests/extmod/framebuf_subclass.py
@@ -18,3 +18,25 @@ fb = FB(n=3)
fb.pixel(0, 0, 0x0102)
fb.foo()
print(bytes(fb))
+
+# Test that blitting a subclass works.
+fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565)
+fb.fill(0)
+fb.pixel(0, 0, 0x0506)
+fb.pixel(2, 2, 0x0708)
+fb2.blit(fb, 0, 0)
+print(bytes(fb2))
+
+# Test that blitting something that isn't a subclass fails with TypeError.
+class NotAFrameBuf:
+ pass
+
+try:
+ fb.blit(NotAFrameBuf(), 0, 0)
+except TypeError:
+ print('TypeError')
+
+try:
+ fb.blit(None, 0, 0)
+except TypeError:
+ print('TypeError')