From 3c28df16586157b6b80e7437559c36f05a309e24 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 12 Dec 2017 14:00:16 +1100 Subject: [PATCH] tests/extmod: Add test which subclasses framebuf.FrameBuffer. --- tests/extmod/framebuf_subclass.py | 20 ++++++++++++++++++++ tests/extmod/framebuf_subclass.py.exp | 1 + 2 files changed, 21 insertions(+) create mode 100644 tests/extmod/framebuf_subclass.py create mode 100644 tests/extmod/framebuf_subclass.py.exp diff --git a/tests/extmod/framebuf_subclass.py b/tests/extmod/framebuf_subclass.py new file mode 100644 index 0000000000..6363c224fb --- /dev/null +++ b/tests/extmod/framebuf_subclass.py @@ -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)) diff --git a/tests/extmod/framebuf_subclass.py.exp b/tests/extmod/framebuf_subclass.py.exp new file mode 100644 index 0000000000..23d53ccc62 --- /dev/null +++ b/tests/extmod/framebuf_subclass.py.exp @@ -0,0 +1 @@ +b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03'