示例#1
0
 def test_screen(self):
     # Testing the screen - drawing a "crosshair" to test screen edges and lines
     c = Canvas(self.o)
     c.line((0, 0, 10, 0))
     c.line(("-1", 0, "-10", 0))
     c.line((0, "-1", 10, "-1"))
     c.line(("-1", "-1", "-10", "-1"))
     c.line((0, 0, 0, 10))
     c.line((0, "-1", 0, "-10"))
     c.line(("-1", 10, "-1", 0))
     c.line(("-1", "-1", "-1", "-10"))
     c.line((0, 0, "-1", "-1"))
     c.line((0, "-1", "-1", 0))
     eh = ExitHelper(self.i, ["KEY_ENTER", "KEY_LEFT"]).start()
     c.display()
     sleep(1)
     for x in range(30):
         if eh.do_run():
             if x % 10 == 0:
                 c.invert()
                 c.display()
             sleep(0.1)
         else:
             break
     # Filling the screen (still using the same ExitHelper)
     c = Canvas(self.o)
     for x in range(60):
         if eh.do_run():
             if x % 20 == 0:
                 c.invert()
                 c.display()
             sleep(0.1)
         else:
             break
示例#2
0
 def test_invert_rgb(self):
     """tests that rgb canvas inversion doesn't fail with RGB displays and returns a valid RGB image"""
     test_image = get_image("canvas_10.png")
     o = get_mock_output(mode="RGB")
     c = Canvas(o, name=c_name)
     c.text("Hello world", (5, 5))
     c.invert()
     assert (c.get_image().mode == o.device_mode)
     assert (imgs_are_equal(c.get_image(), test_image.convert("RGB")))
示例#3
0
 def test_invert(self):
     """tests that inversion works with default display"""
     test_image = get_image("canvas_10.png")
     o = get_mock_output()
     c = Canvas(o, name=c_name)
     c.text("Hello world", (5, 5))
     c.invert()
     assert (c.get_image().mode == o.device_mode)
     assert (imgs_are_equal(c.get_image(), test_image))