def test_capture_noops(): fname = NamedTemporaryFile(suffix=".png").name device = capture(file_template=fname, transform="none") # All these should have no effect device.hide() device.show() device.command(1, 2, 4, 4) device.data([1, 2, 4, 4])
def test_portrait(): reference = os.path.abspath( os.path.join(os.path.dirname(__file__), 'reference', 'portrait.png')) fname = NamedTemporaryFile(suffix=".png").name device = capture(rotate=1, file_template=fname, transform="none") # Use the same drawing primitives as the demo with canvas(device) as draw: baseline_data.primitives(device, draw) assert md5(reference) == md5(fname)
def test_viewport_set_position(): reference = os.path.abspath( os.path.join(os.path.dirname(__file__), 'reference', 'set_position.png')) fname = NamedTemporaryFile(suffix=".png").name device = capture(file_template=fname, transform="none") virtual = viewport(device, 200, 200) # Use the same drawing primitives as the demo with canvas(virtual) as draw: baseline_data.primitives(virtual, draw) virtual.set_position((20, 30)) assert md5(reference) == md5(fname)
def test_viewport_hotspot(): reference = os.path.abspath( os.path.join(os.path.dirname(__file__), 'reference', 'hotspot.png')) fname = NamedTemporaryFile(suffix=".png").name device = capture(file_template=fname, transform="none") virtual = viewport(device, 200, 200) def draw_fn(draw, width, height): baseline_data.primitives(device, draw) widget = hotspot(device.width, device.height, draw_fn) virtual.add_hotspot(widget, (19, 56)) virtual.set_position((28, 30)) assert md5(reference) == md5(fname)