コード例 #1
0
def _test_level_against_reference(level_view: LevelView, qtbot):
    qtbot.addWidget(level_view)

    image_name = f"{level_view.level_ref.level.name}.png"
    ref_image_path = str(reference_image_dir.joinpath(image_name))

    level_view.repaint()

    compare_images(image_name, ref_image_path, level_view.grab())
コード例 #2
0
def test_world_map_drawing(world_number, qtbot):
    world_map = WorldMap(world_number)

    view = WorldMapView(None, world_map)
    view.resize(view.sizeHint())

    qtbot.addWidget(view)

    image_name = f"world_map_{world_number}.png"
    reference_image_path = str(reference_image_dir.joinpath(image_name))

    compare_images(image_name, reference_image_path, view.grab())
コード例 #3
0
def test_draw_m3ls(m3l_file_name, level, qtbot):
    with open(m3l_file_name, "rb") as m3l_file:
        level.from_m3l(bytearray(m3l_file.read()))

        ref = LevelRef()
        ref._internal_level = level

        view = LevelView(None, ref, ContextMenu(ref))
        view.draw_grid = False

        compare_images(m3l_file_name.stem,
                       str(reference_image_dir / f"{m3l_file_name.stem}.png"),
                       view.grab())
コード例 #4
0
def _test_object_against_reference(level_object, qtbot):
    object_set_number = level_object.object_set.number
    view = ObjectDrawArea(None, object_set_number, object_set_number)

    qtbot.addWidget(view)

    view.update_object(level_object)

    view.setGeometry(0, 0, *level_object.display_size().toTuple())

    image_name = f"object_set_{object_set_number}_domain_{level_object.domain}_index_{hex(level_object.obj_index)}.png"
    ref_image_path = str(reference_image_dir.joinpath(image_name))

    compare_images(image_name, ref_image_path, view.grab())
コード例 #5
0
def test_draw_jumps(jump_test_name, level, qtbot):
    with open(str(Path(__file__).parent / f"{jump_test_name}.m3l"),
              "rb") as m3l_file:
        level.from_m3l(bytearray(m3l_file.read()))

        ref = LevelRef()
        ref._internal_level = level

        view = LevelView(None, ref, ContextMenu(ref))
        view.draw_jumps = True
        view.draw_grid = False

        compare_images(jump_test_name,
                       str(Path(__file__).parent / f"{jump_test_name}.png"),
                       view.grab())